1
0
Fork 0
mirror of synced 2024-05-16 18:33:53 +12:00
budibase/qa-core/src/internal-api/api/apis/SelfAPI.ts
2023-05-10 16:53:20 +01:00

30 lines
937 B
TypeScript

import { Response } from "node-fetch"
import { User } from "@budibase/types"
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
import { ApiKeyResponse } from "../../../types"
import BaseAPI from "./BaseAPI"
export default class SelfAPI extends BaseAPI {
constructor(client: BudibaseInternalAPIClient) {
super(client)
}
async getSelf(): Promise<[Response, Partial<User>]> {
const [response, json] = await this.get(`/global/self`)
return [response, json]
}
async changeSelfPassword(body: Partial<User>): Promise<[Response, User]> {
const [response, json] = await this.post(`/global/self`, body)
expect(json._id).toEqual(body._id)
expect(json._rev).not.toEqual(body._rev)
return [response, json]
}
async getApiKey(): Promise<ApiKeyResponse> {
const [response, json] = await this.get(`/global/self/api_key`)
expect(json).toHaveProperty("apiKey")
return json
}
}