-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7c1b4a
commit e522331
Showing
55 changed files
with
390 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
packages/mailgun/src/models/v1/emails/request/override-properties/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export type { OverrideProperties } from './override-properties'; | ||
export { appendOverridePropertiesToFormData } from './override-properties'; |
57 changes: 57 additions & 0 deletions
57
...mailgun/src/models/v1/emails/request/override-properties/override-properties.transform.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'])); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
packages/mailgun/src/models/v1/emails/request/send-email-request/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export type { SendEmailRequest } from './send-email-request'; | ||
export { transformSendEmailRequestIntoApiRequestBody } from './send-email-request'; |
55 changes: 55 additions & 0 deletions
55
...s/mailgun/src/models/v1/emails/request/send-email-request/send-email-request.transform.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
packages/mailgun/src/models/v1/emails/request/send-mime-email-request/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export type { SendMimeEmailRequest } from './send-mime-email-request'; | ||
export { transformSendMimeEmailRequestIntoApiRequestBody } from './send-mime-email-request'; |
31 changes: 31 additions & 0 deletions
31
...src/models/v1/emails/request/send-mime-email-request/send-mime-email-request.transform.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
packages/mailgun/src/models/v1/emails/request/template-properties/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export type { TemplateProperties } from './template-properties'; | ||
export { appendTemplatePropertiesToFormData } from './template-properties'; |
18 changes: 18 additions & 0 deletions
18
...mailgun/src/models/v1/emails/request/template-properties/template-properties.transform.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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']); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/mailgun/src/models/v1/emails/response/bad-request/bad-request.transform.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.