Skip to content

Commit

Permalink
feat: add get auth token details method to manage client (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeocodes authored Apr 27, 2024
1 parent 57e3b6a commit 95757eb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/types/GetTokenDetailsResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface GetTokenDetailsResponse {
[key: string]: unknown;
}
1 change: 1 addition & 0 deletions src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type {
export type { GetProjectUsageRequestsSchema } from "./GetProjectUsageRequestsSchema";
export type { GetProjectUsageSummarySchema } from "./GetProjectUsageSummarySchema";
export type { GetProjectUsageSummaryResponse } from "./GetProjectUsageSummaryResponse";
export type { GetTokenDetailsResponse } from "./GetTokenDetailsResponse";
export type {
ListOnPremCredentialsResponse,
OnPremCredentialResponse,
Expand Down
23 changes: 23 additions & 0 deletions src/packages/ManageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,32 @@ import type {
UpdateProjectMemberScopeSchema,
UpdateProjectSchema,
VoidResponse,
GetTokenDetailsResponse,
} from "../lib/types";

export class ManageClient extends AbstractRestfulClient {
/**
* @see https://developers.deepgram.com/docs/authenticating#test-request
*/
async getTokenDetails(
endpoint = "v1/auth/token"
): Promise<DeepgramResponse<GetTokenDetailsResponse>> {
try {
const url = new URL(this.baseUrl);
url.pathname = endpoint;

const result: GetTokenDetailsResponse = await this.get(this.fetch as Fetch, url);

return { result, error: null };
} catch (error) {
if (isDeepgramError(error)) {
return { result: null, error };
}

throw error;
}
}

/**
* @see https://developers.deepgram.com/reference/get-projects
*/
Expand Down

0 comments on commit 95757eb

Please sign in to comment.