import { BaseClient } from "../client/baseClient"; import { GenerateTokenRequest, GenerateTokenResponse, KsefTokensListQueryParams, QueryTokensResponse, TokenStatusResponse, } from "../types/tokens"; export class TokensClient extends BaseClient { async listTokens( params?: KsefTokensListQueryParams, continuationToken?: string, ): Promise { const token = await this.getAccessToken(); const headers = continuationToken !== undefined ? { "x-continuation-token": continuationToken } : undefined; const query = params ? { status: params.status, description: params.description, authorIdentifier: params.authorIdentifier, authorIdentifierType: params.authorIdentifierType, pageSize: params.pageSize, } : undefined; return this.http.request({ method: "GET", path: "/tokens", ...(headers ? { headers } : {}), ...(query ? { query } : {}), authToken: token, }); } async generateToken(request: GenerateTokenRequest): Promise { const token = await this.getAccessToken(); return this.http.request({ method: "POST", path: "/tokens", body: request, authToken: token, }); } async getToken(referenceNumber: string): Promise { const token = await this.getAccessToken(); return this.http.request({ method: "GET", path: `/tokens/${encodeURIComponent(referenceNumber)}`, authToken: token, }); } async revokeToken(referenceNumber: string): Promise { const token = await this.getAccessToken(); await this.http.request({ method: "DELETE", path: `/tokens/${encodeURIComponent(referenceNumber)}`, authToken: token, }); } }