Export SDK as a class to allow multiple instances
This commit is contained in:
parent
2ccdf4b10b
commit
96685f3258
|
@ -1,22 +1,23 @@
|
||||||
import * as BudibaseApi from "../sdk"
|
import * as BudibaseApi from "../sdk"
|
||||||
|
|
||||||
let ApiClient = new BudibaseApi.ApiClient()
|
export default class SDK {
|
||||||
|
applications = new BudibaseApi.ApplicationsApi()
|
||||||
|
queries = new BudibaseApi.QueriesApi()
|
||||||
|
rows = new BudibaseApi.RowsApi()
|
||||||
|
tables = new BudibaseApi.TablesApi()
|
||||||
|
users = new BudibaseApi.UsersApi()
|
||||||
|
|
||||||
// Default to current host
|
constructor({ apiKey, host }) {
|
||||||
ApiClient.basePath = "/api/public/v1"
|
let ApiClient = new BudibaseApi.ApiClient()
|
||||||
|
|
||||||
/**
|
// Default to current host
|
||||||
* Configures the Budibase Public API SDK
|
ApiClient.basePath = `${host || ""}/api/public/v1`
|
||||||
* @param apiKey the user's API key
|
ApiClient.authentications["ApiKeyAuth"].apiKey = apiKey
|
||||||
* @param host the Budibase server host
|
|
||||||
*/
|
this.applications = new BudibaseApi.ApplicationsApi(ApiClient)
|
||||||
export const configure = ({ apiKey, host }) => {
|
this.queries = new BudibaseApi.QueriesApi(ApiClient)
|
||||||
ApiClient.authentications["ApiKeyAuth"].apiKey = apiKey
|
this.rows = new BudibaseApi.RowsApi(ApiClient)
|
||||||
ApiClient.basePath = `${host || ""}/api/public/v1`
|
this.tables = new BudibaseApi.TablesApi(ApiClient)
|
||||||
|
this.users = new BudibaseApi.UsersApi(ApiClient)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ApplicationsApi = new BudibaseApi.ApplicationsApi(ApiClient)
|
|
||||||
export const QueriesApi = new BudibaseApi.QueriesApi(ApiClient)
|
|
||||||
export const RowsApi = new BudibaseApi.RowsApi(ApiClient)
|
|
||||||
export const TablesApi = new BudibaseApi.TablesApi(ApiClient)
|
|
||||||
export const UsersApi = new BudibaseApi.UsersApi(ApiClient)
|
|
||||||
|
|
Loading…
Reference in New Issue