Type licensing endpoints
This commit is contained in:
parent
b2b2648798
commit
85e86900d0
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
const activateLicenseKey = async () => {
|
const activateLicenseKey = async () => {
|
||||||
try {
|
try {
|
||||||
await API.activateLicenseKey({ licenseKey })
|
await API.activateLicenseKey(licenseKey)
|
||||||
await auth.getSelf()
|
await auth.getSelf()
|
||||||
await getLicenseKey()
|
await getLicenseKey()
|
||||||
notifications.success("Successfully activated")
|
notifications.success("Successfully activated")
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
|
|
||||||
async function activateOfflineLicense(offlineLicenseToken) {
|
async function activateOfflineLicense(offlineLicenseToken) {
|
||||||
try {
|
try {
|
||||||
await API.activateOfflineLicense({ offlineLicenseToken })
|
await API.activateOfflineLicense(offlineLicenseToken)
|
||||||
await auth.getSelf()
|
await auth.getSelf()
|
||||||
await getOfflineLicense()
|
await getOfflineLicense()
|
||||||
notifications.success("Successfully activated")
|
notifications.success("Successfully activated")
|
||||||
|
|
|
@ -1,10 +1,34 @@
|
||||||
export const buildLicensingEndpoints = API => ({
|
import {
|
||||||
|
ActivateLicenseKeyRequest,
|
||||||
|
ActivateOfflineLicenseTokenRequest,
|
||||||
|
GetLicenseKeyResponse,
|
||||||
|
GetOfflineIdentifierResponse,
|
||||||
|
GetOfflineLicenseTokenResponse,
|
||||||
|
QuotaUsage,
|
||||||
|
} from "@budibase/types"
|
||||||
|
import { BaseAPIClient } from "./types"
|
||||||
|
|
||||||
|
export interface LicensingEndpoints {
|
||||||
|
activateLicenseKey: (licenseKey: string) => Promise<void>
|
||||||
|
deleteLicenseKey: () => Promise<void>
|
||||||
|
getLicenseKey: () => Promise<GetLicenseKeyResponse>
|
||||||
|
activateOfflineLicense: (offlineLicenseToken: string) => Promise<void>
|
||||||
|
deleteOfflineLicense: () => Promise<void>
|
||||||
|
getOfflineLicense: () => Promise<GetOfflineLicenseTokenResponse>
|
||||||
|
getOfflineLicenseIdentifier: () => Promise<GetOfflineIdentifierResponse>
|
||||||
|
refreshLicense: () => Promise<void>
|
||||||
|
getQuotaUsage: () => Promise<QuotaUsage>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const buildLicensingEndpoints = (
|
||||||
|
API: BaseAPIClient
|
||||||
|
): LicensingEndpoints => ({
|
||||||
// LICENSE KEY
|
// LICENSE KEY
|
||||||
|
|
||||||
activateLicenseKey: async data => {
|
activateLicenseKey: async licenseKey => {
|
||||||
return API.post({
|
return API.post<ActivateLicenseKeyRequest>({
|
||||||
url: `/api/global/license/key`,
|
url: `/api/global/license/key`,
|
||||||
body: data,
|
body: { licenseKey },
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteLicenseKey: async () => {
|
deleteLicenseKey: async () => {
|
||||||
|
@ -26,8 +50,8 @@ export const buildLicensingEndpoints = API => ({
|
||||||
|
|
||||||
// OFFLINE LICENSE
|
// OFFLINE LICENSE
|
||||||
|
|
||||||
activateOfflineLicense: async ({ offlineLicenseToken }) => {
|
activateOfflineLicense: async offlineLicenseToken => {
|
||||||
return API.post({
|
return API.post<ActivateOfflineLicenseTokenRequest>({
|
||||||
url: "/api/global/license/offline",
|
url: "/api/global/license/offline",
|
||||||
body: {
|
body: {
|
||||||
offlineLicenseToken,
|
offlineLicenseToken,
|
|
@ -13,6 +13,7 @@ import { EventEndpoints } from "./events"
|
||||||
import { FlagEndpoints } from "./flags"
|
import { FlagEndpoints } from "./flags"
|
||||||
import { GroupEndpoints } from "./groups"
|
import { GroupEndpoints } from "./groups"
|
||||||
import { LayoutEndpoints } from "./layouts"
|
import { LayoutEndpoints } from "./layouts"
|
||||||
|
import { LicensingEndpoints } from "./licensing"
|
||||||
|
|
||||||
export enum HTTPMethod {
|
export enum HTTPMethod {
|
||||||
POST = "POST",
|
POST = "POST",
|
||||||
|
@ -87,4 +88,5 @@ export type APIClient = BaseAPIClient &
|
||||||
EventEndpoints &
|
EventEndpoints &
|
||||||
FlagEndpoints &
|
FlagEndpoints &
|
||||||
GroupEndpoints &
|
GroupEndpoints &
|
||||||
LayoutEndpoints
|
LayoutEndpoints &
|
||||||
|
LicensingEndpoints
|
||||||
|
|
Loading…
Reference in New Issue