1
0
Fork 0
mirror of synced 2024-06-02 18:44:54 +12:00
budibase/qa-core/src/config/internal-api/TestConfiguration/tables.ts
2022-10-17 18:20:40 +01:00

37 lines
1.1 KiB
TypeScript

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]
}
}