Skip to content

Commit

Permalink
Merge branch 'beta' into fetch-opts
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjmcgrath authored Sep 6, 2023
2 parents 460c5a3 + b27009e commit ce04ca2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 30 deletions.
29 changes: 19 additions & 10 deletions src/management/__generated/managers/clients-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ export class ClientsManager extends BaseAPI {
requestParameters: DeleteClientsByIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<void>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
runtime.validateRequiredRequestParams(requestParameters, ['client_id']);

const response = await this.request(
{
path: `/clients/{id}`.replace('{id}', encodeURIComponent(String(requestParameters.id))),
path: `/clients/{client_id}`.replace(
'{client_id}',
encodeURIComponent(String(requestParameters.client_id))
),
method: 'DELETE',
},
initOverrides
Expand Down Expand Up @@ -194,7 +197,7 @@ export class ClientsManager extends BaseAPI {
requestParameters: GetClientsByIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Client>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
runtime.validateRequiredRequestParams(requestParameters, ['client_id']);

const queryParameters = runtime.applyQueryParams(requestParameters, [
{
Expand All @@ -209,7 +212,10 @@ export class ClientsManager extends BaseAPI {

const response = await this.request(
{
path: `/clients/{id}`.replace('{id}', encodeURIComponent(String(requestParameters.id))),
path: `/clients/{client_id}`.replace(
'{client_id}',
encodeURIComponent(String(requestParameters.client_id))
),
method: 'GET',
query: queryParameters,
},
Expand Down Expand Up @@ -291,15 +297,18 @@ export class ClientsManager extends BaseAPI {
bodyParameters: ClientUpdate,
initOverrides?: InitOverride
): Promise<ApiResponse<Client>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
runtime.validateRequiredRequestParams(requestParameters, ['client_id']);

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

const response = await this.request(
{
path: `/clients/{id}`.replace('{id}', encodeURIComponent(String(requestParameters.id))),
path: `/clients/{client_id}`.replace(
'{client_id}',
encodeURIComponent(String(requestParameters.client_id))
),
method: 'PATCH',
headers: headerParameters,
body: bodyParameters,
Expand Down Expand Up @@ -429,13 +438,13 @@ export class ClientsManager extends BaseAPI {
requestParameters: PostRotateSecretRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Client>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);
runtime.validateRequiredRequestParams(requestParameters, ['client_id']);

const response = await this.request(
{
path: `/clients/{id}/rotate-secret`.replace(
'{id}',
encodeURIComponent(String(requestParameters.id))
path: `/clients/{client_id}/rotate-secret`.replace(
'{client_id}',
encodeURIComponent(String(requestParameters.client_id))
),
method: 'POST',
},
Expand Down
14 changes: 7 additions & 7 deletions src/management/__generated/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export interface Client {
* Metadata associated with the client, in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. Field names (max 255 chars) are alphanumeric and may only include the following special characters: :,-+=_*?"/\()<>@ [Tab] [Space]
*
*/
client_metadata: object;
client_metadata: { [key: string]: any };
/**
*/
mobile: ClientMobile;
Expand Down Expand Up @@ -982,7 +982,7 @@ export interface ClientCreate {
* Metadata associated with the client, in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. Field names (max 255 chars) are alphanumeric and may only include the following special characters: :,-+=_*?"/\()<>@ [Tab] [Space]
*
*/
client_metadata?: object;
client_metadata?: { [key: string]: any };
/**
*/
mobile?: ClientCreateMobile;
Expand Down Expand Up @@ -2207,7 +2207,7 @@ export interface ClientUpdate {
* Metadata associated with the client, in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. Field names (max 255 chars) are alphanumeric and may only include the following special characters: :,-+=_*?"/\()<>@ [Tab] [Space]
*
*/
client_metadata?: object;
client_metadata?: { [key: string]: any };
/**
*/
mobile?: ClientUpdateMobile | null;
Expand Down Expand Up @@ -12244,7 +12244,7 @@ export interface DeleteClientsByIdRequest {
* ID of the client to delete.
*
*/
id: string;
client_id: string;
}
/**
*
Expand Down Expand Up @@ -12314,7 +12314,7 @@ export interface GetClientsByIdRequest {
* ID of the client to retrieve.
*
*/
id: string;
client_id: string;
/**
* Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields.
*
Expand Down Expand Up @@ -12359,7 +12359,7 @@ export interface PatchClientsByIdRequest {
* ID of the client to update.
*
*/
id: string;
client_id: string;
}
/**
*
Expand Down Expand Up @@ -12394,7 +12394,7 @@ export interface PostRotateSecretRequest {
* ID of the client that will rotate secrets.
*
*/
id: string;
client_id: string;
}
/**
*
Expand Down
26 changes: 13 additions & 13 deletions test/management/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,21 @@ describe('ClientsManager', () => {

it('should return a promise if no callback is given', (done) => {
clients
.get({ id: response.client_id as string })
.get({ client_id: response.client_id as string })
.then(done.bind(null, null))
.catch(done.bind(null, null));
});

it('should perform a POST request to /api/v2/clients/5', (done) => {
clients.get({ id: response.client_id as string }).then(() => {
clients.get({ client_id: response.client_id as string }).then(() => {
expect(request.isDone()).toBe(true);

done();
});
});

it('should pass the body of the response to the "then" handler', (done) => {
clients.get({ id: response.client_id as string }).then((client) => {
clients.get({ client_id: response.client_id as string }).then((client) => {
expect(client.data.client_id).toBe(response.client_id);
expect(client.data.name).toBe(response.name);
expect(client.data.description).toBe(response.description);
Expand Down Expand Up @@ -305,13 +305,13 @@ describe('ClientsManager', () => {

it('should return a promise if no callback is given', (done) => {
clients
.update({ id: response.client_id as string }, {})
.update({ client_id: response.client_id as string }, {})
.then(done.bind(null, null))
.catch(done.bind(null, null));
});

it('should perform a PATCH request to /api/v2/clients/5', (done) => {
clients.update({ id: response.client_id as string }, {}).then(() => {
clients.update({ client_id: response.client_id as string }, {}).then(() => {
expect(request.isDone()).toBe(true);

done();
Expand All @@ -325,15 +325,15 @@ describe('ClientsManager', () => {
.patch(`/clients/${response.client_id as string}`, data as any)
.reply(200, response);

clients.update({ id: response.client_id as string }, data as any).then(() => {
clients.update({ client_id: response.client_id as string }, data as any).then(() => {
expect(request.isDone()).toBe(true);

done();
});
});

it('should pass the body of the response to the "then" handler', (done) => {
clients.update({ id: response.client_id as string }, data as any).then((client) => {
clients.update({ client_id: response.client_id as string }, data as any).then((client) => {
expect(client.data.client_id).toBe(response.client_id);
expect(client.data.name).toBe(response.name);
expect(client.data.description).toBe(response.description);
Expand All @@ -356,11 +356,11 @@ describe('ClientsManager', () => {
});

it('should return a promise when no callback is given', (done) => {
clients.delete({ id }).then(done.bind(null, null));
clients.delete({ client_id: id }).then(done.bind(null, null));
});

it(`should perform a DELETE request to /clients/${id}`, (done) => {
clients.delete({ id }).then(() => {
clients.delete({ client_id: id }).then(() => {
expect(request.isDone()).toBe(true);

done();
Expand All @@ -378,13 +378,13 @@ describe('ClientsManager', () => {

it('should return a promise if no callback is given', (done) => {
clients
.rotateClientSecret({ id }, {})
.rotateClientSecret({ client_id: id }, {})
.then(done.bind(null, null))
.catch(done.bind(null, null));
});

it('should perform a POST request to /api/v2/clients/5/rotate-secret', (done) => {
clients.rotateClientSecret({ id }).then(() => {
clients.rotateClientSecret({ client_id: id }).then(() => {
expect(request.isDone()).toBe(true);

done();
Expand All @@ -402,7 +402,7 @@ describe('ClientsManager', () => {
.post(`/clients/${id}/rotate-secret`)
.reply(200, { client_id: '123' });

clients.rotateClientSecret({ id }).then(() => {
clients.rotateClientSecret({ client_id: id }).then(() => {
expect(request.isDone()).toBe(true);

done();
Expand All @@ -414,7 +414,7 @@ describe('ClientsManager', () => {

nock(API_URL).post(`/clients/${id}/rotate-secret`).reply(500, {});

clients.rotateClientSecret({ id }).catch((err) => {
clients.rotateClientSecret({ client_id: id }).catch((err) => {
expect(err).toBeDefined();

done();
Expand Down

0 comments on commit ce04ca2

Please sign in to comment.