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 34e09ac0d..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]; 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,