From caa680c7ab8f68f434a22163b52316d1e5064286 Mon Sep 17 00:00:00 2001 From: Antoine SEIN <142824551+asein-sinch@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:33:22 +0100 Subject: [PATCH] Update function name purgeSendingQueue --- .../{purgeDomainQueues.ts => purgeSendingQueue.ts} | 10 +++++----- .../src/rest/v1/emails/emails-api.jest.fixture.ts | 4 ++-- packages/mailgun/src/rest/v1/emails/emails-api.ts | 4 ++-- .../mailgun/tests/rest/v1/emails/emails-api.test.ts | 12 ++++++------ .../mailgun/tests/rest/v1/emails/emails.steps.ts | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) rename examples/simple-examples/src/mailgun/emails/{purgeDomainQueues.ts => purgeSendingQueue.ts} (51%) diff --git a/examples/simple-examples/src/mailgun/emails/purgeDomainQueues.ts b/examples/simple-examples/src/mailgun/emails/purgeSendingQueue.ts similarity index 51% rename from examples/simple-examples/src/mailgun/emails/purgeDomainQueues.ts rename to examples/simple-examples/src/mailgun/emails/purgeSendingQueue.ts index 32fc15f..4f42afb 100644 --- a/examples/simple-examples/src/mailgun/emails/purgeDomainQueues.ts +++ b/examples/simple-examples/src/mailgun/emails/purgeSendingQueue.ts @@ -1,18 +1,18 @@ import { getMailgunDomainFromConfig, initMailgunService, printFullResponse } from '../../config'; (async () => { - console.log('********************'); - console.log('* PurgeDomainQueue *'); - console.log('********************'); + console.log('*********************'); + console.log('* PurgeSendingQueue *'); + console.log('*********************'); const domainName = getMailgunDomainFromConfig(); const mailgunService = initMailgunService(); let response; try { - response = await mailgunService.emails.purgeDomainQueue(domainName, 'https://storage-us-west1.api.mailgun.net'); + response = await mailgunService.emails.purgeSendingQueue(domainName, 'https://storage-us-west1.api.mailgun.net'); } catch (error) { - console.error('Error when trying to purge the domain queue'); + console.error('Error when trying to purge the sending queue'); throw error; } diff --git a/packages/mailgun/src/rest/v1/emails/emails-api.jest.fixture.ts b/packages/mailgun/src/rest/v1/emails/emails-api.jest.fixture.ts index d005751..e9ea198 100644 --- a/packages/mailgun/src/rest/v1/emails/emails-api.jest.fixture.ts +++ b/packages/mailgun/src/rest/v1/emails/emails-api.jest.fixture.ts @@ -23,9 +23,9 @@ export class EmailsApiFixture implements Partial> { */ public getStoredEmail: jest.Mock, [string, string]> = jest.fn(); /** - * Fixture associated to function purgeDomainQueue + * Fixture associated to function purgeSendingQueue */ - public purgeDomainQueue: jest.Mock, [string, MailgunStorageHostname]> = jest.fn(); + public purgeSendingQueue: jest.Mock, [string, MailgunStorageHostname]> = jest.fn(); /** * Fixture associated to function getSendingQueuesStatus */ diff --git a/packages/mailgun/src/rest/v1/emails/emails-api.ts b/packages/mailgun/src/rest/v1/emails/emails-api.ts index 29925c9..51f5dee 100644 --- a/packages/mailgun/src/rest/v1/emails/emails-api.ts +++ b/packages/mailgun/src/rest/v1/emails/emails-api.ts @@ -130,7 +130,7 @@ export class EmailsApi extends MailgunDomainApi { * @param { string } domainName - The name of the domain you want to delete envelope from * @param { MailgunStorageHostname } storageHostname - The storage hostname to be purged */ - public async purgeDomainQueue( + public async purgeSendingQueue( domainName: string, storageHostname: MailgunStorageHostname, ): Promise { @@ -156,7 +156,7 @@ export class EmailsApi extends MailgunDomainApi { url, requestOptions, apiName: this.apiName, - operationId: 'purgeDomainQueue', + operationId: 'purgeSendingQueue', }); return transformGenericResponseIntoClientResponse(apiResponse); diff --git a/packages/mailgun/tests/rest/v1/emails/emails-api.test.ts b/packages/mailgun/tests/rest/v1/emails/emails-api.test.ts index 17effe8..95fb6eb 100644 --- a/packages/mailgun/tests/rest/v1/emails/emails-api.test.ts +++ b/packages/mailgun/tests/rest/v1/emails/emails-api.test.ts @@ -73,20 +73,20 @@ describe('EmailsApi', () => { }); }); - describe('purgeDomainQueues', () => { - it('should make a DELETE request to purge the domain queues', async () => { + describe('purgeSendingQueue', () => { + it('should make a DELETE request to purge a sending queue', async () => { // Given const domainName: string = 'domainName'; const storageHostname: MailgunStorageHostname = 'storageHostname'; // When - fixture.purgeDomainQueue.mockResolvedValue(genericResponse); - emailsApi.purgeDomainQueue = fixture.purgeDomainQueue; - const response = await emailsApi.purgeDomainQueue(domainName, storageHostname); + fixture.purgeSendingQueue.mockResolvedValue(genericResponse); + emailsApi.purgeSendingQueue = fixture.purgeSendingQueue; + const response = await emailsApi.purgeSendingQueue(domainName, storageHostname); // Then expect(response).toEqual(genericResponse); - expect(fixture.purgeDomainQueue).toHaveBeenCalledWith(domainName, storageHostname); + expect(fixture.purgeSendingQueue).toHaveBeenCalledWith(domainName, storageHostname); }); }); diff --git a/packages/mailgun/tests/rest/v1/emails/emails.steps.ts b/packages/mailgun/tests/rest/v1/emails/emails.steps.ts index a5e8d94..16d543f 100644 --- a/packages/mailgun/tests/rest/v1/emails/emails.steps.ts +++ b/packages/mailgun/tests/rest/v1/emails/emails.steps.ts @@ -7,7 +7,7 @@ let sendEmailResponse: Mailgun.SendEmailResponse; let sendMimeEmailResponse: Mailgun.SendEmailResponse; let getEmailResponse: Mailgun.GetStoredEmailResponse; let sendingQueuesStatusResponse: Mailgun.SendingQueuesStatusResponse; -let purgeDomainQueuesResponse: Mailgun.GenericResponse; +let purgeSendingQueueResponse: Mailgun.GenericResponse; const domainName = 'sandbox123.mailgun.org'; Given('the Mailgun service "Emails" is available', () => { @@ -106,10 +106,10 @@ Then('the response contains the sending queues status', () => { assert.equal(sendingQueuesStatusResponse.scheduled.disabled?.reason, ''); }); -When('I send a request to purge the domain queues', async () => { - purgeDomainQueuesResponse = await emailsApi.purgeDomainQueue(domainName, 'http://localhost:3021'); +When('I send a request to purge a sending queue', async () => { + purgeSendingQueueResponse = await emailsApi.purgeSendingQueue(domainName, 'http://localhost:3021'); }); Then('the response indicates the purge has been done', () => { - assert.equal(purgeDomainQueuesResponse.message, 'done'); + assert.equal(purgeSendingQueueResponse.message, 'done'); });