Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support optional responses
Browse files Browse the repository at this point in the history
adamjmcgrath committed Sep 8, 2023
1 parent 986ccd7 commit e90012a
Showing 3 changed files with 19 additions and 11 deletions.
18 changes: 11 additions & 7 deletions playground/handlers.ts
Original file line number Diff line number Diff line change
@@ -324,14 +324,16 @@ export async function clients() {
const mgmntClient = new ManagementClient(program.opts());
const { data: newClient } = await mgmntClient.clients.create({ name: uuid() });
console.log('Create a client: ' + newClient.name);
const { data: client } = await mgmntClient.clients.get({ id: newClient.client_id as string });
const { data: client } = await mgmntClient.clients.get({
client_id: newClient.client_id as string,
});
console.log('Get the client: ' + client.name);
const { data: updatedClient } = await mgmntClient.clients.update(
{ id: client.client_id as string },
{ client_id: client.client_id as string },
{ name: uuid() }
);
console.log('Updated the client: ' + updatedClient.name);
await mgmntClient.clients.delete({ id: newClient.client_id as string });
await mgmntClient.clients.delete({ client_id: newClient.client_id as string });
console.log('Removed the client: ' + updatedClient.name);
}

@@ -524,8 +526,8 @@ export async function guardian() {

const { data: smsTemplates } = await mgmntClient.guardian.getSmsFactorTemplates();

console.log(`Get SMS enrollement message: ${smsTemplates.enrollment_message}`);
console.log(`Get SMS verification message: ${smsTemplates.verification_message}`);
console.log(`Get SMS enrollement message: ${smsTemplates?.enrollment_message}`);
console.log(`Get SMS verification message: ${smsTemplates?.verification_message}`);

const { data: updateSmsTemplates } = await mgmntClient.guardian.setSmsFactorTemplates({
enrollment_message: 'This is the encrollment message ' + uuid(),
@@ -794,7 +796,9 @@ export async function keys() {

const { data: newClient } = await mgmntClient.clients.create({ name: uuid() });
console.log('Create a client: ' + newClient.name);
const { data: client } = await mgmntClient.clients.get({ id: newClient.client_id as string });
const { data: client } = await mgmntClient.clients.get({
client_id: newClient.client_id as string,
});

const cert = client.signing_keys![0].cert;
const { data: keys } = await mgmntClient.keys.getAll();
@@ -803,7 +807,7 @@ export async function keys() {
const { data: key } = await mgmntClient.keys.get({ kid });
console.log('Got key:', key.kid);

await mgmntClient.clients.delete({ id: newClient.client_id as string });
await mgmntClient.clients.delete({ client_id: newClient.client_id as string });
console.log('Removed the client: ' + newClient.name);
}

6 changes: 4 additions & 2 deletions src/management/__generated/managers/guardian-manager.ts
Original file line number Diff line number Diff line change
@@ -135,7 +135,7 @@ export class GuardianManager extends BaseAPI {
*/
async getSmsFactorTemplates(
initOverrides?: InitOverride
): Promise<ApiResponse<TemplateMessages>> {
): Promise<ApiResponse<TemplateMessages | void>> {
const response = await this.request(
{
path: `/guardian/factors/sms/templates`,
@@ -144,7 +144,9 @@ export class GuardianManager extends BaseAPI {
initOverrides
);

return runtime.JSONApiResponse.fromResponse(response);
return response.status === 204
? runtime.VoidApiResponse.fromResponse(response)
: runtime.JSONApiResponse.fromResponse(response);
}

/**
6 changes: 4 additions & 2 deletions src/management/__generated/managers/jobs-manager.ts
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ export class JobsManager extends BaseAPI {
async getErrors(
requestParameters: GetErrorsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetErrors200Response>> {
): Promise<ApiResponse<GetErrors200Response | void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);

const response = await this.request(
@@ -36,7 +36,9 @@ export class JobsManager extends BaseAPI {
initOverrides
);

return runtime.JSONApiResponse.fromResponse(response);
return response.status === 204
? runtime.VoidApiResponse.fromResponse(response)
: runtime.JSONApiResponse.fromResponse(response);
}

/**

0 comments on commit e90012a

Please sign in to comment.