diff --git a/src/management/__generated/managers/emails-manager.ts b/src/management/__generated/managers/emails-manager.ts index b31172386..50d998e7a 100644 --- a/src/management/__generated/managers/emails-manager.ts +++ b/src/management/__generated/managers/emails-manager.ts @@ -48,10 +48,46 @@ export class EmailsManager extends BaseAPI { } /** - * Update an email provider. - * The credentials object requires different properties depending on the email provider (which is specified using the name property): - * Depending on the type of provider it is possible to specify settings object with different configuration options, which will be used when sending an email: - * + * Update an email provider. The credentials object + * requires different properties depending on the email provider (which is specified using the name property): + * + * Depending on the type of provider it is possible to specify settings object with different configuration + * options, which will be used when sending an email: + * * * Update the email provider * @@ -79,10 +115,48 @@ export class EmailsManager extends BaseAPI { } /** - * Create an email provider. - * The credentials object requires different properties depending on the email provider (which is specified using the name property): - * Depending on the type of provider it is possible to specify settings object with different configuration options, which will be used when sending an email: - * + * Create an email provider. The credentials object + * requires different properties depending on the email provider (which is specified using the name property): + * + * Depending on the type of provider it is possible to specify settings object with different configuration + * options, which will be used when sending an email: + * * * Configure the email provider * diff --git a/src/management/__generated/models/index.ts b/src/management/__generated/models/index.ts index 398e16e64..f160b7466 100644 --- a/src/management/__generated/models/index.ts +++ b/src/management/__generated/models/index.ts @@ -3783,7 +3783,7 @@ export type DeviceCredentialCreateTypeEnum = */ export interface EmailProvider { /** - * Name of the email provider. Can be `mailgun`, `mandrill`, `sendgrid`, `ses`, `sparkpost`, `smtp`, `azure_cs`, or `ms365`. + * Name of the email provider. Can be `mailgun`, `mandrill`, `sendgrid`, `ses`, `sparkpost`, `smtp`, `azure_cs`, `ms365`, or `custom`. * */ name: string; @@ -3811,7 +3811,7 @@ export interface EmailProvider { */ export interface EmailProviderCreate { /** - * Name of the email provider. Can be `mailgun`, `mandrill`, `sendgrid`, `ses`, `sparkpost`, `smtp`, `azure_cs`, or `ms365`. + * Name of the email provider. Can be `mailgun`, `mandrill`, `sendgrid`, `ses`, `sparkpost`, `smtp`, `azure_cs`, `ms365`, or `custom`. * */ name: EmailProviderCreateNameEnum; @@ -3844,6 +3844,7 @@ export const EmailProviderCreateNameEnum = { smtp: 'smtp', azure_cs: 'azure_cs', ms365: 'ms365', + custom: 'custom', } as const; export type EmailProviderCreateNameEnum = (typeof EmailProviderCreateNameEnum)[keyof typeof EmailProviderCreateNameEnum]; @@ -3883,7 +3884,7 @@ export interface EmailProviderCredentials { */ export interface EmailProviderUpdate { /** - * Name of the email provider. Can be `mailgun`, `mandrill`, `sendgrid`, `ses`, `sparkpost`, `smtp`, `azure_cs`, or `ms365`. + * Name of the email provider. Can be `mailgun`, `mandrill`, `sendgrid`, `ses`, `sparkpost`, `smtp`, `azure_cs`, `ms365`, or `custom`. * */ name?: EmailProviderUpdateNameEnum; @@ -3916,6 +3917,7 @@ export const EmailProviderUpdateNameEnum = { smtp: 'smtp', azure_cs: 'azure_cs', ms365: 'ms365', + custom: 'custom', } as const; export type EmailProviderUpdateNameEnum = (typeof EmailProviderUpdateNameEnum)[keyof typeof EmailProviderUpdateNameEnum]; @@ -4629,7 +4631,7 @@ export interface GetActions200ResponseActionsInnerSupportedTriggersInnerCompatib version: string; } /** - * An actions extensibility point. Acceptable values: post-login, credentials-exchange, pre-user-registration, post-user-registration, post-change-password, send-phone-message, password-reset-post-challenge + * An actions extensibility point. Acceptable values: post-login, credentials-exchange, pre-user-registration, post-user-registration, post-change-password, send-phone-message, custom-email-provider, password-reset-post-challenge */ export type GetActions200ResponseActionsInnerSupportedTriggersInnerId = GetActions200ResponseActionsInnerSupportedTriggersInnerIdAnyOf; @@ -4648,6 +4650,7 @@ export const GetActions200ResponseActionsInnerSupportedTriggersInnerIdAnyOf = { iga_certification: 'iga-certification', iga_fulfillment_assignment: 'iga-fulfillment-assignment', iga_fulfillment_execution: 'iga-fulfillment-execution', + custom_email_provider: 'custom-email-provider', password_reset_post_challenge: 'password-reset-post-challenge', } as const; export type GetActions200ResponseActionsInnerSupportedTriggersInnerIdAnyOf = @@ -16404,7 +16407,7 @@ export interface GetActionsRequest { */ export interface GetBindingsRequest { /** - * An actions extensibility point. Acceptable values: post-login, credentials-exchange, pre-user-registration, post-user-registration, post-change-password, send-phone-message, password-reset-post-challenge + * An actions extensibility point. Acceptable values: post-login, credentials-exchange, pre-user-registration, post-user-registration, post-change-password, send-phone-message, custom-email-provider, password-reset-post-challenge * */ triggerId: string; @@ -16444,7 +16447,7 @@ export interface PatchActionOperationRequest { */ export interface PatchBindingsOperationRequest { /** - * An actions extensibility point. Acceptable values: post-login, credentials-exchange, pre-user-registration, post-user-registration, post-change-password, send-phone-message, password-reset-post-challenge + * An actions extensibility point. Acceptable values: post-login, credentials-exchange, pre-user-registration, post-user-registration, post-change-password, send-phone-message, custom-email-provider, password-reset-post-challenge * */ triggerId: string; diff --git a/test/management/email-provider.test.ts b/test/management/email-provider.test.ts index 3cb7cdd58..c5e19a50f 100644 --- a/test/management/email-provider.test.ts +++ b/test/management/email-provider.test.ts @@ -248,6 +248,87 @@ describe('EmailProviderManager', () => { }); }); + describe('#configure.custom', () => { + const data: PostProviderRequest = { + name: PostProviderRequestNameEnum.custom, + enabled: true, + default_from_address: 'from@test.com', + credentials: {}, + }; + const response = { + name: PostProviderRequestNameEnum.custom, + enabled: true, + default_from_address: 'from@test.com', + credentials: {}, + }; + let request: nock.Scope; + + beforeEach(() => { + request = nock(API_URL) + .post('/emails/provider', data as any) + .reply(200, response); + }); + + it('should return a promise if no callback is given', (done) => { + emails.configure(data).then(done.bind(null, null)).catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL).post('/emails/provider').reply(500, {}); + + emails.configure(data).catch((err) => { + expect(err).toBeDefined(); + + done(); + }); + }); + + it('should perform a POST request to /api/v2/emails/provider', (done) => { + emails.configure(data).then(() => { + expect(request.isDone()).toBe(true); + + done(); + }); + }); + + it('should pass the data in the body of the request', (done) => { + emails.configure(data).then(() => { + expect(request.isDone()).toBe(true); + + done(); + }); + }); + + it('should pass the body of the response to the "then" handler', (done) => { + emails.configure(data).then((provider) => { + expect(provider.data.name).toBe(response.name); + expect(provider.data.enabled).toBe(response.enabled); + expect(provider.data.default_from_address).toBe(response.default_from_address); + + expect(provider.data.credentials).toStrictEqual(response.credentials); + + done(); + }); + }); + + it('should include the token in the Authorization header', (done) => { + nock.cleanAll(); + + const request = nock(API_URL) + .post('/emails/provider') + .matchHeader('Authorization', `Bearer ${token}`) + .reply(200, response); + + emails.configure(data).then(() => { + expect(request.isDone()).toBe(true); + + done(); + }); + }); + }); + describe('#update', () => { const data: PatchProviderRequest = { name: PatchProviderRequestNameEnum.smtp,