1
0
Fork 0
mirror of synced 2024-06-12 23:44:39 +12:00
budibase/qa-core/src/internal-api/api/apis/SelfAPI.ts

30 lines
937 B
TypeScript
Raw Normal View History

import { Response } from "node-fetch"
import { User } from "@budibase/types"
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
import { ApiKeyResponse } from "../../../types"
2023-05-11 03:53:20 +12:00
import BaseAPI from "./BaseAPI"
2023-05-11 03:53:20 +12:00
export default class SelfAPI extends BaseAPI {
constructor(client: BudibaseInternalAPIClient) {
2023-05-11 03:53:20 +12:00
super(client)
}
async getSelf(): Promise<[Response, Partial<User>]> {
2023-05-11 03:53:20 +12:00
const [response, json] = await this.get(`/global/self`)
return [response, json]
}
async changeSelfPassword(body: Partial<User>): Promise<[Response, User]> {
2023-05-11 03:53:20 +12:00
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> {
2023-05-11 03:53:20 +12:00
const [response, json] = await this.get(`/global/self/api_key`)
expect(json).toHaveProperty("apiKey")
return json
}
}