mailgun.js 5.0.1 → 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 +30 -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 -83
- 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} +32 -53
- package/{lib/interfaces/Events.ts → interfaces/Events.d.ts} +11 -12
- package/interfaces/IFormData.d.ts +7 -0
- 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 -3
- package/messages.d.ts +9 -0
- package/multipleValidation.d.ts +10 -0
- package/package.json +9 -83
- 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 -1572
- 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 -17
- package/lib/interfaces/APIErrorOptions.ts +0 -10
- package/lib/interfaces/IFormData.ts +0 -9
- 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 -23
- package/lib/interfaces/Supressions.ts +0 -86
- 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 -198
- 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 -219
- 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 -47
- package/webpack/webpack.dev.config.js +0 -28
- package/webpack/webpack.release.config.js +0 -37
package/test/routes.test.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
|
-
import formData from 'form-data';
|
|
3
|
-
import nock from 'nock';
|
|
4
|
-
import Request from '../lib/request';
|
|
5
|
-
import RoutesClient from '../lib/routes';
|
|
6
|
-
import RequestOptions from '../lib/interfaces/RequestOptions';
|
|
7
|
-
import { InputFormData } from '../lib/interfaces/IFormData';
|
|
8
|
-
|
|
9
|
-
interface Data {
|
|
10
|
-
actions: string[],
|
|
11
|
-
created_at: string,
|
|
12
|
-
description: string,
|
|
13
|
-
expression: string,
|
|
14
|
-
id: string,
|
|
15
|
-
priority: number
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
describe('RoutesClient', function () {
|
|
19
|
-
let client: any;
|
|
20
|
-
let api: any;
|
|
21
|
-
|
|
22
|
-
beforeEach(function () {
|
|
23
|
-
client = new RoutesClient(new Request({ url: 'https://api.mailgun.net' } as RequestOptions, formData as InputFormData));
|
|
24
|
-
api = nock('https://api.mailgun.net');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
afterEach(function () {
|
|
28
|
-
api.done();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('list', function () {
|
|
32
|
-
const data = [
|
|
33
|
-
{
|
|
34
|
-
actions: ['forward("http://myhost.com/messages/")', 'stop()'],
|
|
35
|
-
created_at: 'Mon, 26 Oct 2015 03:56:51 GMT',
|
|
36
|
-
description: 'sample',
|
|
37
|
-
expression: 'match_recipient(".*@example.com")',
|
|
38
|
-
id: '562da483125730608a7d1719',
|
|
39
|
-
priority: 0
|
|
40
|
-
}
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
it('fetches all routes', function () {
|
|
44
|
-
api.get('/v3/routes').reply(200, {
|
|
45
|
-
items: data
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
return client.list().then(function (response: Data[]) {
|
|
49
|
-
response.should.eql(data);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe('get', function () {
|
|
55
|
-
it('fetches single route by id', function () {
|
|
56
|
-
const data = {
|
|
57
|
-
actions: ['forward("http://myhost.com/messages/")', 'stop()'],
|
|
58
|
-
created_at: 'Mon, 26 Oct 2015 03:56:51 GMT',
|
|
59
|
-
description: 'sample',
|
|
60
|
-
expression: 'match_recipient(".*@example.com")',
|
|
61
|
-
id: '562da483125730608a7d1719',
|
|
62
|
-
priority: 0
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
api.get('/v3/routes/123').reply(200, { route: data });
|
|
66
|
-
|
|
67
|
-
return client.get('123').then(function (response: Data) {
|
|
68
|
-
response.should.eql(data);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe('create', function () {
|
|
74
|
-
it('creates route', function () {
|
|
75
|
-
const data = {
|
|
76
|
-
actions: ['forward("http://myhost.com/messages/")', 'stop()'],
|
|
77
|
-
created_at: 'Mon, 26 Oct 2015 03:56:51 GMT',
|
|
78
|
-
description: 'sample',
|
|
79
|
-
expression: 'match_recipient(".*@example.com")',
|
|
80
|
-
id: '562da483125730608a7d1719',
|
|
81
|
-
priority: 0
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
api.post('/v3/routes').reply(200, { route: data });
|
|
85
|
-
|
|
86
|
-
return client.create({
|
|
87
|
-
priority: 0,
|
|
88
|
-
description: 'sample',
|
|
89
|
-
expression: 'match_recipient(".*@example.org")',
|
|
90
|
-
action: ['forward("http://myhost.com/messages/")', 'stop()']
|
|
91
|
-
}).then(function (response: Data) {
|
|
92
|
-
response.should.eql(data);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
describe('update', function () {
|
|
98
|
-
it('updates route', function () {
|
|
99
|
-
const data = {
|
|
100
|
-
actions: ['forward("http://myhost.com/messages/")', 'stop()'],
|
|
101
|
-
created_at: 'Mon, 26 Oct 2015 03:56:51 GMT',
|
|
102
|
-
description: 'sample',
|
|
103
|
-
expression: 'match_recipient(".*@example.com")',
|
|
104
|
-
id: '562da483125730608a7d1719',
|
|
105
|
-
priority: 0,
|
|
106
|
-
message: 'Route has been updated',
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
api.put('/v3/routes/123').reply(200, { data });
|
|
110
|
-
|
|
111
|
-
return client.update('123', {
|
|
112
|
-
priority: 0,
|
|
113
|
-
description: 'sample',
|
|
114
|
-
expression: 'match_recipient(".*@example.org")',
|
|
115
|
-
action: ['forward("http://myhost.com/messages/")', 'stop()']
|
|
116
|
-
}).then(function (response: Data) {
|
|
117
|
-
response.should.eql({ data });
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('destroy', function () {
|
|
123
|
-
it('deletes route', function () {
|
|
124
|
-
const data = {
|
|
125
|
-
id: '562da483125730608a7d1719',
|
|
126
|
-
message: 'Route has been deleted'
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
api.delete('/v3/routes/123').reply(200, { data });
|
|
130
|
-
|
|
131
|
-
return client.destroy('123').then(function (response: Data) {
|
|
132
|
-
response.should.eql({ data });
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
});
|
package/test/stats.test.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import formData from 'form-data';
|
|
2
|
-
|
|
3
|
-
import nock from 'nock';
|
|
4
|
-
import Request from '../lib/request';
|
|
5
|
-
import StatsClient from '../lib/stats';
|
|
6
|
-
import RequestOptions from '../lib/interfaces/RequestOptions';
|
|
7
|
-
import { StatsOptions } from '../lib/interfaces/StatsOptions';
|
|
8
|
-
import { InputFormData } from '../lib/interfaces/IFormData';
|
|
9
|
-
|
|
10
|
-
describe('StatsClient', function () {
|
|
11
|
-
let client: any;
|
|
12
|
-
let api: any;
|
|
13
|
-
|
|
14
|
-
beforeEach(function () {
|
|
15
|
-
client = new StatsClient(new Request({ url: 'https://api.mailgun.net' } as RequestOptions, formData as InputFormData));
|
|
16
|
-
api = nock('https://api.mailgun.net');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
afterEach(function () {
|
|
20
|
-
api.done();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe('getDomain', function () {
|
|
24
|
-
const query = { event: 'delivered' };
|
|
25
|
-
|
|
26
|
-
it('fetches stats for a given domain', function () {
|
|
27
|
-
api.get('/v3/domain.com/stats/total')
|
|
28
|
-
.query(query)
|
|
29
|
-
.reply(200, {
|
|
30
|
-
end: 'Mon, 23 Mar 2015 00:00:00 UTC',
|
|
31
|
-
resolution: 'day',
|
|
32
|
-
start: 'Mon, 16 Mar 2015 00:00:00 UTC',
|
|
33
|
-
stats: [
|
|
34
|
-
{
|
|
35
|
-
time: 'Mon, 16 Mar 2015 00:00:00 UTC',
|
|
36
|
-
delivered: {
|
|
37
|
-
smtp: 2,
|
|
38
|
-
http: 1,
|
|
39
|
-
total: 3
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return client.getDomain('domain.com', query).then(function (stats: StatsOptions) {
|
|
46
|
-
(stats.start as Date).toUTCString().should.eql('Mon, 16 Mar 2015 00:00:00 GMT');
|
|
47
|
-
(stats.end as Date).toUTCString().should.eql('Mon, 23 Mar 2015 00:00:00 GMT');
|
|
48
|
-
|
|
49
|
-
(stats.stats[0].time as Date).toUTCString().should.eql('Mon, 16 Mar 2015 00:00:00 GMT');
|
|
50
|
-
stats.stats[0].delivered.http.should.eql(1);
|
|
51
|
-
stats.stats[0].delivered.smtp.should.eql(2);
|
|
52
|
-
stats.stats[0].delivered.total.should.eql(3);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('getAccount', function () {
|
|
58
|
-
const query = { event: 'delivered' };
|
|
59
|
-
|
|
60
|
-
it('fetches stats for a given account', function () {
|
|
61
|
-
api.get('/v3/stats/total')
|
|
62
|
-
.query(query)
|
|
63
|
-
.reply(200, {
|
|
64
|
-
end: 'Mon, 23 Mar 2015 00:00:00 UTC',
|
|
65
|
-
resolution: 'day',
|
|
66
|
-
start: 'Mon, 16 Mar 2015 00:00:00 UTC',
|
|
67
|
-
stats: [
|
|
68
|
-
{
|
|
69
|
-
time: 'Mon, 16 Mar 2015 00:00:00 UTC',
|
|
70
|
-
delivered: {
|
|
71
|
-
smtp: 2,
|
|
72
|
-
http: 1,
|
|
73
|
-
total: 3
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
return client.getAccount({ event: ['delivered'] }).then(function (stats: StatsOptions) {
|
|
80
|
-
(stats.start as Date).toUTCString().should.eql('Mon, 16 Mar 2015 00:00:00 GMT');
|
|
81
|
-
(stats.end as Date).toUTCString().should.eql('Mon, 23 Mar 2015 00:00:00 GMT');
|
|
82
|
-
|
|
83
|
-
(stats.stats[0].time as Date).toUTCString().should.eql('Mon, 16 Mar 2015 00:00:00 GMT');
|
|
84
|
-
stats.stats[0].delivered.http.should.eql(1);
|
|
85
|
-
stats.stats[0].delivered.smtp.should.eql(2);
|
|
86
|
-
stats.stats[0].delivered.total.should.eql(3);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import chai, { expect } from 'chai';
|
|
2
|
-
import formData from 'form-data';
|
|
3
|
-
import nock from 'nock';
|
|
4
|
-
|
|
5
|
-
import Request from '../lib/request';
|
|
6
|
-
import SuppressionClient from '../lib/suppressions';
|
|
7
|
-
import RequestOptions from '../lib/interfaces/RequestOptions';
|
|
8
|
-
import { InputFormData } from '../lib/interfaces/IFormData';
|
|
9
|
-
|
|
10
|
-
chai.should();
|
|
11
|
-
|
|
12
|
-
describe('SuppressionsClient', function () {
|
|
13
|
-
let client: any;
|
|
14
|
-
let api: any;
|
|
15
|
-
|
|
16
|
-
beforeEach(function () {
|
|
17
|
-
client = new SuppressionClient(new Request({ url: 'https://api.mailgun.net' } as RequestOptions, formData as InputFormData));
|
|
18
|
-
api = nock('https://api.mailgun.net');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterEach(function () {
|
|
22
|
-
api.done();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('list', function () {
|
|
26
|
-
let response: any;
|
|
27
|
-
|
|
28
|
-
beforeEach(function () {
|
|
29
|
-
response = {
|
|
30
|
-
items: [],
|
|
31
|
-
paging: {
|
|
32
|
-
first: 'https://api.mailgun.net/v3/mailgun.com/bounces?page=first',
|
|
33
|
-
last: 'https://api.mailgun.net/v3/mailgun.com/bounces?page=last',
|
|
34
|
-
next: 'https://api.mailgun.net/v3/mailgun.com/bounces?page=next&address=next@mailgun.com',
|
|
35
|
-
previous: 'https://api.mailgun.net/v3/mailgun.com/bounces?page=previous&address=previous@mailgun.com'
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('fetches bounces', function () {
|
|
41
|
-
response.items = [{
|
|
42
|
-
address: 'unknown@unknown.com',
|
|
43
|
-
code: 550,
|
|
44
|
-
error: 'No such mailbox',
|
|
45
|
-
created_at: 'Fri, 21 Oct 2011 11:02:55 GMT'
|
|
46
|
-
}, {
|
|
47
|
-
address: 'full@disk.com',
|
|
48
|
-
code: 552,
|
|
49
|
-
error: 'Mailbox full',
|
|
50
|
-
created_at: 'Fri, 21 Oct 2011 12:02:55 GMT'
|
|
51
|
-
}];
|
|
52
|
-
|
|
53
|
-
api.get('/v3/domain.com/bounces').reply(200, response);
|
|
54
|
-
|
|
55
|
-
return client.list('domain.com', 'bounces')
|
|
56
|
-
.then(function (bounces: { items: any }) {
|
|
57
|
-
let b;
|
|
58
|
-
b = bounces.items[0];
|
|
59
|
-
b.address.should.eql('unknown@unknown.com');
|
|
60
|
-
b.code.should.eql(550);
|
|
61
|
-
b.error.should.eql('No such mailbox');
|
|
62
|
-
(b.created_at as Date).toUTCString().should.eql('Fri, 21 Oct 2011 11:02:55 GMT');
|
|
63
|
-
|
|
64
|
-
b = bounces.items[1];
|
|
65
|
-
b.address.should.eql('full@disk.com');
|
|
66
|
-
b.code.should.eql(552);
|
|
67
|
-
b.error.should.eql('Mailbox full');
|
|
68
|
-
(b.created_at as Date).toUTCString().should.eql('Fri, 21 Oct 2011 12:02:55 GMT');
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('fetches unsubscribes', function () {
|
|
73
|
-
response.items = [{
|
|
74
|
-
address: 'brad@example.com',
|
|
75
|
-
tags: ['*'],
|
|
76
|
-
created_at: 'Fri, 21 Oct 2011 11:02:55 GMT'
|
|
77
|
-
}, {
|
|
78
|
-
address: 'roman@example.com',
|
|
79
|
-
tags: ['*'],
|
|
80
|
-
created_at: 'Fri, 21 Oct 2011 12:02:55 GMT'
|
|
81
|
-
}];
|
|
82
|
-
|
|
83
|
-
api.get('/v3/domain.com/unsubscribes').reply(200, response);
|
|
84
|
-
|
|
85
|
-
return client.list('domain.com', 'unsubscribes')
|
|
86
|
-
.then(function (unsubscribes: { items: any }) {
|
|
87
|
-
let u;
|
|
88
|
-
|
|
89
|
-
u = unsubscribes.items[0];
|
|
90
|
-
u.address.should.eql('brad@example.com');
|
|
91
|
-
u.tags.should.eql(['*']);
|
|
92
|
-
u.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 11:02:55 GMT');
|
|
93
|
-
|
|
94
|
-
u = unsubscribes.items[1];
|
|
95
|
-
u.address.should.eql('roman@example.com');
|
|
96
|
-
u.tags.should.eql(['*']);
|
|
97
|
-
u.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 12:02:55 GMT');
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('fetches complaints', function () {
|
|
102
|
-
response.items = [{
|
|
103
|
-
address: 'brad@example.com',
|
|
104
|
-
created_at: 'Fri, 21 Oct 2011 11:02:55 GMT'
|
|
105
|
-
}, {
|
|
106
|
-
address: 'roman@example.com',
|
|
107
|
-
created_at: 'Fri, 21 Oct 2011 12:02:55 GMT'
|
|
108
|
-
}];
|
|
109
|
-
|
|
110
|
-
api.get('/v3/domain.com/complaints').reply(200, response);
|
|
111
|
-
|
|
112
|
-
return client.list('domain.com', 'complaints')
|
|
113
|
-
.then(function (complaints: { items: any }) {
|
|
114
|
-
let c;
|
|
115
|
-
|
|
116
|
-
c = complaints.items[0];
|
|
117
|
-
c.address.should.eql('brad@example.com');
|
|
118
|
-
c.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 11:02:55 GMT');
|
|
119
|
-
|
|
120
|
-
c = complaints.items[1];
|
|
121
|
-
c.address.should.eql('roman@example.com');
|
|
122
|
-
c.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 12:02:55 GMT');
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('parses page links', function () {
|
|
127
|
-
api.get('/v3/domain.com/bounces').reply(200, response);
|
|
128
|
-
|
|
129
|
-
return client.list('domain.com', 'bounces')
|
|
130
|
-
.then(function (bounces: { pages: any }) {
|
|
131
|
-
let page;
|
|
132
|
-
|
|
133
|
-
page = bounces.pages.first;
|
|
134
|
-
page.url.should.eql('https://api.mailgun.net/v3/mailgun.com/bounces?page=first');
|
|
135
|
-
expect(page.page).to.eql('first');
|
|
136
|
-
expect(page.address).to.be.eql(undefined);
|
|
137
|
-
|
|
138
|
-
page = bounces.pages.last;
|
|
139
|
-
page.url.should.eql('https://api.mailgun.net/v3/mailgun.com/bounces?page=last');
|
|
140
|
-
expect(page.page).to.be.eql('last');
|
|
141
|
-
expect(page.address).to.be.eql(undefined);
|
|
142
|
-
|
|
143
|
-
page = bounces.pages.next;
|
|
144
|
-
page.url.should.eql('https://api.mailgun.net/v3/mailgun.com/bounces?page=next&address=next@mailgun.com');
|
|
145
|
-
expect(page.page).to.be.eql('next');
|
|
146
|
-
page.address.should.eql('next@mailgun.com');
|
|
147
|
-
|
|
148
|
-
page = bounces.pages.previous;
|
|
149
|
-
page.url.should.eql('https://api.mailgun.net/v3/mailgun.com/bounces?page=previous&address=previous@mailgun.com');
|
|
150
|
-
expect(page.page).to.be.eql('previous');
|
|
151
|
-
page.address.should.eql('previous@mailgun.com');
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
describe('get', function () {
|
|
157
|
-
it('fetches bounce for address', function () {
|
|
158
|
-
api.get('/v3/domain.com/bounces/address%3F%40unknown.com').reply(200, {
|
|
159
|
-
address: 'address?@unknown.com',
|
|
160
|
-
code: 550,
|
|
161
|
-
error: 'No such mailbox',
|
|
162
|
-
created_at: 'Fri, 21 Oct 2011 11:02:55 GMT'
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
return client.get('domain.com', 'bounces', 'address?@unknown.com')
|
|
166
|
-
.then(function (bounce: any) {
|
|
167
|
-
bounce.address.should.eql('address?@unknown.com');
|
|
168
|
-
bounce.code.should.eql(550);
|
|
169
|
-
bounce.error.should.eql('No such mailbox');
|
|
170
|
-
bounce.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 11:02:55 GMT');
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('fetches unsubscribe for address', function () {
|
|
175
|
-
api.get('/v3/domain.com/unsubscribes/roman%3F%40example.com').reply(200, {
|
|
176
|
-
address: 'address?@unknown.com',
|
|
177
|
-
tags: ['*'],
|
|
178
|
-
created_at: 'Fri, 21 Oct 2011 12:02:55 GMT'
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
return client.get('domain.com', 'unsubscribes', 'roman?@example.com')
|
|
182
|
-
.then(function (unsubscribe: any) {
|
|
183
|
-
unsubscribe.address.should.eql('address?@unknown.com');
|
|
184
|
-
unsubscribe.tags.should.eql(['*']);
|
|
185
|
-
unsubscribe.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 12:02:55 GMT');
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe('create', function () {
|
|
191
|
-
it('creates suppression', function () {
|
|
192
|
-
api.post('/v3/domain.com/bounces').reply(200, {
|
|
193
|
-
message: 'Bounced address has been inserted',
|
|
194
|
-
address: 'myaddress'
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
return client.create('domain.com', 'bounces', {
|
|
198
|
-
address: 'myaddress',
|
|
199
|
-
code: 550
|
|
200
|
-
}).then(function (data: { address: string }) {
|
|
201
|
-
data.address.should.eql('myaddress');
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
describe('destroy', function () {
|
|
207
|
-
it('deletes suppression', function () {
|
|
208
|
-
api.delete('/v3/domain.com/bounces/my%3F%40address.com').reply(200, {
|
|
209
|
-
message: 'Bounced address has been removed',
|
|
210
|
-
address: 'my?@address.com'
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
return client.destroy('domain.com', 'bounces', 'my?@address.com')
|
|
214
|
-
.then(function (data: { address: string }) {
|
|
215
|
-
data.address.should.eql('my?@address.com');
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
});
|
package/test/validate.test.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import formData from 'form-data';
|
|
2
|
-
|
|
3
|
-
import nock from 'nock';
|
|
4
|
-
import Request from '../lib/request';
|
|
5
|
-
import ValidateClient from '../lib/validate';
|
|
6
|
-
import RequestOptions from '../lib/interfaces/RequestOptions';
|
|
7
|
-
import { InputFormData } from '../lib/interfaces/IFormData';
|
|
8
|
-
import MultipleValidationClient from '../lib/multipleValidation';
|
|
9
|
-
|
|
10
|
-
describe('ValidateClient', function () {
|
|
11
|
-
let client: ValidateClient;
|
|
12
|
-
let api: nock.Scope;
|
|
13
|
-
|
|
14
|
-
beforeEach(function () {
|
|
15
|
-
const reqObject = new Request({ url: 'https://api.mailgun.net' } as RequestOptions, formData as InputFormData);
|
|
16
|
-
const multipleValidationClient = new MultipleValidationClient(reqObject);
|
|
17
|
-
client = new ValidateClient(reqObject, multipleValidationClient);
|
|
18
|
-
api = nock('https://api.mailgun.net');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterEach(function () {
|
|
22
|
-
api.done();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('get', function () {
|
|
26
|
-
it('validates a single email address', function () {
|
|
27
|
-
const data: any = {
|
|
28
|
-
address: 'Alice <alice@example.com>',
|
|
29
|
-
did_you_mean: null,
|
|
30
|
-
is_valid: false,
|
|
31
|
-
parts: { display_name: null, domain: null, local_part: null }
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
api.get('/v4/address/validate')
|
|
35
|
-
.query({ address: 'foo@example.com' })
|
|
36
|
-
.reply(200, data);
|
|
37
|
-
|
|
38
|
-
return client.get('foo@example.com').then(function (response: any) {
|
|
39
|
-
response.should.eql(data);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
});
|
package/test/webhooks.test.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import formData from 'form-data';
|
|
2
|
-
import nock from 'nock';
|
|
3
|
-
import Request from '../lib/request';
|
|
4
|
-
import WebhookClient from '../lib/webhooks';
|
|
5
|
-
import RequestOptions from '../lib/interfaces/RequestOptions';
|
|
6
|
-
import { InputFormData } from '../lib/interfaces/IFormData';
|
|
7
|
-
|
|
8
|
-
describe('WebhookClient', function () {
|
|
9
|
-
let client: any;
|
|
10
|
-
let api: any;
|
|
11
|
-
|
|
12
|
-
beforeEach(function () {
|
|
13
|
-
client = new WebhookClient(new Request({ url: 'https://api.mailgun.net' } as RequestOptions, formData as InputFormData));
|
|
14
|
-
api = nock('https://api.mailgun.net');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
afterEach(function () {
|
|
18
|
-
api.done();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe('list', function () {
|
|
22
|
-
const hooks = {
|
|
23
|
-
open: { url: 'trackopen.com' },
|
|
24
|
-
click: { url: 'trackclick.com' }
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
it('fetches all webhooks', function () {
|
|
28
|
-
api.get('/v3/domains/domain.com/webhooks').reply(200, {
|
|
29
|
-
webhooks: hooks
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
return client.list('domain.com').then(function (webhooks: any) {
|
|
33
|
-
webhooks.should.eql(hooks);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('get', function () {
|
|
39
|
-
it('fetches single webhook', function () {
|
|
40
|
-
api.get('/v3/domains/domain.com/webhooks/click').reply(200, {
|
|
41
|
-
webhook: {
|
|
42
|
-
url: 'trackclick.com'
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
return client.get('domain.com', 'click').then(function (webhook: any) {
|
|
47
|
-
webhook.should.eql({ id: 'click', url: 'trackclick.com' });
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe('create', function () {
|
|
53
|
-
it('creates webhook', function () {
|
|
54
|
-
api.post('/v3/domains/domain.com/webhooks')
|
|
55
|
-
.reply(200, {
|
|
56
|
-
message: 'Webhook has been created',
|
|
57
|
-
webhook: {
|
|
58
|
-
url: 'trackclick.com'
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return client.create('domain.com', 'click', 'trackclick.com')
|
|
63
|
-
.then(function (webhook: any) {
|
|
64
|
-
webhook.should.eql({ id: 'click', url: 'trackclick.com' });
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('tests webhook', function () {
|
|
69
|
-
api.put('/v3/domains/domain.com/webhooks/click/test')
|
|
70
|
-
.reply(200, {
|
|
71
|
-
code: '500',
|
|
72
|
-
message: 'Hi!'
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return client.create('domain.com', 'click', 'trackclick.com', true)
|
|
76
|
-
.then(function (test: any) {
|
|
77
|
-
test.should.eql({ code: '500', message: 'Hi!' });
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe('update', function () {
|
|
83
|
-
it('updates webhook', function () {
|
|
84
|
-
api.put('/v3/domains/domain.com/webhooks/click')
|
|
85
|
-
.reply(200, {
|
|
86
|
-
message: 'Webhook has been updated',
|
|
87
|
-
webhook: {
|
|
88
|
-
url: 'trackclick.com'
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
return client.update('domain.com', 'click', 'trackclick.com').then(function (webhook: any) {
|
|
93
|
-
webhook.should.eql({ id: 'click', url: 'trackclick.com' });
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('destroy', function () {
|
|
99
|
-
it('deletes webhook', function () {
|
|
100
|
-
api.delete('/v3/domains/domain.com/webhooks/click').reply(200, {
|
|
101
|
-
message: 'Webhook has been deleted',
|
|
102
|
-
webhook: {
|
|
103
|
-
url: 'trackclick.com'
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
return client.destroy('domain.com', 'click', { url: 'trackclick.com' }).then(function (webhook: any) {
|
|
108
|
-
webhook.should.eql({ id: 'click', url: 'trackclick.com' });
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "dist",
|
|
4
|
-
"noImplicitAny": true,
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"target": "es5",
|
|
7
|
-
"allowJs": true,
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
|
|
11
|
-
"allowSyntheticDefaultImports": true,
|
|
12
|
-
"incremental": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"strict": true
|
|
15
|
-
},
|
|
16
|
-
"typedocOptions": {
|
|
17
|
-
"out": "docs",
|
|
18
|
-
"entryPointStrategy": "expand",
|
|
19
|
-
"entryPoints": ["./lib"],
|
|
20
|
-
"exclude": ["test/**", "dist/**", "build/**", "docs/**", "examples/**"]
|
|
21
|
-
}
|
|
22
|
-
}
|
package/tsconfig.webpack.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const webpack = require('webpack');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const pkg = require('../package.json');
|
|
4
|
-
|
|
5
|
-
const SRC_DIR = path.join(__dirname, '../');
|
|
6
|
-
|
|
7
|
-
const outputDir = 'dist';
|
|
8
|
-
const commonConfig = {
|
|
9
|
-
mode: 'development',
|
|
10
|
-
context: SRC_DIR,
|
|
11
|
-
entry: {
|
|
12
|
-
mailgun: path.join(SRC_DIR, 'lib/index.ts'),
|
|
13
|
-
'mailgun.min': path.join(SRC_DIR, 'lib/index.ts')
|
|
14
|
-
},
|
|
15
|
-
output: {
|
|
16
|
-
path: path.join(SRC_DIR, outputDir),
|
|
17
|
-
filename: 'mailgun.js',
|
|
18
|
-
library: 'mailgun',
|
|
19
|
-
libraryTarget: 'umd',
|
|
20
|
-
globalObject: 'this',
|
|
21
|
-
},
|
|
22
|
-
module: {
|
|
23
|
-
rules: [
|
|
24
|
-
{
|
|
25
|
-
test: /\.(ts|js)?/,
|
|
26
|
-
use: [
|
|
27
|
-
{
|
|
28
|
-
loader: 'babel-loader',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
loader: `ts-loader?configFile=${path.join(SRC_DIR, 'tsconfig.webpack.json')}`
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
exclude: /(node_modules|test)/
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
},
|
|
38
|
-
plugins: [
|
|
39
|
-
new webpack.BannerPlugin(`${pkg.name} v${pkg.version}`)
|
|
40
|
-
],
|
|
41
|
-
resolve: {
|
|
42
|
-
extensions: ['.ts', '.js', '.json']
|
|
43
|
-
},
|
|
44
|
-
devtool: 'inline-source-map'
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
module.exports = commonConfig;
|