1
0
Fork 0
mirror of synced 2024-06-02 18:44:54 +12:00

Add Table endpoints

This commit is contained in:
Pedro Silva 2022-10-17 18:20:40 +01:00
parent bccc83d0d8
commit 5ba7100e48
2 changed files with 40 additions and 0 deletions

View file

@ -1,14 +1,17 @@
import ApplicationApi from "./applications"
import AuthApi from "./auth"
import InternalAPIClient from "./InternalAPIClient"
import TablesApi from "./tables"
export default class TestConfiguration<T> {
applications: ApplicationApi
auth: AuthApi
context: T
tables: TablesApi
constructor(apiClient: InternalAPIClient) {
this.applications = new ApplicationApi(apiClient)
this.tables = new TablesApi(apiClient)
this.auth = new AuthApi(apiClient)
this.context = <T>{}
}

View file

@ -0,0 +1,37 @@
import { Response } from "node-fetch"
import { Table } from "@budibase/types"
import InternalAPIClient from "./InternalAPIClient"
export default class TablesApi {
api: InternalAPIClient
constructor(apiClient: InternalAPIClient) {
this.api = apiClient
}
async getTables(): Promise<[Response, Table[]]> {
const response = await this.api.get(`/tables`)
const json = await response.json()
return [response, json]
}
async getTable(tableId: string): Promise<[Response, Table]> {
const response = await this.api.get(`/tables/${tableId}`)
const json = await response.json()
return [response, json]
}
async createTable(body: any): Promise<[Response, Table]> {
const response = await this.api.post(`/tables`, { body })
const json = await response.json()
return [response, json]
}
async deleteTable(tableId: string, revId: string): Promise<[Response, Table]> {
const response = await this.api.del(`/tables/${tableId}/${revId}`)
const json = await response.json()
return [response, json]
}
}