mailgun.js 5.0.3 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +15 -3
- package/client.d.ts +29 -0
- package/domains.d.ts +53 -0
- package/domainsCredentials.d.ts +14 -0
- package/domainsTags.d.ts +34 -0
- package/domainsTemplates.d.ts +35 -0
- package/error.d.ts +7 -0
- package/events.d.ts +13 -0
- package/index.d.ts +9 -0
- package/interfaces/APIErrorOptions.d.ts +11 -0
- package/{lib/interfaces/ApiResponse.ts → interfaces/ApiResponse.d.ts} +1 -2
- package/{lib/interfaces/DomainCredentials.ts → interfaces/DomainCredentials.d.ts} +14 -30
- package/{lib/interfaces/DomainTags.ts → interfaces/DomainTags.d.ts} +49 -82
- package/{lib/interfaces/DomainTemplates.ts → interfaces/DomainTemplates.d.ts} +35 -79
- package/{lib/interfaces/DomainTracking.ts → interfaces/DomainTracking.d.ts} +18 -17
- package/{lib/interfaces/Domains.ts → interfaces/Domains.d.ts} +29 -50
- package/{lib/interfaces/Events.ts → interfaces/Events.d.ts} +11 -12
- package/{lib/interfaces/IFormData.ts → interfaces/IFormData.d.ts} +2 -4
- package/interfaces/IMailgunClient.d.ts +24 -0
- package/interfaces/IpPools.d.ts +19 -0
- package/interfaces/Ips.d.ts +10 -0
- package/{lib/interfaces/MultipleValidation.ts → interfaces/MultipleValidation.d.ts} +9 -16
- package/interfaces/Options.d.ts +8 -0
- package/{lib/interfaces/RequestOptions.ts → interfaces/RequestOptions.d.ts} +2 -4
- package/interfaces/StatsOptions.d.ts +22 -0
- package/interfaces/Supressions.d.ts +103 -0
- package/{lib/interfaces/Validate.ts → interfaces/Validate.d.ts} +0 -3
- package/{lib/interfaces/Webhooks.ts → interfaces/Webhooks.d.ts} +11 -17
- package/{lib/interfaces/lists.ts → interfaces/lists.d.ts} +1 -5
- package/{lib/interfaces/mailListMembers.ts → interfaces/mailListMembers.d.ts} +8 -23
- package/{lib/interfaces/routes.ts → interfaces/routes.d.ts} +1 -6
- package/ip-pools.d.ts +21 -0
- package/ips.d.ts +9 -0
- package/lists.d.ts +14 -0
- package/mailListMembers.d.ts +14 -0
- package/mailgun.node.js +3 -0
- package/{dist/mailgun.node.js.LICENSE.txt → mailgun.node.js.LICENSE.txt} +1 -1
- package/mailgun.web.js +3 -0
- package/{dist/mailgun.web.js.LICENSE.txt → mailgun.web.js.LICENSE.txt} +1 -1
- package/messages.d.ts +9 -0
- package/multipleValidation.d.ts +10 -0
- package/package.json +8 -81
- package/request.d.ts +31 -0
- package/routes.d.ts +11 -0
- package/stats.d.ts +20 -0
- package/suppressions.d.ts +50 -0
- package/validate.d.ts +9 -0
- package/version.md +1 -0
- package/webhooks.d.ts +32 -0
- package/.editorconfig +0 -10
- package/.eslintrc +0 -56
- package/.husky/commit-msg +0 -4
- package/.travis.yml +0 -5
- package/LICENSE +0 -191
- package/commitlint.config.js +0 -7
- package/dist/mailgun.js.d.ts +0 -1586
- package/dist/mailgun.node.js +0 -3
- package/dist/mailgun.web.js +0 -3
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -127
- package/docs/assets/icons.css +0 -1043
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
- package/docs/assets/main.js +0 -52
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1413
- package/docs/assets/widgets.png +0 -0
- package/docs/assets/widgets@2x.png +0 -0
- package/docs/classes/client.default.html +0 -1
- package/docs/classes/domains.Domain.html +0 -1
- package/docs/classes/domains.default.html +0 -1
- package/docs/classes/domainsCredentials.default.html +0 -1
- package/docs/classes/domainsTemplates.DomainTemplateItem.html +0 -1
- package/docs/classes/domainsTemplates.default.html +0 -1
- package/docs/classes/error.default.html +0 -6
- package/docs/classes/events.default.html +0 -1
- package/docs/classes/ip_pools.default.html +0 -1
- package/docs/classes/ips.default.html +0 -1
- package/docs/classes/lists.default.html +0 -1
- package/docs/classes/mailListMembers.default.html +0 -1
- package/docs/classes/messages.default.html +0 -1
- package/docs/classes/multipleValidation.default.html +0 -1
- package/docs/classes/request.default.html +0 -1
- package/docs/classes/routes.default.html +0 -1
- package/docs/classes/stats.default.html +0 -1
- package/docs/classes/suppressions.default.html +0 -1
- package/docs/classes/validate.default.html +0 -1
- package/docs/classes/webhooks.default.html +0 -1
- package/docs/enums/interfaces_DomainTemplates.Pages.html +0 -1
- package/docs/enums/interfaces_DomainTemplates.YesNo.html +0 -1
- package/docs/index.html +0 -1140
- package/docs/interfaces/interfaces_APIErrorOptions.default.html +0 -1
- package/docs/interfaces/interfaces_ApiResponse.default.html +0 -1
- package/docs/interfaces/interfaces_DomainCredentials.CreatedUpdatedDomainCredentialsResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainCredentials.DeletedDomainCredentialsResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainCredentials.DomainCredentials.html +0 -1
- package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsItem.html +0 -1
- package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsList.html +0 -1
- package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsQuery.html +0 -1
- package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsResponseData.html +0 -1
- package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsResult.html +0 -1
- package/docs/interfaces/interfaces_DomainCredentials.IDomainCredentials.html +0 -1
- package/docs/interfaces/interfaces_DomainCredentials.UpdateDomainCredentialsData.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.CreateDomainTemplateAPIResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.CreateDomainTemplateVersionAPIResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.CreateDomainTemplateVersionResult.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.DomainTemplate.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateData.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateUpdateData.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateUpdateVersionData.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateVersionData.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.DomainTemplatesQuery.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.GetDomainTemplateAPIResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.IDomainTemplatesClient.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplateVersionsAPIResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplateVersionsResult.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplatesAPIResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplatesResult.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.MutateDomainTemplateVersionAPIResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.MutateDomainTemplateVersionResult.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.NotificationAPIResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.NotificationResult.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.ShortTemplateVersion.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.TemplateQuery.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.TemplateVersion.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.UpdateOrDeleteDomainTemplateAPIResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainTemplates.UpdateOrDeleteDomainTemplateResult.html +0 -1
- package/docs/interfaces/interfaces_DomainTracking.ClickTrackingInfo.html +0 -1
- package/docs/interfaces/interfaces_DomainTracking.DomainTrackingData.html +0 -1
- package/docs/interfaces/interfaces_DomainTracking.DomainTrackingResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainTracking.OpenTrackingInfo.html +0 -1
- package/docs/interfaces/interfaces_DomainTracking.UnsubscribeTrackingInfo.html +0 -1
- package/docs/interfaces/interfaces_DomainTracking.UpdateDomainTrackingResponse.html +0 -1
- package/docs/interfaces/interfaces_DomainTracking.UpdatedOpenTracking.html +0 -1
- package/docs/interfaces/interfaces_Domains.ConnectionSettings.html +0 -1
- package/docs/interfaces/interfaces_Domains.ConnectionSettingsResponse.html +0 -1
- package/docs/interfaces/interfaces_Domains.DKIMAuthorityInfo.html +0 -1
- package/docs/interfaces/interfaces_Domains.DKIMSelectorInfo.html +0 -1
- package/docs/interfaces/interfaces_Domains.DNSRecord.html +0 -1
- package/docs/interfaces/interfaces_Domains.DestroyedDomainResponse.html +0 -1
- package/docs/interfaces/interfaces_Domains.DomainData.html +0 -1
- package/docs/interfaces/interfaces_Domains.DomainInfo.html +0 -1
- package/docs/interfaces/interfaces_Domains.DomainListResponseData.html +0 -1
- package/docs/interfaces/interfaces_Domains.DomainResponseData.html +0 -1
- package/docs/interfaces/interfaces_Domains.DomainShortData.html +0 -1
- package/docs/interfaces/interfaces_Domains.DomainsListItem.html +0 -1
- package/docs/interfaces/interfaces_Domains.DomainsQuery.html +0 -1
- package/docs/interfaces/interfaces_Domains.MessageResponse.html +0 -1
- package/docs/interfaces/interfaces_Domains.ReplacementForPool.html +0 -1
- package/docs/interfaces/interfaces_Domains.UpdatedConnectionSettings.html +0 -1
- package/docs/interfaces/interfaces_Domains.UpdatedConnectionSettingsRes.html +0 -1
- package/docs/interfaces/interfaces_Domains.UpdatedDKIMAuthority.html +0 -1
- package/docs/interfaces/interfaces_Domains.UpdatedDKIMAuthorityResponse.html +0 -1
- package/docs/interfaces/interfaces_Domains.UpdatedDKIMSelectorResponse.html +0 -1
- package/docs/interfaces/interfaces_Domains.UpdatedWebPrefix.html +0 -1
- package/docs/interfaces/interfaces_Domains.UpdatedWebPrefixResponse.html +0 -1
- package/docs/interfaces/interfaces_Domains.WebPrefixInfo.html +0 -1
- package/docs/interfaces/interfaces_Events.DomainEvent.html +0 -1
- package/docs/interfaces/interfaces_Events.EventsList.html +0 -1
- package/docs/interfaces/interfaces_Events.EventsPage.html +0 -1
- package/docs/interfaces/interfaces_Events.EventsResponse.html +0 -1
- package/docs/interfaces/interfaces_Events.PagesList.html +0 -1
- package/docs/interfaces/interfaces_Events.PagesListAccumulator.html +0 -1
- package/docs/interfaces/interfaces_Events.ParsedPage.html +0 -1
- package/docs/interfaces/interfaces_Events.ParsedPagesList.html +0 -1
- package/docs/interfaces/interfaces_IFormData.IFormDataOptions.html +0 -1
- package/docs/interfaces/interfaces_IFormData.InputFormData.html +0 -1
- package/docs/interfaces/interfaces_IpPools.IpPool.html +0 -1
- package/docs/interfaces/interfaces_IpPools.IpPoolListResponse.html +0 -1
- package/docs/interfaces/interfaces_IpPools.IpPoolUpdateData.html +0 -1
- package/docs/interfaces/interfaces_Ips.IpData.html +0 -1
- package/docs/interfaces/interfaces_Ips.IpsListResponseBody.html +0 -1
- package/docs/interfaces/interfaces_MultipleValidation.CanceledMultipleValidationJob.html +0 -1
- package/docs/interfaces/interfaces_MultipleValidation.CreatedMultipleValidationJob.html +0 -1
- package/docs/interfaces/interfaces_MultipleValidation.IMultipleValidationClient.html +0 -1
- package/docs/interfaces/interfaces_MultipleValidation.MultipleValidationJob.html +0 -1
- package/docs/interfaces/interfaces_MultipleValidation.MultipleValidationJobsListResponse.html +0 -1
- package/docs/interfaces/interfaces_MultipleValidation.MultipleValidationJobsListResult.html +0 -1
- package/docs/interfaces/interfaces_MultipleValidation.PagesList.html +0 -1
- package/docs/interfaces/interfaces_Options.default.html +0 -1
- package/docs/interfaces/interfaces_RequestOptions.default.html +0 -1
- package/docs/interfaces/interfaces_StatsOptions.Stat.html +0 -1
- package/docs/interfaces/interfaces_StatsOptions.StatsOptions.html +0 -1
- package/docs/interfaces/interfaces_StatsOptions.StatsQuery.html +0 -1
- package/docs/interfaces/interfaces_Supressions.BounceData.html +0 -1
- package/docs/interfaces/interfaces_Supressions.ComplaintData.html +0 -1
- package/docs/interfaces/interfaces_Supressions.UnsubscribeData.html +0 -1
- package/docs/interfaces/interfaces_Supressions.WhiteListData.html +0 -1
- package/docs/interfaces/interfaces_Validate.ValidationResponse.html +0 -1
- package/docs/interfaces/interfaces_Validate.ValidationResult.html +0 -1
- package/docs/interfaces/interfaces_Webhooks.APIWebhook.html +0 -1
- package/docs/interfaces/interfaces_Webhooks.ValidationResponse.html +0 -1
- package/docs/interfaces/interfaces_Webhooks.WebhookList.html +0 -1
- package/docs/interfaces/interfaces_Webhooks.WebhookResponse.html +0 -1
- package/docs/interfaces/interfaces_Webhooks.WebhookResponseBody.html +0 -1
- package/docs/interfaces/interfaces_Webhooks.WebhooksQuery.html +0 -1
- package/docs/interfaces/interfaces_lists.CreateUpdateList.html +0 -1
- package/docs/interfaces/interfaces_lists.DestroyedList.html +0 -1
- package/docs/interfaces/interfaces_lists.ListsQuery.html +0 -1
- package/docs/interfaces/interfaces_lists.MailingList.html +0 -1
- package/docs/interfaces/interfaces_mailListMembers.CreateUpdateMailListMembers.html +0 -1
- package/docs/interfaces/interfaces_mailListMembers.CreateUpdateMailListMembersReq.html +0 -1
- package/docs/interfaces/interfaces_mailListMembers.DeletedMember.html +0 -1
- package/docs/interfaces/interfaces_mailListMembers.IMailListsMembers.html +0 -1
- package/docs/interfaces/interfaces_mailListMembers.MailListMember.html +0 -1
- package/docs/interfaces/interfaces_mailListMembers.MailListMembersQuery.html +0 -1
- package/docs/interfaces/interfaces_mailListMembers.MultipleMembersData.html +0 -1
- package/docs/interfaces/interfaces_mailListMembers.MultipleMembersReqData.html +0 -1
- package/docs/interfaces/interfaces_mailListMembers.NewMultipleMembersResponse.html +0 -1
- package/docs/interfaces/interfaces_routes.CreateUpdateRouteData.html +0 -1
- package/docs/interfaces/interfaces_routes.DestroyRouteResponse.html +0 -1
- package/docs/interfaces/interfaces_routes.Route.html +0 -1
- package/docs/interfaces/interfaces_routes.RoutesListQuery.html +0 -1
- package/docs/interfaces/interfaces_routes.UpdateRouteResponse.html +0 -1
- package/docs/modules/client.html +0 -1
- package/docs/modules/domains.html +0 -1
- package/docs/modules/domainsCredentials.html +0 -1
- package/docs/modules/domainsTemplates.html +0 -1
- package/docs/modules/error.html +0 -1
- package/docs/modules/events.html +0 -1
- package/docs/modules/interfaces_APIErrorOptions.html +0 -1
- package/docs/modules/interfaces_ApiResponse.html +0 -1
- package/docs/modules/interfaces_DomainCredentials.html +0 -1
- package/docs/modules/interfaces_DomainTemplates.html +0 -1
- package/docs/modules/interfaces_DomainTracking.html +0 -1
- package/docs/modules/interfaces_Domains.html +0 -1
- package/docs/modules/interfaces_Events.html +0 -1
- package/docs/modules/interfaces_IFormData.html +0 -1
- package/docs/modules/interfaces_IpPools.html +0 -1
- package/docs/modules/interfaces_Ips.html +0 -1
- package/docs/modules/interfaces_MultipleValidation.html +0 -1
- package/docs/modules/interfaces_Options.html +0 -1
- package/docs/modules/interfaces_RequestOptions.html +0 -1
- package/docs/modules/interfaces_StatsOptions.html +0 -1
- package/docs/modules/interfaces_Supressions.html +0 -1
- package/docs/modules/interfaces_Validate.html +0 -1
- package/docs/modules/interfaces_Webhooks.html +0 -1
- package/docs/modules/interfaces_lists.html +0 -1
- package/docs/modules/interfaces_mailListMembers.html +0 -1
- package/docs/modules/interfaces_routes.html +0 -1
- package/docs/modules/ip_pools.html +0 -1
- package/docs/modules/ips.html +0 -1
- package/docs/modules/lists.html +0 -1
- package/docs/modules/mailListMembers.html +0 -1
- package/docs/modules/messages.html +0 -1
- package/docs/modules/multipleValidation.html +0 -1
- package/docs/modules/request.html +0 -1
- package/docs/modules/routes.html +0 -1
- package/docs/modules/stats.html +0 -1
- package/docs/modules/suppressions.html +0 -1
- package/docs/modules/validate.html +0 -1
- package/docs/modules/webhooks.html +0 -1
- package/docs/modules.html +0 -1
- package/dts-bundle.js +0 -8
- package/examples/addresses.js +0 -20
- package/examples/index.html +0 -285
- package/examples/list-domains.js +0 -8
- package/examples/mailgun.png +0 -0
- package/examples/rackspace.png +0 -0
- package/examples/send-email.js +0 -24
- package/lib/client.ts +0 -79
- package/lib/domains.ts +0 -224
- package/lib/domainsCredentials.ts +0 -88
- package/lib/domainsTags.ts +0 -165
- package/lib/domainsTemplates.ts +0 -235
- package/lib/error.ts +0 -22
- package/lib/events.ts +0 -54
- package/lib/index.ts +0 -16
- package/lib/interfaces/APIErrorOptions.ts +0 -10
- package/lib/interfaces/IpPools.ts +0 -22
- package/lib/interfaces/Ips.ts +0 -12
- package/lib/interfaces/Options.ts +0 -10
- package/lib/interfaces/StatsOptions.ts +0 -25
- package/lib/interfaces/Supressions.ts +0 -123
- package/lib/ip-pools.ts +0 -36
- package/lib/ips.ts +0 -24
- package/lib/lists.ts +0 -45
- package/lib/mailListMembers.ts +0 -83
- package/lib/messages.ts +0 -27
- package/lib/multipleValidation.ts +0 -37
- package/lib/request.ts +0 -271
- package/lib/routes.ts +0 -37
- package/lib/stats.ts +0 -62
- package/lib/suppressions.ts +0 -253
- package/lib/validate.ts +0 -20
- package/lib/webhooks.ts +0 -83
- package/test/client.test.ts +0 -96
- package/test/data/emailsValidation1.csv +0 -3
- package/test/domains.test.ts +0 -313
- package/test/domainsCredentials.test.ts +0 -97
- package/test/domainsTags.test.ts +0 -345
- package/test/domainsTemplates.test.ts +0 -392
- package/test/error.test.ts +0 -32
- package/test/events.test.ts +0 -104
- package/test/img/mailgun.png +0 -0
- package/test/ips.test.ts +0 -57
- package/test/lists.test.ts +0 -100
- package/test/mailListMembers.test.ts +0 -198
- package/test/messageAttachment.test.ts +0 -50
- package/test/messages.test.ts +0 -89
- package/test/multipleValidation.test.ts +0 -159
- package/test/request.test.ts +0 -103
- package/test/routes.test.ts +0 -136
- package/test/stats.test.ts +0 -90
- package/test/suppressions.test.ts +0 -303
- package/test/validate.test.ts +0 -43
- package/test/webhooks.test.ts +0 -112
- package/tsconfig.json +0 -22
- package/tsconfig.webpack.json +0 -10
- package/webpack/webpack.common.config.js +0 -46
- package/webpack/webpack.dev.config.js +0 -36
- package/webpack/webpack.release.config.js +0 -45
package/examples/addresses.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
const mailgun = require('../lib/index');
|
|
3
|
-
|
|
4
|
-
const mg = mailgun.client({
|
|
5
|
-
username: 'api',
|
|
6
|
-
key: process.env.MAILGUN_API_KEY || '',
|
|
7
|
-
public_key: process.env.MAILGUN_PUBLIC_KEY || ''
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
mg.validate.get('Alice <alice@example.com>')
|
|
11
|
-
.then((data) => console.log('validate: ', data))
|
|
12
|
-
.catch((err) => console.log(err));
|
|
13
|
-
|
|
14
|
-
mg.parse.get(['Alice <alice@example.com>', 'bob@example.com', 'example.com'])
|
|
15
|
-
.then((data) => console.log('parse: without dns/esp checks', data))
|
|
16
|
-
.catch((err) => console.log(err));
|
|
17
|
-
|
|
18
|
-
mg.parse.get('Alice <alice@example.com>, bob@example.com, example.com', true)
|
|
19
|
-
.then((data) => console.log('parse: with dns/esp checks', data))
|
|
20
|
-
.catch((err) => console.log(err));
|
package/examples/index.html
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html ng-app="app">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
-
<title>Mailgun.js Example</title>
|
|
8
|
-
<link rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css">
|
|
9
|
-
<style media="screen">
|
|
10
|
-
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
|
|
11
|
-
display: none !important;
|
|
12
|
-
}
|
|
13
|
-
.jumbotron,.jumbotron p:last-child,.navbar{margin-bottom:0}body{min-height:75rem}.navbar-collapse .container-fluid{padding:2rem 2.5rem;border-bottom:1px solid #55595c}.navbar-collapse .text-muted,.navbar-collapse h4{color:#818a91}.about{float:left;max-width:30rem;margin-right:3rem}.social a{font-weight:500;color:#eceeef}.social a:hover{color:#fff}.jumbotron{padding-top:6rem;padding-bottom:6rem;background-color:#fff}.jumbotron-heading{font-weight:300}.jumbotron .container{max-width:40rem}footer{padding-top:3rem;padding-bottom:3rem}footer p{margin-bottom:.25rem}
|
|
14
|
-
.album {
|
|
15
|
-
min-height: 50rem; /* Can be removed; just added for demo purposes */
|
|
16
|
-
padding-top: 3rem;
|
|
17
|
-
padding-bottom: 3rem;
|
|
18
|
-
background-color: #f7f7f7;
|
|
19
|
-
}
|
|
20
|
-
.card, .card-header {
|
|
21
|
-
background: white;
|
|
22
|
-
}
|
|
23
|
-
pre {
|
|
24
|
-
background: #f1f1f1;
|
|
25
|
-
padding: .5rem;
|
|
26
|
-
border-radius: 3px;
|
|
27
|
-
}
|
|
28
|
-
.form-control-label {
|
|
29
|
-
text-align: right;
|
|
30
|
-
}
|
|
31
|
-
select.form-control {
|
|
32
|
-
height: 2.6rem;
|
|
33
|
-
}
|
|
34
|
-
.filedropper {
|
|
35
|
-
border: 1px dashed #ccc;
|
|
36
|
-
background: #fff;
|
|
37
|
-
text-align: center;
|
|
38
|
-
padding: 20px;
|
|
39
|
-
font-size: smaller;
|
|
40
|
-
width: 100%;
|
|
41
|
-
}
|
|
42
|
-
</style>
|
|
43
|
-
</head>
|
|
44
|
-
<body ng-controller="MainCtrl" ng-cloak>
|
|
45
|
-
<section class="jumbotron text-center">
|
|
46
|
-
<div class="container">
|
|
47
|
-
<p class="lead">
|
|
48
|
-
<img src="https://mailgun.github.io/media/Mailgun_Icon.png" alt="" width="100px" />
|
|
49
|
-
</p>
|
|
50
|
-
<h1 class="jumbotron-heading display-2">Mailgun.js</h1>
|
|
51
|
-
<p class="lead">
|
|
52
|
-
A javascript sdk for Mailgun built with webpack, babel & es6.
|
|
53
|
-
</p>
|
|
54
|
-
<hr>
|
|
55
|
-
<p class="text-muted">
|
|
56
|
-
For this demo to work, you'll need to install and run `http-proxy` locally. Install it with:</p>
|
|
57
|
-
<pre>npm install -g http-proxy</pre>
|
|
58
|
-
<p class="text-muted">then run the following command:</p>
|
|
59
|
-
<pre>http-server -p 4001 --proxy="https://api.mailgun.net"</pre>
|
|
60
|
-
<p class="text-muted">then load up this page from <a href="http://0.0.0.0:4001/examples/">0.0.0.0:4001/examples/</a></p>
|
|
61
|
-
<p class="text-muted">Last but not least, enter your Mailgun private key below and click create client to fetch the domains for your account.</p>
|
|
62
|
-
|
|
63
|
-
<form class="form-inline">
|
|
64
|
-
<div class="form-group">
|
|
65
|
-
<label class="sr-only" for="key">Password</label>
|
|
66
|
-
<input ng-model="form.key" type="password" class="form-control" id="key" placeholder="key-xxxxxxxxxxxxxx">
|
|
67
|
-
</div>
|
|
68
|
-
<button type="submit" class="btn btn-danger" ng-click="setClient()">Create Client</button>
|
|
69
|
-
</form>
|
|
70
|
-
</div>
|
|
71
|
-
</section>
|
|
72
|
-
|
|
73
|
-
<div class="album text-muted">
|
|
74
|
-
<div class="container">
|
|
75
|
-
<div class="row">
|
|
76
|
-
<div class="col-md-8 col-md-offset-2">
|
|
77
|
-
<h1 class="display-1 text-center">Email example</h1>
|
|
78
|
-
<hr>
|
|
79
|
-
<form name="emailForm" novalidate="">
|
|
80
|
-
<div class="form-group row">
|
|
81
|
-
<label for="domains" class="col-sm-3 form-control-label">Sending Domain</label>
|
|
82
|
-
<div class="col-sm-9">
|
|
83
|
-
<select class="form-control" ng-change="updateDomain()" ng-model="emailForm.selectedDomain" id="domains" ng-options="item.name for item in domains"></select>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
<div class="form-group row">
|
|
87
|
-
<label for="from" class="col-sm-3 form-control-label">From</label>
|
|
88
|
-
<div class="col-sm-9">
|
|
89
|
-
<input type="text" class="form-control" id="from" ng-model="emailForm.from" placeholder="you@example.com" novalidate>
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
<div class="form-group row">
|
|
93
|
-
<label for="to" class="col-sm-3 form-control-label">To</label>
|
|
94
|
-
<div class="col-sm-9">
|
|
95
|
-
<input type="text" class="form-control" ng-model="emailForm.to" id="to" placeholder="test@example.com" novalidate>
|
|
96
|
-
</div>
|
|
97
|
-
</div>
|
|
98
|
-
<div class="form-group row">
|
|
99
|
-
<label for="subject" class="col-sm-3 form-control-label">Subject</label>
|
|
100
|
-
<div class="col-sm-9">
|
|
101
|
-
<input type="text" class="form-control" ng-model="emailForm.subject" id="subject" placeholder="Mailgun Test" novalidate>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
<div class="form-group row">
|
|
105
|
-
<label for="html" class="col-sm-3 form-control-label">HTML</label>
|
|
106
|
-
<div class="col-sm-9">
|
|
107
|
-
<textarea ng-model="emailForm.html" class="form-control" id="html" rows="3"></textarea>
|
|
108
|
-
</div>
|
|
109
|
-
</div>
|
|
110
|
-
<div class="form-group row">
|
|
111
|
-
<label for="text" class="col-sm-3 form-control-label">Text</label>
|
|
112
|
-
<div class="col-sm-9">
|
|
113
|
-
<textarea ng-model="emailForm.text" class="form-control" id="text" rows="3"></textarea>
|
|
114
|
-
</div>
|
|
115
|
-
</div>
|
|
116
|
-
<div class="form-group row">
|
|
117
|
-
<label for="inline" class="col-sm-3 form-control-label">Inline Media</label>
|
|
118
|
-
<div class="col-sm-9">
|
|
119
|
-
<input type="file" class="form-control-file sr-only" id="inline" file-model="emailForm.inline" multiple>
|
|
120
|
-
<label for="inline" class="filedropper" dropper-model="emailForm.inline">
|
|
121
|
-
Drop Inline Images Here
|
|
122
|
-
</label>
|
|
123
|
-
<span ng-if="emailForm.inline.length > 0"><small>Use the following in the html section:</small></span>
|
|
124
|
-
<span ng-repeat="f in emailForm.inline"><br><small><code><img src="cid:{{f.name}}" width="200px"></code></small></span>
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
<div class="form-group row">
|
|
128
|
-
<label for="attachment" class="col-sm-3 form-control-label">Attachments</label>
|
|
129
|
-
<div class="col-sm-9">
|
|
130
|
-
<input type="file" class="form-control-file sr-only" id="attachment" file-model="emailForm.attachment" multiple>
|
|
131
|
-
<label for="attachment" class="filedropper" dropper-model="emailForm.attachment">
|
|
132
|
-
Drop Attachments Here
|
|
133
|
-
</label>
|
|
134
|
-
<span ng-repeat="f in emailForm.attachment"><br><small>{{f.name}}</small></span>
|
|
135
|
-
</div>
|
|
136
|
-
</div>
|
|
137
|
-
<div class="form-group row">
|
|
138
|
-
<div class="col-sm-push-3 col-sm-9">
|
|
139
|
-
<button type="submit" class="btn btn-danger" ng-click="sendEmail()" ng-disabled="btnDisabled">Send Email</button>
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
<hr>
|
|
143
|
-
<p>
|
|
144
|
-
Response:
|
|
145
|
-
</p>
|
|
146
|
-
<pre><code>{{ response | json }}</code></pre>
|
|
147
|
-
|
|
148
|
-
</form>
|
|
149
|
-
</div>
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
</div>
|
|
153
|
-
|
|
154
|
-
<footer class="text-muted">
|
|
155
|
-
<div class="container text-center">
|
|
156
|
-
<p><a href="https://github.com/mailgun/mailgun-js">https://github.com/mailgun/mailgun-js</a></p>
|
|
157
|
-
</div>
|
|
158
|
-
</footer>
|
|
159
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.2/angular.min.js"></script>
|
|
160
|
-
<script src="../dist/mailgun.js" charset="utf-8"></script>
|
|
161
|
-
<script type="text/javascript">
|
|
162
|
-
var app = angular.module("app", []);
|
|
163
|
-
|
|
164
|
-
app.directive('fileModel', ['$parse', function ($parse) {
|
|
165
|
-
return {
|
|
166
|
-
restrict: 'A',
|
|
167
|
-
link: function(scope, element, attrs) {
|
|
168
|
-
var model = $parse(attrs.fileModel);
|
|
169
|
-
var modelSetter = model.assign;
|
|
170
|
-
|
|
171
|
-
element.bind('change', function(){
|
|
172
|
-
var files = []
|
|
173
|
-
|
|
174
|
-
for (var i = 0; i < element[0].files.length; i++) {
|
|
175
|
-
files.push(element[0].files[i]);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
scope.$apply(function(){
|
|
179
|
-
modelSetter(scope, files);
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
}]);
|
|
185
|
-
|
|
186
|
-
app.directive('dropperModel', ['$parse', function ($parse) {
|
|
187
|
-
return {
|
|
188
|
-
restrict: 'A',
|
|
189
|
-
link: function(scope, element, attrs) {
|
|
190
|
-
var model = $parse(attrs.dropperModel);
|
|
191
|
-
var modelSetter = model.assign;
|
|
192
|
-
|
|
193
|
-
function drop(e){
|
|
194
|
-
e.stopPropagation();
|
|
195
|
-
e.preventDefault();
|
|
196
|
-
|
|
197
|
-
var files = []
|
|
198
|
-
|
|
199
|
-
for (var i = 0; i < e.dataTransfer.files.length; i++) {
|
|
200
|
-
files.push(e.dataTransfer.files[i]);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
scope.$apply(function(){
|
|
204
|
-
modelSetter(scope, files);
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function dragover(e) {
|
|
209
|
-
e.stopPropagation();
|
|
210
|
-
e.preventDefault();
|
|
211
|
-
e.dataTransfer.dropEffect = 'copy';
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
element[0].addEventListener('dragover', dragover, false);
|
|
215
|
-
element[0].addEventListener('drop', drop, false);
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
}]);
|
|
219
|
-
|
|
220
|
-
app.controller("MainCtrl", function($scope) {
|
|
221
|
-
$scope.mg = null;
|
|
222
|
-
$scope.domains = [];
|
|
223
|
-
$scope.form = {
|
|
224
|
-
key: ''
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
$scope.emailForm = $scope.emailForm || {};
|
|
228
|
-
$scope.emailForm.subject = 'Hello from Mailgun!';
|
|
229
|
-
|
|
230
|
-
$scope.setClient = function() {
|
|
231
|
-
if($scope.form.key){
|
|
232
|
-
$scope.mg = mailgun.client({url: 'http://0.0.0.0:4001', username: 'api', key: $scope.form.key});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
$scope.mg.domains.list()
|
|
236
|
-
.then(domains => {
|
|
237
|
-
$scope.domains = domains;
|
|
238
|
-
$scope.emailForm.selectedDomain = $scope.domains[0];
|
|
239
|
-
$scope.updateDomain();
|
|
240
|
-
$scope.$apply();
|
|
241
|
-
})
|
|
242
|
-
.catch(err => console.log(err));
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
$scope.updateDomain = function(){
|
|
246
|
-
if($scope.emailForm.selectedDomain){
|
|
247
|
-
$scope.emailForm.from = 'Excited User <mailgun@' + $scope.emailForm.selectedDomain.name + '>';
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
$scope.sendEmail = function() {
|
|
252
|
-
if(!$scope.mg && !$scope.emailForm.selectedDomain){
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
$scope.btnDisabled = true;
|
|
257
|
-
|
|
258
|
-
var data = {
|
|
259
|
-
to: $scope.emailForm.to,
|
|
260
|
-
from: $scope.emailForm.from,
|
|
261
|
-
subject: $scope.emailForm.subject,
|
|
262
|
-
html: $scope.emailForm.html,
|
|
263
|
-
text: $scope.emailForm.text,
|
|
264
|
-
inline: $scope.emailForm.inline,
|
|
265
|
-
attachment: $scope.emailForm.attachment
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
var domain = $scope.emailForm.selectedDomain.name;
|
|
269
|
-
|
|
270
|
-
$scope.mg.messages.create(domain, data)
|
|
271
|
-
.then(response => {
|
|
272
|
-
$scope.response = response;
|
|
273
|
-
$scope.btnDisabled = false;
|
|
274
|
-
$scope.$apply();
|
|
275
|
-
})
|
|
276
|
-
.catch(err => {
|
|
277
|
-
$scope.btnDisabled = false;
|
|
278
|
-
$scope.response = err;
|
|
279
|
-
$scope.$apply();
|
|
280
|
-
})
|
|
281
|
-
};
|
|
282
|
-
});
|
|
283
|
-
</script>
|
|
284
|
-
</body>
|
|
285
|
-
</html>
|
package/examples/list-domains.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
const mailgun = require('../lib/index');
|
|
3
|
-
|
|
4
|
-
const mg = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY || '' });
|
|
5
|
-
|
|
6
|
-
mg.domains.list()
|
|
7
|
-
.then((domains) => console.log(domains))
|
|
8
|
-
.catch((err) => console.log(err));
|
package/examples/mailgun.png
DELETED
|
Binary file
|
package/examples/rackspace.png
DELETED
|
Binary file
|
package/examples/send-email.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const mailgun = require('../lib/index');
|
|
4
|
-
|
|
5
|
-
const mg = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY || '', timeout: 60000 });
|
|
6
|
-
|
|
7
|
-
const domain = 'sandbox-123.mailgun.com';
|
|
8
|
-
const fromEmail = 'Excited User <mailgun@sandbox-123.mailgun.com>';
|
|
9
|
-
const toEmails = ['you@example.com'];
|
|
10
|
-
|
|
11
|
-
const mailgunLogo = fs.createReadStream(`${__dirname}/mailgun.png`);
|
|
12
|
-
const rackspaceLogo = fs.createReadStream(`${__dirname}/rackspace.png`);
|
|
13
|
-
|
|
14
|
-
mg.messages.create(domain, {
|
|
15
|
-
from: fromEmail,
|
|
16
|
-
to: toEmails,
|
|
17
|
-
subject: 'Hello',
|
|
18
|
-
html: '<img src="cid:mailgun.png" width="200px"><br><h3>Testing some Mailgun awesomness!</h3>',
|
|
19
|
-
text: 'Testing some Mailgun awesomness!',
|
|
20
|
-
inline: [mailgunLogo],
|
|
21
|
-
attachment: [rackspaceLogo]
|
|
22
|
-
})
|
|
23
|
-
.then((msg) => console.log(msg))
|
|
24
|
-
.catch((err) => console.log(err));
|
package/lib/client.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
|
-
import Request from './request';
|
|
3
|
-
import Options from './interfaces/Options';
|
|
4
|
-
import RequestOptions from './interfaces/RequestOptions';
|
|
5
|
-
|
|
6
|
-
import DomainClient from './domains';
|
|
7
|
-
import EventClient from './events';
|
|
8
|
-
import StatsClient from './stats';
|
|
9
|
-
import SuppressionClient from './suppressions';
|
|
10
|
-
import WebhookClient from './webhooks';
|
|
11
|
-
import MessagesClient from './messages';
|
|
12
|
-
import RoutesClient from './routes';
|
|
13
|
-
import ValidateClient from './validate';
|
|
14
|
-
import IpsClient from './ips';
|
|
15
|
-
import IpPoolsClient from './ip-pools';
|
|
16
|
-
import ListsClient from './lists';
|
|
17
|
-
import MailListsMembers from './mailListMembers';
|
|
18
|
-
import { InputFormData } from './interfaces/IFormData';
|
|
19
|
-
import DomainCredentialsClient from './domainsCredentials';
|
|
20
|
-
import MultipleValidationClient from './multipleValidation';
|
|
21
|
-
import DomainTemplatesClient from './domainsTemplates';
|
|
22
|
-
import DomainTagsClient from './domainsTags';
|
|
23
|
-
|
|
24
|
-
export default class Client {
|
|
25
|
-
private request;
|
|
26
|
-
|
|
27
|
-
public domains;
|
|
28
|
-
public webhooks;
|
|
29
|
-
public events;
|
|
30
|
-
public stats;
|
|
31
|
-
public suppressions;
|
|
32
|
-
public messages;
|
|
33
|
-
public routes;
|
|
34
|
-
public validate;
|
|
35
|
-
public ips;
|
|
36
|
-
public ip_pools;
|
|
37
|
-
public lists;
|
|
38
|
-
|
|
39
|
-
constructor(options: Options, formData: InputFormData) {
|
|
40
|
-
const config: RequestOptions = { ...options } as RequestOptions;
|
|
41
|
-
|
|
42
|
-
if (!config.url) {
|
|
43
|
-
config.url = 'https://api.mailgun.net';
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (!config.username) {
|
|
47
|
-
throw new Error('Parameter "username" is required');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!config.key) {
|
|
51
|
-
throw new Error('Parameter "key" is required');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** @internal */
|
|
55
|
-
this.request = new Request(config, formData);
|
|
56
|
-
const mailListsMembers = new MailListsMembers(this.request);
|
|
57
|
-
const domainCredentialsClient = new DomainCredentialsClient(this.request);
|
|
58
|
-
const domainTemplatesClient = new DomainTemplatesClient(this.request);
|
|
59
|
-
const domainTagsClient = new DomainTagsClient(this.request);
|
|
60
|
-
const multipleValidationClient = new MultipleValidationClient(this.request);
|
|
61
|
-
|
|
62
|
-
this.domains = new DomainClient(
|
|
63
|
-
this.request,
|
|
64
|
-
domainCredentialsClient,
|
|
65
|
-
domainTemplatesClient,
|
|
66
|
-
domainTagsClient
|
|
67
|
-
);
|
|
68
|
-
this.webhooks = new WebhookClient(this.request);
|
|
69
|
-
this.events = new EventClient(this.request);
|
|
70
|
-
this.stats = new StatsClient(this.request);
|
|
71
|
-
this.suppressions = new SuppressionClient(this.request);
|
|
72
|
-
this.messages = new MessagesClient(this.request);
|
|
73
|
-
this.routes = new RoutesClient(this.request);
|
|
74
|
-
this.ips = new IpsClient(this.request);
|
|
75
|
-
this.ip_pools = new IpPoolsClient(this.request);
|
|
76
|
-
this.lists = new ListsClient(this.request, mailListsMembers);
|
|
77
|
-
this.validate = new ValidateClient(this.request, multipleValidationClient);
|
|
78
|
-
}
|
|
79
|
-
}
|
package/lib/domains.ts
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
|
-
import urljoin from 'url-join';
|
|
3
|
-
import {
|
|
4
|
-
DomainResponseData,
|
|
5
|
-
DestroyedDomainResponse,
|
|
6
|
-
DomainsQuery,
|
|
7
|
-
DomainInfo,
|
|
8
|
-
DomainListResponseData,
|
|
9
|
-
DomainShortData,
|
|
10
|
-
DNSRecord,
|
|
11
|
-
ConnectionSettingsResponse,
|
|
12
|
-
ConnectionSettings,
|
|
13
|
-
UpdatedConnectionSettings,
|
|
14
|
-
UpdatedConnectionSettingsRes,
|
|
15
|
-
DKIMAuthorityInfo,
|
|
16
|
-
UpdatedDKIMAuthority,
|
|
17
|
-
UpdatedDKIMAuthorityResponse,
|
|
18
|
-
DKIMSelectorInfo,
|
|
19
|
-
UpdatedDKIMSelectorResponse,
|
|
20
|
-
WebPrefixInfo,
|
|
21
|
-
UpdatedWebPrefixResponse,
|
|
22
|
-
ReplacementForPool,
|
|
23
|
-
MessageResponse,
|
|
24
|
-
} from './interfaces/Domains';
|
|
25
|
-
|
|
26
|
-
import APIResponse from './interfaces/ApiResponse';
|
|
27
|
-
import APIError from './error';
|
|
28
|
-
import APIErrorOptions from './interfaces/APIErrorOptions';
|
|
29
|
-
|
|
30
|
-
import Request from './request';
|
|
31
|
-
import {
|
|
32
|
-
DomainTrackingResponse,
|
|
33
|
-
DomainTrackingData,
|
|
34
|
-
OpenTrackingInfo,
|
|
35
|
-
ClickTrackingInfo,
|
|
36
|
-
UnsubscribeTrackingInfo,
|
|
37
|
-
UpdateDomainTrackingResponse,
|
|
38
|
-
UpdatedOpenTracking
|
|
39
|
-
} from './interfaces/DomainTracking';
|
|
40
|
-
import { IDomainCredentials } from './interfaces/DomainCredentials';
|
|
41
|
-
import { IDomainTemplatesClient } from './interfaces/DomainTemplates';
|
|
42
|
-
import DomainCredentialsClient from './domainsCredentials';
|
|
43
|
-
import DomainTemplatesClient from './domainsTemplates';
|
|
44
|
-
import { IDomainTagsClient } from './interfaces/DomainTags';
|
|
45
|
-
import DomainTagsClient from './domainsTags';
|
|
46
|
-
|
|
47
|
-
export class Domain {
|
|
48
|
-
name: string;
|
|
49
|
-
require_tls: boolean;
|
|
50
|
-
skip_verification: boolean;
|
|
51
|
-
state: string;
|
|
52
|
-
wildcard: boolean;
|
|
53
|
-
spam_action: string;
|
|
54
|
-
created_at: string;
|
|
55
|
-
smtp_password: string;
|
|
56
|
-
smtp_login: string;
|
|
57
|
-
type: string;
|
|
58
|
-
receiving_dns_records: DNSRecord[] | null;
|
|
59
|
-
sending_dns_records: DNSRecord[] | null;
|
|
60
|
-
|
|
61
|
-
constructor(data: DomainShortData, receiving?: DNSRecord[] | null, sending?: DNSRecord[] | null) {
|
|
62
|
-
this.name = data.name;
|
|
63
|
-
this.require_tls = data.require_tls;
|
|
64
|
-
this.skip_verification = data.skip_verification;
|
|
65
|
-
this.state = data.state;
|
|
66
|
-
this.wildcard = data.wildcard;
|
|
67
|
-
this.spam_action = data.spam_action;
|
|
68
|
-
this.created_at = data.created_at;
|
|
69
|
-
this.smtp_password = data.smtp_password;
|
|
70
|
-
this.smtp_login = data.smtp_login;
|
|
71
|
-
this.type = data.type;
|
|
72
|
-
|
|
73
|
-
this.receiving_dns_records = receiving || null;
|
|
74
|
-
this.sending_dns_records = sending || null;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default class DomainClient {
|
|
79
|
-
request: Request;
|
|
80
|
-
public domainCredentials: IDomainCredentials;
|
|
81
|
-
public domainTemplates: IDomainTemplatesClient;
|
|
82
|
-
public domainTags: IDomainTagsClient;
|
|
83
|
-
|
|
84
|
-
constructor(
|
|
85
|
-
request: Request,
|
|
86
|
-
domainCredentialsClient: DomainCredentialsClient,
|
|
87
|
-
domainTemplatesClient: DomainTemplatesClient,
|
|
88
|
-
domainTagsClient: DomainTagsClient
|
|
89
|
-
) {
|
|
90
|
-
this.request = request;
|
|
91
|
-
this.domainCredentials = domainCredentialsClient;
|
|
92
|
-
this.domainTemplates = domainTemplatesClient;
|
|
93
|
-
this.domainTags = domainTagsClient;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
private _parseMessage(response: DestroyedDomainResponse) : MessageResponse {
|
|
97
|
-
return response.body;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private _parseDomainList(response: DomainListResponseData): Domain[] {
|
|
101
|
-
return response.body.items.map(function (item) {
|
|
102
|
-
return new Domain(item);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
private _parseDomain(response: DomainResponseData): Domain {
|
|
107
|
-
return new Domain(
|
|
108
|
-
response.body.domain,
|
|
109
|
-
response.body.receiving_dns_records,
|
|
110
|
-
response.body.sending_dns_records
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private _parseTrackingSettings(response: DomainTrackingResponse) : DomainTrackingData {
|
|
115
|
-
return response.body.tracking;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private _parseTrackingUpdate(response: UpdateDomainTrackingResponse) :UpdatedOpenTracking {
|
|
119
|
-
return response.body;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
list(query?: DomainsQuery): Promise<Domain[]> {
|
|
123
|
-
return this.request.get('/v3/domains', query)
|
|
124
|
-
.then((res : APIResponse) => this._parseDomainList(res as DomainListResponseData));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
get(domain: string) : Promise<Domain> {
|
|
128
|
-
return this.request.get(`/v3/domains/${domain}`)
|
|
129
|
-
.then((res : APIResponse) => this._parseDomain(res as DomainResponseData));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
create(data: DomainInfo) : Promise<Domain> {
|
|
133
|
-
const postObj = { ...data };
|
|
134
|
-
if ('force_dkim_authority' in postObj && typeof postObj.force_dkim_authority === 'boolean') {
|
|
135
|
-
postObj.force_dkim_authority = postObj.toString() === 'true' ? 'true' : 'false';
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return this.request.postWithFD('/v3/domains', postObj)
|
|
139
|
-
.then((res : APIResponse) => this._parseDomain(res as DomainResponseData));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
destroy(domain: string): Promise<MessageResponse> {
|
|
143
|
-
return this.request.delete(`/v3/domains/${domain}`)
|
|
144
|
-
.then((res : APIResponse) => this._parseMessage(res as DestroyedDomainResponse));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
getConnection(domain: string): Promise<ConnectionSettings> {
|
|
148
|
-
return this.request.get(`/v3/domains/${domain}/connection`)
|
|
149
|
-
.then((res : APIResponse) => res as ConnectionSettingsResponse)
|
|
150
|
-
.then((res:ConnectionSettingsResponse) => res.body.connection as ConnectionSettings);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
updateConnection(domain: string, data: ConnectionSettings): Promise<UpdatedConnectionSettings> {
|
|
154
|
-
return this.request.put(`/v3/domains/${domain}/connection`, data)
|
|
155
|
-
.then((res : APIResponse) => res as UpdatedConnectionSettingsRes)
|
|
156
|
-
.then((res:UpdatedConnectionSettingsRes) => res.body as UpdatedConnectionSettings);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Tracking
|
|
160
|
-
|
|
161
|
-
getTracking(domain: string) : Promise<DomainTrackingData> {
|
|
162
|
-
return this.request.get(urljoin('/v3/domains', domain, 'tracking'))
|
|
163
|
-
.then(this._parseTrackingSettings);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
updateTracking(
|
|
167
|
-
domain: string,
|
|
168
|
-
type: string,
|
|
169
|
-
data: OpenTrackingInfo | ClickTrackingInfo | UnsubscribeTrackingInfo
|
|
170
|
-
): Promise<UpdatedOpenTracking> {
|
|
171
|
-
if (typeof data?.active === 'boolean') {
|
|
172
|
-
throw new APIError({ status: 400, statusText: '', body: { message: 'Property "active" must contain string value.' } } as APIErrorOptions);
|
|
173
|
-
}
|
|
174
|
-
return this.request.putWithFD(urljoin('/v3/domains', domain, 'tracking', type), data)
|
|
175
|
-
.then((res : APIResponse) => this._parseTrackingUpdate(res as UpdateDomainTrackingResponse));
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// IPs
|
|
179
|
-
|
|
180
|
-
getIps(domain: string): Promise<string[]> {
|
|
181
|
-
return this.request.get(urljoin('/v3/domains', domain, 'ips'))
|
|
182
|
-
.then((response: APIResponse) => response?.body?.items);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
assignIp(domain: string, ip: string): Promise<APIResponse> {
|
|
186
|
-
return this.request.postWithFD(urljoin('/v3/domains', domain, 'ips'), { ip });
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
deleteIp(domain: string, ip: string): Promise<APIResponse> {
|
|
190
|
-
return this.request.delete(urljoin('/v3/domains', domain, 'ips', ip));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
linkIpPool(domain: string, pool_id: string): Promise<APIResponse> {
|
|
194
|
-
return this.request.postWithFD(urljoin('/v3/domains', domain, 'ips'), { pool_id });
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
unlinkIpPoll(domain: string, replacement: ReplacementForPool): Promise<APIResponse> {
|
|
198
|
-
let searchParams = '';
|
|
199
|
-
if (replacement.pool_id && replacement.ip) {
|
|
200
|
-
throw new APIError({ status: 400, statusText: '', body: { message: 'Please specify either pool_id or ip (not both)' } } as APIErrorOptions);
|
|
201
|
-
} else if (replacement.pool_id) {
|
|
202
|
-
searchParams = `?pool_id=${replacement.pool_id}`;
|
|
203
|
-
} else if (replacement.ip) {
|
|
204
|
-
searchParams = `?ip=${replacement.ip}`;
|
|
205
|
-
}
|
|
206
|
-
return this.request.delete(urljoin('/v3/domains', domain, 'ips', 'ip_pool', searchParams));
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
updateDKIMAuthority(domain: string, data: DKIMAuthorityInfo): Promise<UpdatedDKIMAuthority> {
|
|
210
|
-
return this.request.put(`/v3/domains/${domain}/dkim_authority`, {}, { query: `self=${data.self}` })
|
|
211
|
-
.then((res : APIResponse) => res as UpdatedDKIMAuthorityResponse)
|
|
212
|
-
.then((res : UpdatedDKIMAuthorityResponse) => res.body as UpdatedDKIMAuthority);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
updateDKIMSelector(domain: string, data: DKIMSelectorInfo): Promise<UpdatedDKIMSelectorResponse> {
|
|
216
|
-
return this.request.put(`/v3/domains/${domain}/dkim_selector`, {}, { query: `dkim_selector=${data.dkimSelector}` })
|
|
217
|
-
.then((res : APIResponse) => res as UpdatedDKIMSelectorResponse);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
updateWebPrefix(domain: string, data: WebPrefixInfo): Promise<UpdatedWebPrefixResponse> {
|
|
221
|
-
return this.request.put(`/v3/domains/${domain}/web_prefix`, {}, { query: `web_prefix=${data.webPrefix}` })
|
|
222
|
-
.then((res : APIResponse) => res as UpdatedWebPrefixResponse);
|
|
223
|
-
}
|
|
224
|
-
}
|