From e522331cbabb1d94b19bec3db644cc57f88d3f5e Mon Sep 17 00:00:00 2001 From: Antoine SEIN <142824551+asein-sinch@users.noreply.github.com> Date: Sun, 15 Dec 2024 22:41:40 +0100 Subject: [PATCH] Fix comments --- .../src/models/v1/emails/request/helper.ts | 2 +- .../request/override-properties/index.ts | 1 - .../override-properties.transform.ts | 57 +++++++++++++++++++ .../override-properties.ts | 52 ----------------- .../request/send-email-request/index.ts | 1 - .../send-email-request.transform.ts | 55 ++++++++++++++++++ .../send-email-request/send-email-request.ts | 55 ++---------------- .../request/send-mime-email-request/index.ts | 1 - .../send-mime-email-request.transform.ts | 31 ++++++++++ .../send-mime-email-request.ts | 27 +-------- .../request/template-properties/index.ts | 1 - .../template-properties.transform.ts | 18 ++++++ .../template-properties.ts | 12 ---- .../bad-request/bad-request.transform.ts | 14 +++++ .../response/bad-request/bad-request.ts | 9 --- .../v1/emails/response/bad-request/index.ts | 9 +-- .../email-not-found.transform.ts | 14 +++++ .../email-not-found/email-not-found.ts | 9 --- .../emails/response/email-not-found/index.ts | 8 +-- .../exceeded-queue-quota.transform.ts | 17 ++++++ .../exceeded-queue-quota.ts | 16 +----- .../response/exceeded-queue-quota/index.ts | 8 +-- .../generic-response.transform.ts | 14 +++++ .../generic-response/generic-response.ts | 9 --- .../emails/response/generic-response/index.ts | 8 +-- .../get-stored-email-response.transform.ts | 34 +++++++++++ .../get-stored-email-response.ts | 24 -------- .../response/get-email-response/index.ts | 10 +--- .../queue-status-disabled-details/index.ts | 8 +-- ...queue-status-disabled-details.transform.ts | 14 +++++ .../queue-status-disabled-details.ts | 9 --- .../response/send-email-response/index.ts | 8 +-- .../send-email-response.transform.ts | 14 +++++ .../send-email-response.ts | 9 --- .../sending-queues-status-response/index.ts | 8 +-- ...ending-queues-status-response.transform.ts | 15 +++++ .../sending-queues-status-response.ts | 12 +--- packages/mailgun/src/models/v1/index.ts | 24 ++++---- .../mailgun/src/rest/v1/emails/emails-api.ts | 36 +++++++++--- .../models/v1/emails/request/helper.test.ts | 2 +- .../request/send-email-request.models.ts | 4 +- .../emails/request/send-email-request.test.ts | 4 +- .../request/send-mime-email-request.test.ts | 4 +- .../v1/emails/response/bad-request.models.ts | 3 +- .../v1/emails/response/bad-request.test.ts | 4 +- .../emails/response/email-not-found.models.ts | 3 +- .../emails/response/email-not-found.test.ts | 4 +- .../response/generic-response.models.ts | 3 +- .../emails/response/generic-response.test.ts | 4 +- .../get-stored-email-response.models.ts | 3 +- .../get-stored-email-response.test.ts | 4 +- .../response/send-email-response.models.ts | 3 +- .../response/send-email-response.test.ts | 6 +- .../sending-queues-status-response.models.ts | 5 +- .../sending-queues-status-response.test.ts | 7 ++- 55 files changed, 390 insertions(+), 346 deletions(-) create mode 100644 packages/mailgun/src/models/v1/emails/request/override-properties/override-properties.transform.ts create mode 100644 packages/mailgun/src/models/v1/emails/request/send-email-request/send-email-request.transform.ts create mode 100644 packages/mailgun/src/models/v1/emails/request/send-mime-email-request/send-mime-email-request.transform.ts create mode 100644 packages/mailgun/src/models/v1/emails/request/template-properties/template-properties.transform.ts create mode 100644 packages/mailgun/src/models/v1/emails/response/bad-request/bad-request.transform.ts create mode 100644 packages/mailgun/src/models/v1/emails/response/email-not-found/email-not-found.transform.ts create mode 100644 packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/exceeded-queue-quota.transform.ts create mode 100644 packages/mailgun/src/models/v1/emails/response/generic-response/generic-response.transform.ts create mode 100644 packages/mailgun/src/models/v1/emails/response/get-email-response/get-stored-email-response.transform.ts create mode 100644 packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/queue-status-disabled-details.transform.ts create mode 100644 packages/mailgun/src/models/v1/emails/response/send-email-response/send-email-response.transform.ts create mode 100644 packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/sending-queues-status-response.transform.ts diff --git a/packages/mailgun/src/models/v1/emails/request/helper.ts b/packages/mailgun/src/models/v1/emails/request/helper.ts index f02fc5a0..4bd19943 100644 --- a/packages/mailgun/src/models/v1/emails/request/helper.ts +++ b/packages/mailgun/src/models/v1/emails/request/helper.ts @@ -8,7 +8,7 @@ export const appendFilteredPropertiesToFormData = ( for (const [key, value] of Object.entries(obj)) { if (key.startsWith(prefix) && value != null) { if (value instanceof Date) { - formData.append(key, value.toISOString()); + formData.append(key, value.toUTCString()); } else { formData.append(key, String(value)); } diff --git a/packages/mailgun/src/models/v1/emails/request/override-properties/index.ts b/packages/mailgun/src/models/v1/emails/request/override-properties/index.ts index 3e79b29b..94d31285 100644 --- a/packages/mailgun/src/models/v1/emails/request/override-properties/index.ts +++ b/packages/mailgun/src/models/v1/emails/request/override-properties/index.ts @@ -1,2 +1 @@ export type { OverrideProperties } from './override-properties'; -export { appendOverridePropertiesToFormData } from './override-properties'; diff --git a/packages/mailgun/src/models/v1/emails/request/override-properties/override-properties.transform.ts b/packages/mailgun/src/models/v1/emails/request/override-properties/override-properties.transform.ts new file mode 100644 index 00000000..6212153c --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/request/override-properties/override-properties.transform.ts @@ -0,0 +1,57 @@ +import { OverrideProperties } from './override-properties'; +import FormData = require('form-data'); + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const appendOverridePropertiesToFormData = (overrideProperties: OverrideProperties, formData: FormData) => { + if (overrideProperties['tag'] != null) { + formData.append('o:tag', overrideProperties['tag']); + } + if (overrideProperties['deliveryTimeOptimizePeriod'] != null) { + formData.append('o:deliverytime-optimize-period', `${overrideProperties['deliveryTimeOptimizePeriod']}h`); + } + if (overrideProperties['enableDkimSignature'] != null) { + formData.append('o:dkim', String(overrideProperties['enableDkimSignature'])); + } + if (overrideProperties['secondaryDkim'] != null) { + formData.append('o:secondary-dkim', overrideProperties['secondaryDkim']); + } + if (overrideProperties['secondaryDkimPublic'] != null) { + formData.append('o:secondary-dkim-public', overrideProperties['secondaryDkimPublic']); + } + if (overrideProperties['deliveryTime'] != null) { + formData.append('o:deliverytime', overrideProperties['deliveryTime']); + } + if (overrideProperties['timeZoneLocalize'] != null) { + formData.append('o:time-zone-localize', overrideProperties['timeZoneLocalize']); + } + if (overrideProperties['tracking'] != null) { + formData.append('o:tracking', String(overrideProperties['tracking'])); + } + if (overrideProperties['trackingClicks'] != null) { + formData.append('o:tracking-clicks', String(overrideProperties['trackingClicks'])); + } + if (overrideProperties['trackingOpens'] != null) { + formData.append('o:tracking-opens', String(overrideProperties['trackingOpens'])); + } + if (overrideProperties['trackingPixelLocationTop'] != null) { + formData.append('o:tracking-pixel-location-top', String(overrideProperties['trackingPixelLocationTop'])); + } + if (overrideProperties['sendingIp'] != null) { + formData.append('o:sending-ip', overrideProperties['sendingIp']); + } + if (overrideProperties['sendingIpPool'] != null) { + formData.append('o:sending-ip-pool', overrideProperties['sendingIpPool']); + } + if (overrideProperties['requireTls'] != null) { + formData.append('o:require-tls', String(overrideProperties['requireTls'])); + } + if (overrideProperties['skipVerification'] != null) { + formData.append('o:skip-verification', String(overrideProperties['skipVerification'])); + } + if (overrideProperties['isTestMode'] != null) { + formData.append('o:testmode', String(overrideProperties['isTestMode'])); + } +}; diff --git a/packages/mailgun/src/models/v1/emails/request/override-properties/override-properties.ts b/packages/mailgun/src/models/v1/emails/request/override-properties/override-properties.ts index c3c0f5c1..43a5d489 100644 --- a/packages/mailgun/src/models/v1/emails/request/override-properties/override-properties.ts +++ b/packages/mailgun/src/models/v1/emails/request/override-properties/override-properties.ts @@ -1,5 +1,4 @@ import { YesNoEnum, YesNoHtmlonlyEnum } from '../enum'; -import FormData = require('form-data'); export interface OverrideProperties { /** Tag string. See **Tagging** for more information */ @@ -35,54 +34,3 @@ export interface OverrideProperties { /** Enables sending in test mode. Pass `yes` if needed. See **Sending in Test Mode** */ isTestMode?: YesNoEnum; } - -export const appendOverridePropertiesToFormData = (overrideProperties: OverrideProperties, formData: FormData) => { - if (overrideProperties['tag'] != null) { - formData.append('o:tag', overrideProperties['tag']); - } - if (overrideProperties['deliveryTimeOptimizePeriod'] != null) { - formData.append('o:deliverytime-optimize-period', `${overrideProperties['deliveryTimeOptimizePeriod']}h`); - } - if (overrideProperties['enableDkimSignature'] != null) { - formData.append('o:dkim', String(overrideProperties['enableDkimSignature'])); - } - if (overrideProperties['secondaryDkim'] != null) { - formData.append('o:secondary-dkim', overrideProperties['secondaryDkim']); - } - if (overrideProperties['secondaryDkimPublic'] != null) { - formData.append('o:secondary-dkim-public', overrideProperties['secondaryDkimPublic']); - } - if (overrideProperties['deliveryTime'] != null) { - formData.append('o:deliverytime', overrideProperties['deliveryTime']); - } - if (overrideProperties['timeZoneLocalize'] != null) { - formData.append('o:time-zone-localize', overrideProperties['timeZoneLocalize']); - } - if (overrideProperties['tracking'] != null) { - formData.append('o:tracking', String(overrideProperties['tracking'])); - } - if (overrideProperties['trackingClicks'] != null) { - formData.append('o:tracking-clicks', String(overrideProperties['trackingClicks'])); - } - if (overrideProperties['trackingOpens'] != null) { - formData.append('o:tracking-opens', String(overrideProperties['trackingOpens'])); - } - if (overrideProperties['trackingPixelLocationTop'] != null) { - formData.append('o:tracking-pixel-location-top', String(overrideProperties['trackingPixelLocationTop'])); - } - if (overrideProperties['sendingIp'] != null) { - formData.append('o:sending-ip', overrideProperties['sendingIp']); - } - if (overrideProperties['sendingIpPool'] != null) { - formData.append('o:sending-ip-pool', overrideProperties['sendingIpPool']); - } - if (overrideProperties['requireTls'] != null) { - formData.append('o:require-tls', String(overrideProperties['requireTls'])); - } - if (overrideProperties['skipVerification'] != null) { - formData.append('o:skip-verification', String(overrideProperties['skipVerification'])); - } - if (overrideProperties['isTestMode'] != null) { - formData.append('o:testmode', String(overrideProperties['isTestMode'])); - } -}; diff --git a/packages/mailgun/src/models/v1/emails/request/send-email-request/index.ts b/packages/mailgun/src/models/v1/emails/request/send-email-request/index.ts index ba662c40..cf7e8c76 100644 --- a/packages/mailgun/src/models/v1/emails/request/send-email-request/index.ts +++ b/packages/mailgun/src/models/v1/emails/request/send-email-request/index.ts @@ -1,2 +1 @@ export type { SendEmailRequest } from './send-email-request'; -export { transformSendEmailRequestIntoApiRequestBody } from './send-email-request'; diff --git a/packages/mailgun/src/models/v1/emails/request/send-email-request/send-email-request.transform.ts b/packages/mailgun/src/models/v1/emails/request/send-email-request/send-email-request.transform.ts new file mode 100644 index 00000000..6e019539 --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/request/send-email-request/send-email-request.transform.ts @@ -0,0 +1,55 @@ +import { appendOverridePropertiesToFormData } from '../override-properties/override-properties.transform'; +import { appendTemplatePropertiesToFormData } from '../template-properties/template-properties.transform'; +import { appendFilteredPropertiesToFormData } from '../helper'; +import { SendEmailRequest } from './send-email-request'; +import FormData = require('form-data'); + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const transformSendEmailRequestIntoApiRequestBody = (sdkRequest: SendEmailRequest): FormData => { + const formData = new FormData(); + if (sdkRequest.html != null) { + formData.append('html', sdkRequest.html); + } + if (sdkRequest.ampHtml != null) { + formData.append('amp-html', sdkRequest['ampHtml']); + } + if (sdkRequest.text!= null) { + formData.append('text', sdkRequest.text); + } + if (sdkRequest.to != null) { + formData.append('to', sdkRequest.to); + } + if (sdkRequest.from != null) { + formData.append('from', sdkRequest.from); + } + if (sdkRequest.cc != null) { + formData.append('cc', sdkRequest.cc); + } + if (sdkRequest.bcc != null) { + formData.append('bcc', sdkRequest.bcc); + } + if (sdkRequest.subject != null) { + formData.append('subject', sdkRequest.subject); + } + if (sdkRequest.attachment != null) { + formData.append('attachment', sdkRequest.attachment); + } + if (sdkRequest.inline != null) { + formData.append('inline', sdkRequest.inline); + } + if (sdkRequest.overrideProperties != null) { + appendOverridePropertiesToFormData(sdkRequest.overrideProperties, formData); + } + if (sdkRequest.template != null) { + formData.append('template', sdkRequest.template); + } + if (sdkRequest.templateProperties != null) { + appendTemplatePropertiesToFormData(sdkRequest.templateProperties, formData); + } + appendFilteredPropertiesToFormData(sdkRequest, 'h:', formData); + appendFilteredPropertiesToFormData(sdkRequest, 'v:', formData); + return formData; +}; diff --git a/packages/mailgun/src/models/v1/emails/request/send-email-request/send-email-request.ts b/packages/mailgun/src/models/v1/emails/request/send-email-request/send-email-request.ts index fccb534a..0afcbe4c 100644 --- a/packages/mailgun/src/models/v1/emails/request/send-email-request/send-email-request.ts +++ b/packages/mailgun/src/models/v1/emails/request/send-email-request/send-email-request.ts @@ -1,7 +1,6 @@ -import { appendTemplatePropertiesToFormData, TemplateProperties } from '../template-properties'; -import { appendOverridePropertiesToFormData, OverrideProperties } from '../override-properties'; -import { appendFilteredPropertiesToFormData } from '../helper'; -import FormData = require('form-data'); +import { TemplateProperties } from '../template-properties'; +import { OverrideProperties } from '../override-properties'; + export type MessageContentWithHtmlInline = { /** Body of the message (HTML version) */ @@ -35,7 +34,7 @@ export interface CommonEmailProperties { /** Body of the message (text version) */ text?: string; /** AMP part of the message. Please follow Google guidelines to compose and send AMP emails */ - amp_html?: string; + ampHtml?: string; /** File attachment. You can post multiple `attachment` values. **Important:** You must use `multipart/form-data` encoding for sending attachments */ attachment?: string; /** Attachment with `inline` disposition. Can be used to send inline images (see example). You can post multiple `inline` values */ @@ -50,49 +49,3 @@ export interface CommonEmailProperties { export type SendEmailRequest = MessageContentWithHtmlInline | MessageContentWithHtmlInTemplate; - -export const transformSendEmailRequestIntoApiRequestBody = (sdkRequest: SendEmailRequest): FormData => { - const formData = new FormData(); - if (sdkRequest['html'] != null) { - formData.append('html', sdkRequest['html']); - } - if (sdkRequest['amp_html'] != null) { - formData.append('amp-html', sdkRequest['amp_html']); - } - if (sdkRequest['text'] != null) { - formData.append('text', sdkRequest['text']); - } - if (sdkRequest['to'] != null) { - formData.append('to', sdkRequest['to']); - } - if (sdkRequest['from'] != null) { - formData.append('from', sdkRequest['from']); - } - if (sdkRequest['cc'] != null) { - formData.append('cc', sdkRequest['cc']); - } - if (sdkRequest['bcc'] != null) { - formData.append('bcc', sdkRequest['bcc']); - } - if (sdkRequest['subject'] != null) { - formData.append('subject', sdkRequest['subject']); - } - if (sdkRequest['attachment'] != null) { - formData.append('attachment', sdkRequest['attachment']); - } - if (sdkRequest['inline'] != null) { - formData.append('inline', sdkRequest['inline']); - } - if (sdkRequest.overrideProperties != null) { - appendOverridePropertiesToFormData(sdkRequest.overrideProperties, formData); - } - if (sdkRequest['template'] != null) { - formData.append('template', sdkRequest['template']); - } - if (sdkRequest.templateProperties != null) { - appendTemplatePropertiesToFormData(sdkRequest.templateProperties, formData); - } - appendFilteredPropertiesToFormData(sdkRequest, 'h:', formData); - appendFilteredPropertiesToFormData(sdkRequest, 'v:', formData); - return formData; -}; diff --git a/packages/mailgun/src/models/v1/emails/request/send-mime-email-request/index.ts b/packages/mailgun/src/models/v1/emails/request/send-mime-email-request/index.ts index 309f8231..22f54c29 100644 --- a/packages/mailgun/src/models/v1/emails/request/send-mime-email-request/index.ts +++ b/packages/mailgun/src/models/v1/emails/request/send-mime-email-request/index.ts @@ -1,2 +1 @@ export type { SendMimeEmailRequest } from './send-mime-email-request'; -export { transformSendMimeEmailRequestIntoApiRequestBody } from './send-mime-email-request'; diff --git a/packages/mailgun/src/models/v1/emails/request/send-mime-email-request/send-mime-email-request.transform.ts b/packages/mailgun/src/models/v1/emails/request/send-mime-email-request/send-mime-email-request.transform.ts new file mode 100644 index 00000000..0612e4dd --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/request/send-mime-email-request/send-mime-email-request.transform.ts @@ -0,0 +1,31 @@ +import { appendTemplatePropertiesToFormData } from '../template-properties/template-properties.transform'; +import { appendOverridePropertiesToFormData } from '../override-properties/override-properties.transform'; +import { appendFilteredPropertiesToFormData } from '../helper'; +import { SendMimeEmailRequest } from './send-mime-email-request'; +import FormData = require('form-data'); + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const transformSendMimeEmailRequestIntoApiRequestBody = (sdkRequest: SendMimeEmailRequest): FormData => { + const formData = new FormData(); + if (sdkRequest.to != null) { + formData.append('to', sdkRequest.to); + } + if (sdkRequest.message != null) { + formData.append('message', sdkRequest.message, { filename: 'MimeMessage' }); + } + if (sdkRequest.template != null) { + formData.append('template', sdkRequest['template']); + } + if (sdkRequest.templateProperties != null) { + appendTemplatePropertiesToFormData(sdkRequest.templateProperties, formData); + } + if (sdkRequest.overrideProperties != null) { + appendOverridePropertiesToFormData(sdkRequest.overrideProperties, formData); + } + appendFilteredPropertiesToFormData(sdkRequest, 'h:', formData); + appendFilteredPropertiesToFormData(sdkRequest, 'v:', formData); + return formData; +}; diff --git a/packages/mailgun/src/models/v1/emails/request/send-mime-email-request/send-mime-email-request.ts b/packages/mailgun/src/models/v1/emails/request/send-mime-email-request/send-mime-email-request.ts index 241b3c53..3abe9090 100644 --- a/packages/mailgun/src/models/v1/emails/request/send-mime-email-request/send-mime-email-request.ts +++ b/packages/mailgun/src/models/v1/emails/request/send-mime-email-request/send-mime-email-request.ts @@ -1,7 +1,5 @@ -import { appendTemplatePropertiesToFormData, TemplateProperties } from '../template-properties'; -import { appendOverridePropertiesToFormData, OverrideProperties } from '../override-properties'; -import { appendFilteredPropertiesToFormData } from '../helper'; -import FormData = require('form-data'); +import { TemplateProperties } from '../template-properties'; +import { OverrideProperties } from '../override-properties'; export interface SendMimeEmailRequest { /** MIME string of the message. Make sure to use `multipart/form-data` content type to send this as a file upload */ @@ -22,24 +20,3 @@ export interface SendMimeEmailRequest { [key: `v:${string}`]: string | number; } -export const transformSendMimeEmailRequestIntoApiRequestBody = (sdkRequest: SendMimeEmailRequest): FormData => { - const formData = new FormData(); - if (sdkRequest['to'] != null) { - formData.append('to', sdkRequest['to']); - } - if ('message' in sdkRequest && sdkRequest['message'] != null) { - formData.append('message', sdkRequest['message'], { filename: 'MimeMessage' }); - } - if ('template' in sdkRequest && sdkRequest['template'] != null) { - formData.append('template', sdkRequest['template']); - } - if (sdkRequest.templateProperties != null) { - appendTemplatePropertiesToFormData(sdkRequest.templateProperties, formData); - } - if (sdkRequest.overrideProperties != null) { - appendOverridePropertiesToFormData(sdkRequest.overrideProperties, formData); - } - appendFilteredPropertiesToFormData(sdkRequest, 'h:', formData); - appendFilteredPropertiesToFormData(sdkRequest, 'v:', formData); - return formData; -}; diff --git a/packages/mailgun/src/models/v1/emails/request/template-properties/index.ts b/packages/mailgun/src/models/v1/emails/request/template-properties/index.ts index 35c01cc2..8e761a97 100644 --- a/packages/mailgun/src/models/v1/emails/request/template-properties/index.ts +++ b/packages/mailgun/src/models/v1/emails/request/template-properties/index.ts @@ -1,2 +1 @@ export type { TemplateProperties } from './template-properties'; -export { appendTemplatePropertiesToFormData } from './template-properties'; diff --git a/packages/mailgun/src/models/v1/emails/request/template-properties/template-properties.transform.ts b/packages/mailgun/src/models/v1/emails/request/template-properties/template-properties.transform.ts new file mode 100644 index 00000000..de95bf12 --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/request/template-properties/template-properties.transform.ts @@ -0,0 +1,18 @@ +import { TemplateProperties } from './template-properties'; +import FormData = require('form-data'); + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const appendTemplatePropertiesToFormData = (templateProperties: TemplateProperties, formData: FormData) => { + if (templateProperties['text'] != null) { + formData.append('t:text', String(templateProperties['text'])); + } + if (templateProperties['version'] != null) { + formData.append('t:version', templateProperties['version']); + } + if (templateProperties['variables'] != null) { + formData.append('t:variables', templateProperties['variables']); + } +}; diff --git a/packages/mailgun/src/models/v1/emails/request/template-properties/template-properties.ts b/packages/mailgun/src/models/v1/emails/request/template-properties/template-properties.ts index ea500634..e1b131de 100644 --- a/packages/mailgun/src/models/v1/emails/request/template-properties/template-properties.ts +++ b/packages/mailgun/src/models/v1/emails/request/template-properties/template-properties.ts @@ -1,4 +1,3 @@ -import FormData = require('form-data'); import { YesNoEnum } from '../enum'; export interface TemplateProperties { @@ -10,14 +9,3 @@ export interface TemplateProperties { variables?: string; } -export const appendTemplatePropertiesToFormData = (templateProperties: TemplateProperties, formData: FormData) => { - if (templateProperties['text'] != null) { - formData.append('t:text', String(templateProperties['text'])); - } - if (templateProperties['version'] != null) { - formData.append('t:version', templateProperties['version']); - } - if (templateProperties['variables'] != null) { - formData.append('t:variables', templateProperties['variables']); - } -}; diff --git a/packages/mailgun/src/models/v1/emails/response/bad-request/bad-request.transform.ts b/packages/mailgun/src/models/v1/emails/response/bad-request/bad-request.transform.ts new file mode 100644 index 00000000..abef2b1d --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/response/bad-request/bad-request.transform.ts @@ -0,0 +1,14 @@ +import { BadRequest, BadRequestFromApi } from './bad-request'; + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const transformBadRequestIntoClientResponse = ( + apiResponse: BadRequestFromApi, +): BadRequest => { + const { + ...response + } = apiResponse; + return response; +}; diff --git a/packages/mailgun/src/models/v1/emails/response/bad-request/bad-request.ts b/packages/mailgun/src/models/v1/emails/response/bad-request/bad-request.ts index c6ec15ac..94a8e171 100644 --- a/packages/mailgun/src/models/v1/emails/response/bad-request/bad-request.ts +++ b/packages/mailgun/src/models/v1/emails/response/bad-request/bad-request.ts @@ -2,12 +2,3 @@ export type BadRequest = Omit; export interface BadRequestFromApi { message: string; } - -export const transformBadRequestIntoClientResponse = ( - apiResponse: BadRequestFromApi, -): BadRequest => { - const { - ...response - } = apiResponse; - return response; -}; diff --git a/packages/mailgun/src/models/v1/emails/response/bad-request/index.ts b/packages/mailgun/src/models/v1/emails/response/bad-request/index.ts index abd2105a..95242d8a 100644 --- a/packages/mailgun/src/models/v1/emails/response/bad-request/index.ts +++ b/packages/mailgun/src/models/v1/emails/response/bad-request/index.ts @@ -1,8 +1 @@ -export type { - BadRequest, - BadRequestFromApi, -} from './bad-request'; -export { - transformBadRequestIntoClientResponse, -} from './bad-request'; - +export type { BadRequest } from './bad-request'; diff --git a/packages/mailgun/src/models/v1/emails/response/email-not-found/email-not-found.transform.ts b/packages/mailgun/src/models/v1/emails/response/email-not-found/email-not-found.transform.ts new file mode 100644 index 00000000..9e97ba75 --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/response/email-not-found/email-not-found.transform.ts @@ -0,0 +1,14 @@ +import { EmailNotFound, EmailNotFoundFromApi } from './email-not-found'; + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const transformEmailNotFoundIntoClientResponse = ( + apiResponse: EmailNotFoundFromApi, +): EmailNotFound => { + const { + ...response + } = apiResponse; + return response; +}; diff --git a/packages/mailgun/src/models/v1/emails/response/email-not-found/email-not-found.ts b/packages/mailgun/src/models/v1/emails/response/email-not-found/email-not-found.ts index c7dfaed5..2a6546e1 100644 --- a/packages/mailgun/src/models/v1/emails/response/email-not-found/email-not-found.ts +++ b/packages/mailgun/src/models/v1/emails/response/email-not-found/email-not-found.ts @@ -3,12 +3,3 @@ export type EmailNotFound = Omit; export interface EmailNotFoundFromApi { message: string; } - -export const transformEmailNotFoundIntoClientResponse = ( - apiResponse: EmailNotFoundFromApi, -): EmailNotFound => { - const { - ...response - } = apiResponse; - return response; -}; diff --git a/packages/mailgun/src/models/v1/emails/response/email-not-found/index.ts b/packages/mailgun/src/models/v1/emails/response/email-not-found/index.ts index e95051b8..6ed45d38 100644 --- a/packages/mailgun/src/models/v1/emails/response/email-not-found/index.ts +++ b/packages/mailgun/src/models/v1/emails/response/email-not-found/index.ts @@ -1,7 +1 @@ -export type { - EmailNotFound, - EmailNotFoundFromApi, -} from './email-not-found'; -export { - transformEmailNotFoundIntoClientResponse, -} from './email-not-found'; +export type { EmailNotFound } from './email-not-found'; diff --git a/packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/exceeded-queue-quota.transform.ts b/packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/exceeded-queue-quota.transform.ts new file mode 100644 index 00000000..7435d9e4 --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/exceeded-queue-quota.transform.ts @@ -0,0 +1,17 @@ +import { ExceededQueueQuota, ExceededQueueQuotaFromApi } from './exceeded-queue-quota'; +import { + transformQueueStatusDisabledDetailsIntoClientResponse, +} from '../queue-status-disabled-details/queue-status-disabled-details.transform'; + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const transformExceededQueueQuota = ( + apiResponse: ExceededQueueQuotaFromApi, +): ExceededQueueQuota => { + return { + disabled: transformQueueStatusDisabledDetailsIntoClientResponse(apiResponse['disabled']), + isDisabled: apiResponse['is_disabled'], + }; +}; diff --git a/packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/exceeded-queue-quota.ts b/packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/exceeded-queue-quota.ts index b5d160e4..12f25445 100644 --- a/packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/exceeded-queue-quota.ts +++ b/packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/exceeded-queue-quota.ts @@ -1,8 +1,5 @@ -import { - QueueStatusDisabledDetails, - QueueStatusDisabledDetailsFromApi, - transformQueueStatusDisabledDetailsIntoClientResponse, -} from '../queue-status-disabled-details'; +import { QueueStatusDisabledDetails } from '../queue-status-disabled-details'; +import { QueueStatusDisabledDetailsFromApi } from '../queue-status-disabled-details/queue-status-disabled-details'; export interface ExceededQueueQuota { /** @see QueueStatusDisabledDetails */ @@ -15,12 +12,3 @@ export interface ExceededQueueQuotaFromApi { disabled?: QueueStatusDisabledDetailsFromApi; is_disabled: boolean; } - -export const transformExceededQueueQuota = ( - apiResponse: ExceededQueueQuotaFromApi, -): ExceededQueueQuota => { - return { - disabled: transformQueueStatusDisabledDetailsIntoClientResponse(apiResponse['disabled']), - isDisabled: apiResponse['is_disabled'], - }; -}; diff --git a/packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/index.ts b/packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/index.ts index 1968596a..f16dfc1a 100644 --- a/packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/index.ts +++ b/packages/mailgun/src/models/v1/emails/response/exceeded-queue-quota/index.ts @@ -1,7 +1 @@ -export type { - ExceededQueueQuota, - ExceededQueueQuotaFromApi, -} from './exceeded-queue-quota'; -export { - transformExceededQueueQuota, -} from './exceeded-queue-quota'; +export type { ExceededQueueQuota } from './exceeded-queue-quota'; diff --git a/packages/mailgun/src/models/v1/emails/response/generic-response/generic-response.transform.ts b/packages/mailgun/src/models/v1/emails/response/generic-response/generic-response.transform.ts new file mode 100644 index 00000000..1af3320d --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/response/generic-response/generic-response.transform.ts @@ -0,0 +1,14 @@ +import { GenericResponse, GenericResponseFromApi } from './generic-response'; + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const transformGenericResponseIntoClientResponse = ( + apiResponse: GenericResponseFromApi, +): GenericResponse => { + const { + ...response + } = apiResponse; + return response; +}; diff --git a/packages/mailgun/src/models/v1/emails/response/generic-response/generic-response.ts b/packages/mailgun/src/models/v1/emails/response/generic-response/generic-response.ts index 46a4ee35..0ab03f3d 100644 --- a/packages/mailgun/src/models/v1/emails/response/generic-response/generic-response.ts +++ b/packages/mailgun/src/models/v1/emails/response/generic-response/generic-response.ts @@ -3,12 +3,3 @@ export type GenericResponse = Omit export interface GenericResponseFromApi { message: string; } - -export const transformGenericResponseIntoClientResponse = ( - apiResponse: GenericResponseFromApi, -): GenericResponse => { - const { - ...response - } = apiResponse; - return response; -}; diff --git a/packages/mailgun/src/models/v1/emails/response/generic-response/index.ts b/packages/mailgun/src/models/v1/emails/response/generic-response/index.ts index 172eff9f..f1e9e87c 100644 --- a/packages/mailgun/src/models/v1/emails/response/generic-response/index.ts +++ b/packages/mailgun/src/models/v1/emails/response/generic-response/index.ts @@ -1,7 +1 @@ -export type { - GenericResponse, - GenericResponseFromApi, -} from './generic-response'; -export { - transformGenericResponseIntoClientResponse, -} from './generic-response'; +export type { GenericResponse } from './generic-response'; diff --git a/packages/mailgun/src/models/v1/emails/response/get-email-response/get-stored-email-response.transform.ts b/packages/mailgun/src/models/v1/emails/response/get-email-response/get-stored-email-response.transform.ts new file mode 100644 index 00000000..a34957a9 --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/response/get-email-response/get-stored-email-response.transform.ts @@ -0,0 +1,34 @@ +import { + GetStoredEmailResponse, + GetStoredEmailResponseFromApi, + MessageHeaders, + MessageHeadersFromApi, +} from './get-stored-email-response'; + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const transformGetEmailResponseIntoClientResponse = ( + apiResponse: GetStoredEmailResponseFromApi, +): GetStoredEmailResponse => { + return { + sender: apiResponse['sender'], + recipients: apiResponse['recipients'], + from: apiResponse['from'], + subject: apiResponse['subject'], + bodyHtml: apiResponse['body-html'], + bodyPlain: apiResponse['body-plain'], + messageHeaders: convertHeaders(apiResponse['message-headers']), + strippedHtml: apiResponse['stripped-html'], + strippedText: apiResponse['stripped-text'], + strippedSignature: apiResponse['stripped-signature'], + }; +}; + +const convertHeaders = (headers: MessageHeadersFromApi): MessageHeaders => { + return headers.reduce((acc, [key, value]) => { + acc[key] = value; + return acc; + }, {} as MessageHeaders); +}; diff --git a/packages/mailgun/src/models/v1/emails/response/get-email-response/get-stored-email-response.ts b/packages/mailgun/src/models/v1/emails/response/get-email-response/get-stored-email-response.ts index 235173fc..d25891e3 100644 --- a/packages/mailgun/src/models/v1/emails/response/get-email-response/get-stored-email-response.ts +++ b/packages/mailgun/src/models/v1/emails/response/get-email-response/get-stored-email-response.ts @@ -30,27 +30,3 @@ export type MessageHeadersFromApi = [string, string | Date][]; export type MessageHeaders = { [key: string]: string | Date; }; - -export const transformGetEmailResponseIntoClientResponse = ( - apiResponse: GetStoredEmailResponseFromApi, -): GetStoredEmailResponse => { - return { - sender: apiResponse['sender'], - recipients: apiResponse['recipients'], - from: apiResponse['from'], - subject: apiResponse['subject'], - bodyHtml: apiResponse['body-html'], - bodyPlain: apiResponse['body-plain'], - messageHeaders: convertHeaders(apiResponse['message-headers']), - strippedHtml: apiResponse['stripped-html'], - strippedText: apiResponse['stripped-text'], - strippedSignature: apiResponse['stripped-signature'], - }; -}; - -const convertHeaders = (headers: MessageHeadersFromApi): MessageHeaders => { - return headers.reduce((acc, [key, value]) => { - acc[key] = value; - return acc; - }, {} as MessageHeaders); -}; diff --git a/packages/mailgun/src/models/v1/emails/response/get-email-response/index.ts b/packages/mailgun/src/models/v1/emails/response/get-email-response/index.ts index e9f3c953..d40813db 100644 --- a/packages/mailgun/src/models/v1/emails/response/get-email-response/index.ts +++ b/packages/mailgun/src/models/v1/emails/response/get-email-response/index.ts @@ -1,9 +1 @@ -export type { - GetStoredEmailResponse, - MessageHeaders, - GetStoredEmailResponseFromApi, - MessageHeadersFromApi, -} from './get-stored-email-response'; -export { - transformGetEmailResponseIntoClientResponse, -} from './get-stored-email-response'; +export type { GetStoredEmailResponse, MessageHeaders } from './get-stored-email-response'; diff --git a/packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/index.ts b/packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/index.ts index f4ce44f0..d6c63da2 100644 --- a/packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/index.ts +++ b/packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/index.ts @@ -1,7 +1 @@ -export type { - QueueStatusDisabledDetails, - QueueStatusDisabledDetailsFromApi, -} from './queue-status-disabled-details'; -export { - transformQueueStatusDisabledDetailsIntoClientResponse, -} from './queue-status-disabled-details'; +export type { QueueStatusDisabledDetails } from './queue-status-disabled-details'; diff --git a/packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/queue-status-disabled-details.transform.ts b/packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/queue-status-disabled-details.transform.ts new file mode 100644 index 00000000..53c85346 --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/queue-status-disabled-details.transform.ts @@ -0,0 +1,14 @@ +import { QueueStatusDisabledDetails, QueueStatusDisabledDetailsFromApi } from './queue-status-disabled-details'; + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const transformQueueStatusDisabledDetailsIntoClientResponse = ( + apiResponse?: QueueStatusDisabledDetailsFromApi, +): QueueStatusDisabledDetails => { + const { + ...response + } = apiResponse; + return response; +}; diff --git a/packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/queue-status-disabled-details.ts b/packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/queue-status-disabled-details.ts index 9135e9bb..534094be 100644 --- a/packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/queue-status-disabled-details.ts +++ b/packages/mailgun/src/models/v1/emails/response/queue-status-disabled-details/queue-status-disabled-details.ts @@ -4,12 +4,3 @@ export interface QueueStatusDisabledDetailsFromApi { 'reason': string; 'until': string; } - -export const transformQueueStatusDisabledDetailsIntoClientResponse = ( - apiResponse?: QueueStatusDisabledDetailsFromApi, -): QueueStatusDisabledDetails => { - const { - ...response - } = apiResponse; - return response; -}; diff --git a/packages/mailgun/src/models/v1/emails/response/send-email-response/index.ts b/packages/mailgun/src/models/v1/emails/response/send-email-response/index.ts index 8ac506f4..0afd055b 100644 --- a/packages/mailgun/src/models/v1/emails/response/send-email-response/index.ts +++ b/packages/mailgun/src/models/v1/emails/response/send-email-response/index.ts @@ -1,7 +1 @@ -export type { - SendEmailResponse, - SendEmailResponseFromApi, -} from './send-email-response'; -export { - transformSendEmailResponseIntoClientResponse, -} from './send-email-response'; +export type { SendEmailResponse } from './send-email-response'; diff --git a/packages/mailgun/src/models/v1/emails/response/send-email-response/send-email-response.transform.ts b/packages/mailgun/src/models/v1/emails/response/send-email-response/send-email-response.transform.ts new file mode 100644 index 00000000..ddfb2d72 --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/response/send-email-response/send-email-response.transform.ts @@ -0,0 +1,14 @@ +import { SendEmailResponse, SendEmailResponseFromApi } from './send-email-response'; + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const transformSendEmailResponseIntoClientResponse = ( + apiResponse: SendEmailResponseFromApi, +): SendEmailResponse => { + const { + ...response + } = apiResponse; + return response; +}; diff --git a/packages/mailgun/src/models/v1/emails/response/send-email-response/send-email-response.ts b/packages/mailgun/src/models/v1/emails/response/send-email-response/send-email-response.ts index 6809823f..5a810169 100644 --- a/packages/mailgun/src/models/v1/emails/response/send-email-response/send-email-response.ts +++ b/packages/mailgun/src/models/v1/emails/response/send-email-response/send-email-response.ts @@ -4,12 +4,3 @@ export interface SendEmailResponseFromApi { message: string; id: string; } - -export const transformSendEmailResponseIntoClientResponse = ( - apiResponse: SendEmailResponseFromApi, -): SendEmailResponse => { - const { - ...response - } = apiResponse; - return response; -}; diff --git a/packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/index.ts b/packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/index.ts index 12491b05..9a8adf99 100644 --- a/packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/index.ts +++ b/packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/index.ts @@ -1,7 +1 @@ -export type { - SendingQueuesStatusResponse, - SendingQueuesStatusResponseFromApi, -} from './sending-queues-status-response'; -export { - transformSendingQueuesStatusResponseIntoClientResponse, -} from './sending-queues-status-response'; +export type { SendingQueuesStatusResponse } from './sending-queues-status-response'; diff --git a/packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/sending-queues-status-response.transform.ts b/packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/sending-queues-status-response.transform.ts new file mode 100644 index 00000000..f9e0e134 --- /dev/null +++ b/packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/sending-queues-status-response.transform.ts @@ -0,0 +1,15 @@ +import { SendingQueuesStatusResponse, SendingQueuesStatusResponseFromApi } from './sending-queues-status-response'; +import { transformExceededQueueQuota } from '../exceeded-queue-quota/exceeded-queue-quota.transform'; + +// eslint-disable-next-line valid-jsdoc +/** + * ** INTERNAL METHOD ** IT SHOULD NOT BE USED DIRECTLY BY SDK USERS AS IT CAN BE REMOVED OR MODIFIED WITHOUT NOTICE + */ +export const transformSendingQueuesStatusResponseIntoClientResponse = ( + apiResponse: SendingQueuesStatusResponseFromApi, +): SendingQueuesStatusResponse => { + return { + scheduled: transformExceededQueueQuota(apiResponse['scheduled']), + regular: transformExceededQueueQuota(apiResponse['regular']), + }; +}; diff --git a/packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/sending-queues-status-response.ts b/packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/sending-queues-status-response.ts index 32c722a2..7aca45ab 100644 --- a/packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/sending-queues-status-response.ts +++ b/packages/mailgun/src/models/v1/emails/response/sending-queues-status-response/sending-queues-status-response.ts @@ -1,4 +1,5 @@ -import { ExceededQueueQuota, ExceededQueueQuotaFromApi, transformExceededQueueQuota } from '../exceeded-queue-quota'; +import { ExceededQueueQuota } from '../exceeded-queue-quota'; +import { ExceededQueueQuotaFromApi } from '../exceeded-queue-quota/exceeded-queue-quota'; export interface SendingQueuesStatusResponse { /** @see ExceededQueueQuota */ @@ -13,12 +14,3 @@ export interface SendingQueuesStatusResponseFromApi { /** @see ExceededQueueQuotaFromApi */ regular: ExceededQueueQuotaFromApi; } - -export const transformSendingQueuesStatusResponseIntoClientResponse = ( - apiResponse: SendingQueuesStatusResponseFromApi, -): SendingQueuesStatusResponse => { - return { - scheduled: transformExceededQueueQuota(apiResponse['scheduled']), - regular: transformExceededQueueQuota(apiResponse['regular']), - }; -}; diff --git a/packages/mailgun/src/models/v1/index.ts b/packages/mailgun/src/models/v1/index.ts index c4fc5a1f..4c7239de 100644 --- a/packages/mailgun/src/models/v1/index.ts +++ b/packages/mailgun/src/models/v1/index.ts @@ -1,12 +1,12 @@ -export * from './emails/request/override-properties/override-properties'; -export * from './emails/request/send-email-request/send-email-request'; -export * from './emails/request/send-mime-email-request/send-mime-email-request'; -export * from './emails/request/template-properties/template-properties'; -export * from './emails/response/bad-request/bad-request'; -export * from './emails/response/email-not-found/email-not-found'; -export * from './emails/response/exceeded-queue-quota/exceeded-queue-quota'; -export * from './emails/response/generic-response/generic-response'; -export * from './emails/response/get-email-response/get-stored-email-response'; -export * from './emails/response/queue-status-disabled-details/queue-status-disabled-details'; -export * from './emails/response/send-email-response/send-email-response'; -export * from './emails/response/sending-queues-status-response/sending-queues-status-response'; +export * from './emails/request/override-properties'; +export * from './emails/request/send-email-request'; +export * from './emails/request/send-mime-email-request'; +export * from './emails/request/template-properties'; +export * from './emails/response/bad-request'; +export * from './emails/response/email-not-found'; +export * from './emails/response/exceeded-queue-quota'; +export * from './emails/response/generic-response'; +export * from './emails/response/get-email-response'; +export * from './emails/response/queue-status-disabled-details'; +export * from './emails/response/send-email-response'; +export * from './emails/response/sending-queues-status-response'; diff --git a/packages/mailgun/src/rest/v1/emails/emails-api.ts b/packages/mailgun/src/rest/v1/emails/emails-api.ts index ce9cf627..35b7dd4a 100644 --- a/packages/mailgun/src/rest/v1/emails/emails-api.ts +++ b/packages/mailgun/src/rest/v1/emails/emails-api.ts @@ -1,18 +1,9 @@ import { - GenericResponseFromApi, GetStoredEmailResponse, - GetStoredEmailResponseFromApi, SendEmailRequest, SendEmailResponse, - SendEmailResponseFromApi, SendingQueuesStatusResponse, - SendingQueuesStatusResponseFromApi, SendMimeEmailRequest, - transformGetEmailResponseIntoClientResponse, - transformSendEmailRequestIntoApiRequestBody, - transformSendEmailResponseIntoClientResponse, - transformSendingQueuesStatusResponseIntoClientResponse, - transformSendMimeEmailRequestIntoApiRequestBody, } from '../../../models'; import { RequestBody, @@ -20,6 +11,33 @@ import { MailgunStorageHostname, } from '@sinch/sdk-client'; import { MailgunDomainApi } from '../mailgun-domain-api'; +import { + transformSendEmailRequestIntoApiRequestBody, +} from '../../../models/v1/emails/request/send-email-request/send-email-request.transform'; +import { + transformSendMimeEmailRequestIntoApiRequestBody, +} from '../../../models/v1/emails/request/send-mime-email-request/send-mime-email-request.transform'; +import { + transformSendEmailResponseIntoClientResponse, +} from '../../../models/v1/emails/response/send-email-response/send-email-response.transform'; +import { + transformGetEmailResponseIntoClientResponse, +} from '../../../models/v1/emails/response/get-email-response/get-stored-email-response.transform'; +import { + transformSendingQueuesStatusResponseIntoClientResponse, +} from '../../../models/v1/emails/response/sending-queues-status-response/sending-queues-status-response.transform'; +import { + SendEmailResponseFromApi, +} from '../../../models/v1/emails/response/send-email-response/send-email-response'; +import { + GetStoredEmailResponseFromApi, +} from '../../../models/v1/emails/response/get-email-response/get-stored-email-response'; +import { + GenericResponseFromApi, +} from '../../../models/v1/emails/response/generic-response/generic-response'; +import { + SendingQueuesStatusResponseFromApi, +} from '../../../models/v1/emails/response/sending-queues-status-response/sending-queues-status-response'; export class EmailsApi extends MailgunDomainApi { storageHostnames: string[]; diff --git a/packages/mailgun/tests/models/v1/emails/request/helper.test.ts b/packages/mailgun/tests/models/v1/emails/request/helper.test.ts index f0a2b984..95c38848 100644 --- a/packages/mailgun/tests/models/v1/emails/request/helper.test.ts +++ b/packages/mailgun/tests/models/v1/emails/request/helper.test.ts @@ -32,7 +32,7 @@ describe('appendFilteredPropertiesToFormData', () => { expect(appendSpy).toHaveBeenCalledWith('v:last_name', 'Smith'); expect(appendSpy).toHaveBeenCalledWith('v:my_message_id', '123'); expect(appendSpy).toHaveBeenCalledWith('v:date1', '2024-06-06T13:42:42Z'); - expect(appendSpy).toHaveBeenCalledWith('v:date2', '2024-06-06T13:42:42.000Z'); + expect(appendSpy).toHaveBeenCalledWith('v:date2', 'Thu, 06 Jun 2024 13:42:42 GMT'); }); it('should not append properties with null or undefined values', () => { diff --git a/packages/mailgun/tests/models/v1/emails/request/send-email-request.models.ts b/packages/mailgun/tests/models/v1/emails/request/send-email-request.models.ts index 73fb983c..3007e9cf 100644 --- a/packages/mailgun/tests/models/v1/emails/request/send-email-request.models.ts +++ b/packages/mailgun/tests/models/v1/emails/request/send-email-request.models.ts @@ -8,7 +8,7 @@ export const sendEmailRequestWithHtml: Mailgun.SendEmailRequest = { subject: 'subject value', text: 'text value', html: 'html value', - amp_html: 'amp_html value', + ampHtml: 'amp_html value', attachment: 'attachment value', inline: 'inline value', overrideProperties: { @@ -43,7 +43,7 @@ export const sendEmailRequestWithTemplate: Mailgun.SendEmailRequest = { subject: 'subject value', text: 'text value', template: 'template value', - amp_html: 'amp_html value', + ampHtml: 'amp_html value', attachment: 'attachment value', inline: 'inline value', templateProperties: { diff --git a/packages/mailgun/tests/models/v1/emails/request/send-email-request.test.ts b/packages/mailgun/tests/models/v1/emails/request/send-email-request.test.ts index 31988889..f423e8d4 100644 --- a/packages/mailgun/tests/models/v1/emails/request/send-email-request.test.ts +++ b/packages/mailgun/tests/models/v1/emails/request/send-email-request.test.ts @@ -1,6 +1,8 @@ import FormData = require('form-data'); import { sendEmailRequestWithHtml, sendEmailRequestWithTemplate } from './send-email-request.models'; -import { transformSendEmailRequestIntoApiRequestBody } from '../../../../../src/models'; +import { + transformSendEmailRequestIntoApiRequestBody, +} from '../../../../../src/models/v1/emails/request/send-email-request/send-email-request.transform'; describe('SendEmailRequest', () => { diff --git a/packages/mailgun/tests/models/v1/emails/request/send-mime-email-request.test.ts b/packages/mailgun/tests/models/v1/emails/request/send-mime-email-request.test.ts index c84326fd..2e6fb6bb 100644 --- a/packages/mailgun/tests/models/v1/emails/request/send-mime-email-request.test.ts +++ b/packages/mailgun/tests/models/v1/emails/request/send-mime-email-request.test.ts @@ -1,6 +1,8 @@ import FormData = require('form-data'); -import { transformSendMimeEmailRequestIntoApiRequestBody } from '../../../../../src/models'; import { sendMimeEmailRequest } from './send-mime-email-request.models'; +import { + transformSendMimeEmailRequestIntoApiRequestBody, +} from '../../../../../src/models/v1/emails/request/send-mime-email-request/send-mime-email-request.transform'; describe('SendMimeEmailRequest', () => { diff --git a/packages/mailgun/tests/models/v1/emails/response/bad-request.models.ts b/packages/mailgun/tests/models/v1/emails/response/bad-request.models.ts index ec9a2d77..fa0206de 100644 --- a/packages/mailgun/tests/models/v1/emails/response/bad-request.models.ts +++ b/packages/mailgun/tests/models/v1/emails/response/bad-request.models.ts @@ -1,6 +1,7 @@ import { Mailgun } from '../../../../../src'; +import { BadRequestFromApi } from '../../../../../src/models/v1/emails/response/bad-request/bad-request'; -export const badRequestFromApi: Mailgun.BadRequestFromApi = { +export const badRequestFromApi: BadRequestFromApi = { message: 'Invalid storage key', }; diff --git a/packages/mailgun/tests/models/v1/emails/response/bad-request.test.ts b/packages/mailgun/tests/models/v1/emails/response/bad-request.test.ts index 8c9733e8..1e5bf8f9 100644 --- a/packages/mailgun/tests/models/v1/emails/response/bad-request.test.ts +++ b/packages/mailgun/tests/models/v1/emails/response/bad-request.test.ts @@ -1,7 +1,5 @@ -import { - transformBadRequestIntoClientResponse, -} from '../../../../../src/models'; import { badRequest, badRequestFromApi } from './bad-request.models'; +import { transformBadRequestIntoClientResponse } from '../../../../../src/models/v1/emails/response/bad-request/bad-request.transform'; describe('BadRequest', () => { diff --git a/packages/mailgun/tests/models/v1/emails/response/email-not-found.models.ts b/packages/mailgun/tests/models/v1/emails/response/email-not-found.models.ts index 5b188ede..6d5140d8 100644 --- a/packages/mailgun/tests/models/v1/emails/response/email-not-found.models.ts +++ b/packages/mailgun/tests/models/v1/emails/response/email-not-found.models.ts @@ -1,6 +1,7 @@ import { Mailgun } from '../../../../../src'; +import { EmailNotFoundFromApi } from '../../../../../src/models/v1/emails/response/email-not-found/email-not-found'; -export const emailNotFoundFromApi: Mailgun.EmailNotFoundFromApi = { +export const emailNotFoundFromApi: EmailNotFoundFromApi = { message: 'Message not found', }; diff --git a/packages/mailgun/tests/models/v1/emails/response/email-not-found.test.ts b/packages/mailgun/tests/models/v1/emails/response/email-not-found.test.ts index 1ecb09cb..fccf2a9a 100644 --- a/packages/mailgun/tests/models/v1/emails/response/email-not-found.test.ts +++ b/packages/mailgun/tests/models/v1/emails/response/email-not-found.test.ts @@ -1,7 +1,5 @@ -import { - transformEmailNotFoundIntoClientResponse, -} from '../../../../../src/models'; import { emailNotFound, emailNotFoundFromApi } from './email-not-found.models'; +import { transformEmailNotFoundIntoClientResponse } from '../../../../../src/models/v1/emails/response/email-not-found/email-not-found.transform'; describe('EmailNotFound', () => { diff --git a/packages/mailgun/tests/models/v1/emails/response/generic-response.models.ts b/packages/mailgun/tests/models/v1/emails/response/generic-response.models.ts index e6f14583..79447d8b 100644 --- a/packages/mailgun/tests/models/v1/emails/response/generic-response.models.ts +++ b/packages/mailgun/tests/models/v1/emails/response/generic-response.models.ts @@ -1,6 +1,7 @@ import { Mailgun } from '../../../../../src'; +import { GenericResponseFromApi } from '../../../../../src/models/v1/emails/response/generic-response/generic-response'; -export const genericResponseFromApi: Mailgun.GenericResponseFromApi = { +export const genericResponseFromApi: GenericResponseFromApi = { message: 'message value', }; diff --git a/packages/mailgun/tests/models/v1/emails/response/generic-response.test.ts b/packages/mailgun/tests/models/v1/emails/response/generic-response.test.ts index dd639681..358bd23d 100644 --- a/packages/mailgun/tests/models/v1/emails/response/generic-response.test.ts +++ b/packages/mailgun/tests/models/v1/emails/response/generic-response.test.ts @@ -1,7 +1,7 @@ +import { genericResponse, genericResponseFromApi } from './generic-response.models'; import { transformGenericResponseIntoClientResponse, -} from '../../../../../src/models'; -import { genericResponse, genericResponseFromApi } from './generic-response.models'; +} from '../../../../../src/models/v1/emails/response/generic-response/generic-response.transform'; describe('GenericResponse', () => { diff --git a/packages/mailgun/tests/models/v1/emails/response/get-stored-email-response.models.ts b/packages/mailgun/tests/models/v1/emails/response/get-stored-email-response.models.ts index d8f0581f..e01005a6 100644 --- a/packages/mailgun/tests/models/v1/emails/response/get-stored-email-response.models.ts +++ b/packages/mailgun/tests/models/v1/emails/response/get-stored-email-response.models.ts @@ -1,6 +1,7 @@ import { Mailgun } from '../../../../../src'; +import { GetStoredEmailResponseFromApi } from '../../../../../src/models/v1/emails/response/get-email-response/get-stored-email-response'; -export const getStoredEmailResponseFromApi: Mailgun.GetStoredEmailResponseFromApi = { +export const getStoredEmailResponseFromApi: GetStoredEmailResponseFromApi = { 'X-Mailgun-Deliver-By': new Date('Wed, 06 Jun 2024 07:40:00 +0000'), subject: '"Mailgun is awesome"', Subject: '"Mailgun is awesome"', diff --git a/packages/mailgun/tests/models/v1/emails/response/get-stored-email-response.test.ts b/packages/mailgun/tests/models/v1/emails/response/get-stored-email-response.test.ts index 15d94a83..cb65c827 100644 --- a/packages/mailgun/tests/models/v1/emails/response/get-stored-email-response.test.ts +++ b/packages/mailgun/tests/models/v1/emails/response/get-stored-email-response.test.ts @@ -1,7 +1,7 @@ +import { getStoredEmailResponse, getStoredEmailResponseFromApi } from './get-stored-email-response.models'; import { transformGetEmailResponseIntoClientResponse, -} from '../../../../../src/models'; -import { getStoredEmailResponse, getStoredEmailResponseFromApi } from './get-stored-email-response.models'; +} from '../../../../../src/models/v1/emails/response/get-email-response/get-stored-email-response.transform'; describe('GetEmailResponse', () => { diff --git a/packages/mailgun/tests/models/v1/emails/response/send-email-response.models.ts b/packages/mailgun/tests/models/v1/emails/response/send-email-response.models.ts index 2d9cf7c7..6ac1ca1c 100644 --- a/packages/mailgun/tests/models/v1/emails/response/send-email-response.models.ts +++ b/packages/mailgun/tests/models/v1/emails/response/send-email-response.models.ts @@ -1,6 +1,7 @@ import { Mailgun } from '../../../../../src'; +import { SendEmailResponseFromApi } from '../../../../../src/models/v1/emails/response/send-email-response/send-email-response'; -export const sendEmailResponseFromApi: Mailgun.SendEmailResponseFromApi = { +export const sendEmailResponseFromApi: SendEmailResponseFromApi = { id: 'id value', message: 'Queued. Thank you.', }; diff --git a/packages/mailgun/tests/models/v1/emails/response/send-email-response.test.ts b/packages/mailgun/tests/models/v1/emails/response/send-email-response.test.ts index ca314a0c..5434e326 100644 --- a/packages/mailgun/tests/models/v1/emails/response/send-email-response.test.ts +++ b/packages/mailgun/tests/models/v1/emails/response/send-email-response.test.ts @@ -1,12 +1,10 @@ +import { sendEmailResponse, sendEmailResponseFromApi } from './send-email-response.models'; import { transformSendEmailResponseIntoClientResponse, -} from '../../../../../src/models'; -import { sendEmailResponse, sendEmailResponseFromApi } from './send-email-response.models'; +} from '../../../../../src/models/v1/emails/response/send-email-response/send-email-response.transform'; describe('SendEmailResponse', () => { - - it('should convert an API object into a client object', () => { const transformedResponse = transformSendEmailResponseIntoClientResponse(sendEmailResponseFromApi); expect(transformedResponse).toEqual(sendEmailResponse); diff --git a/packages/mailgun/tests/models/v1/emails/response/sending-queues-status-response.models.ts b/packages/mailgun/tests/models/v1/emails/response/sending-queues-status-response.models.ts index 1ca11f00..ceeee2d4 100644 --- a/packages/mailgun/tests/models/v1/emails/response/sending-queues-status-response.models.ts +++ b/packages/mailgun/tests/models/v1/emails/response/sending-queues-status-response.models.ts @@ -1,6 +1,9 @@ import { Mailgun } from '../../../../../src'; +import { + SendingQueuesStatusResponseFromApi, +} from '../../../../../src/models/v1/emails/response/sending-queues-status-response/sending-queues-status-response'; -export const sendingQueuesStatusResponseFromApi: Mailgun.SendingQueuesStatusResponseFromApi = { +export const sendingQueuesStatusResponseFromApi: SendingQueuesStatusResponseFromApi = { scheduled: { is_disabled: false, disabled: { diff --git a/packages/mailgun/tests/models/v1/emails/response/sending-queues-status-response.test.ts b/packages/mailgun/tests/models/v1/emails/response/sending-queues-status-response.test.ts index bee61aa2..b4fe417e 100644 --- a/packages/mailgun/tests/models/v1/emails/response/sending-queues-status-response.test.ts +++ b/packages/mailgun/tests/models/v1/emails/response/sending-queues-status-response.test.ts @@ -1,10 +1,11 @@ -import { - transformSendingQueuesStatusResponseIntoClientResponse, -} from '../../../../../src/models'; import { sendingQueuesStatusResponse, sendingQueuesStatusResponseFromApi, } from './sending-queues-status-response.models'; +import { + transformSendingQueuesStatusResponseIntoClientResponse, +// eslint-disable-next-line max-len +} from '../../../../../src/models/v1/emails/response/sending-queues-status-response/sending-queues-status-response.transform'; describe('SendingQueuesStatusResponse', () => {