1
0
Fork 0
mirror of synced 2024-06-01 10:09:48 +12:00
budibase/qa-core/src/internal-api/api/apis/LicenseAPI.ts

64 lines
1.9 KiB
TypeScript
Raw Normal View History

2023-07-15 11:12:18 +12:00
import { Response } from "node-fetch"
import {
ActivateLicenseKeyRequest,
2023-07-15 11:12:18 +12:00
ActivateOfflineLicenseTokenRequest,
GetLicenseKeyResponse,
2023-07-15 11:12:18 +12:00
GetOfflineIdentifierResponse,
GetOfflineLicenseTokenResponse,
} from "@budibase/types"
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
import BaseAPI from "./BaseAPI"
import { APIRequestOpts } from "../../../types"
2023-07-15 11:12:18 +12:00
export default class LicenseAPI extends BaseAPI {
constructor(client: BudibaseInternalAPIClient) {
super(client)
}
2023-07-25 22:28:14 +12:00
async getOfflineLicenseToken(
2023-10-06 05:43:25 +13:00
opts: { status?: number } = {}
2023-07-25 22:28:14 +12:00
): Promise<[Response, GetOfflineLicenseTokenResponse]> {
const [response, body] = await this.get(
2023-10-06 05:43:25 +13:00
`/global/license/offline`,
opts.status
2023-07-25 22:28:14 +12:00
)
2023-07-15 11:12:18 +12:00
return [response, body]
}
async deleteOfflineLicenseToken(): Promise<[Response]> {
const [response] = await this.del(`/global/license/offline`, 204)
return [response]
}
2023-07-25 22:28:14 +12:00
async activateOfflineLicenseToken(
2023-10-06 05:43:25 +13:00
body: ActivateOfflineLicenseTokenRequest
2023-07-25 22:28:14 +12:00
): Promise<[Response]> {
2023-07-15 11:12:18 +12:00
const [response] = await this.post(`/global/license/offline`, body)
return [response]
}
2023-07-25 22:28:14 +12:00
async getOfflineIdentifier(): Promise<
2023-10-06 05:43:25 +13:00
[Response, GetOfflineIdentifierResponse]
2023-07-25 22:28:14 +12:00
> {
const [response, body] = await this.get(
2023-10-06 05:43:25 +13:00
`/global/license/offline/identifier`
2023-07-25 22:28:14 +12:00
)
2023-07-15 11:12:18 +12:00
return [response, body]
}
async getLicenseKey(
2023-10-06 05:43:25 +13:00
opts: { status?: number } = {}
): Promise<[Response, GetLicenseKeyResponse]> {
const [response, body] = await this.get(`/global/license/key`, opts.status)
return [response, body]
}
async activateLicenseKey(
2023-10-06 05:43:25 +13:00
body: ActivateLicenseKeyRequest
): Promise<[Response]> {
const [response] = await this.post(`/global/license/key`, body)
return [response]
}
async deleteLicenseKey(): Promise<[Response]> {
const [response] = await this.del(`/global/license/key`, 204)
return [response]
}
2023-10-06 05:43:25 +13:00
}