mailgun.js 5.0.3 → 5.1.0

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.
Files changed (314) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +15 -3
  3. package/client.d.ts +29 -0
  4. package/domains.d.ts +54 -0
  5. package/domainsCredentials.d.ts +14 -0
  6. package/domainsTags.d.ts +34 -0
  7. package/domainsTemplates.d.ts +35 -0
  8. package/error.d.ts +7 -0
  9. package/events.d.ts +13 -0
  10. package/index.d.ts +9 -0
  11. package/interfaces/APIErrorOptions.d.ts +11 -0
  12. package/{lib/interfaces/ApiResponse.ts → interfaces/ApiResponse.d.ts} +1 -2
  13. package/{lib/interfaces/DomainCredentials.ts → interfaces/DomainCredentials.d.ts} +14 -30
  14. package/{lib/interfaces/DomainTags.ts → interfaces/DomainTags.d.ts} +49 -82
  15. package/{lib/interfaces/DomainTemplates.ts → interfaces/DomainTemplates.d.ts} +35 -79
  16. package/{lib/interfaces/DomainTracking.ts → interfaces/DomainTracking.d.ts} +18 -17
  17. package/{lib/interfaces/Domains.ts → interfaces/Domains.d.ts} +29 -50
  18. package/{lib/interfaces/Events.ts → interfaces/Events.d.ts} +11 -12
  19. package/{lib/interfaces/IFormData.ts → interfaces/IFormData.d.ts} +2 -4
  20. package/interfaces/IMailgunClient.d.ts +24 -0
  21. package/interfaces/IpPools.d.ts +19 -0
  22. package/interfaces/Ips.d.ts +10 -0
  23. package/interfaces/Messages.d.ts +165 -0
  24. package/{lib/interfaces/MultipleValidation.ts → interfaces/MultipleValidation.d.ts} +9 -16
  25. package/interfaces/Options.d.ts +8 -0
  26. package/{lib/interfaces/RequestOptions.ts → interfaces/RequestOptions.d.ts} +2 -4
  27. package/interfaces/StatsOptions.d.ts +22 -0
  28. package/interfaces/Supressions.d.ts +103 -0
  29. package/{lib/interfaces/Validate.ts → interfaces/Validate.d.ts} +0 -3
  30. package/{lib/interfaces/Webhooks.ts → interfaces/Webhooks.d.ts} +11 -17
  31. package/{lib/interfaces/lists.ts → interfaces/lists.d.ts} +1 -5
  32. package/{lib/interfaces/mailListMembers.ts → interfaces/mailListMembers.d.ts} +8 -23
  33. package/{lib/interfaces/routes.ts → interfaces/routes.d.ts} +1 -6
  34. package/ip-pools.d.ts +21 -0
  35. package/ips.d.ts +9 -0
  36. package/lists.d.ts +14 -0
  37. package/mailListMembers.d.ts +14 -0
  38. package/mailgun.node.js +3 -0
  39. package/{dist/mailgun.node.js.LICENSE.txt → mailgun.node.js.LICENSE.txt} +1 -1
  40. package/mailgun.web.js +3 -0
  41. package/{dist/mailgun.web.js.LICENSE.txt → mailgun.web.js.LICENSE.txt} +1 -1
  42. package/messages.d.ts +8 -0
  43. package/multipleValidation.d.ts +10 -0
  44. package/package.json +8 -81
  45. package/request.d.ts +31 -0
  46. package/routes.d.ts +11 -0
  47. package/stats.d.ts +20 -0
  48. package/suppressions.d.ts +50 -0
  49. package/validate.d.ts +9 -0
  50. package/version.md +1 -0
  51. package/webhooks.d.ts +32 -0
  52. package/.editorconfig +0 -10
  53. package/.eslintrc +0 -56
  54. package/.husky/commit-msg +0 -4
  55. package/.travis.yml +0 -5
  56. package/LICENSE +0 -191
  57. package/commitlint.config.js +0 -7
  58. package/dist/mailgun.js.d.ts +0 -1586
  59. package/dist/mailgun.node.js +0 -3
  60. package/dist/mailgun.web.js +0 -3
  61. package/docs/.nojekyll +0 -1
  62. package/docs/assets/highlight.css +0 -127
  63. package/docs/assets/icons.css +0 -1043
  64. package/docs/assets/icons.png +0 -0
  65. package/docs/assets/icons@2x.png +0 -0
  66. package/docs/assets/main.js +0 -52
  67. package/docs/assets/search.js +0 -1
  68. package/docs/assets/style.css +0 -1413
  69. package/docs/assets/widgets.png +0 -0
  70. package/docs/assets/widgets@2x.png +0 -0
  71. package/docs/classes/client.default.html +0 -1
  72. package/docs/classes/domains.Domain.html +0 -1
  73. package/docs/classes/domains.default.html +0 -1
  74. package/docs/classes/domainsCredentials.default.html +0 -1
  75. package/docs/classes/domainsTemplates.DomainTemplateItem.html +0 -1
  76. package/docs/classes/domainsTemplates.default.html +0 -1
  77. package/docs/classes/error.default.html +0 -6
  78. package/docs/classes/events.default.html +0 -1
  79. package/docs/classes/ip_pools.default.html +0 -1
  80. package/docs/classes/ips.default.html +0 -1
  81. package/docs/classes/lists.default.html +0 -1
  82. package/docs/classes/mailListMembers.default.html +0 -1
  83. package/docs/classes/messages.default.html +0 -1
  84. package/docs/classes/multipleValidation.default.html +0 -1
  85. package/docs/classes/request.default.html +0 -1
  86. package/docs/classes/routes.default.html +0 -1
  87. package/docs/classes/stats.default.html +0 -1
  88. package/docs/classes/suppressions.default.html +0 -1
  89. package/docs/classes/validate.default.html +0 -1
  90. package/docs/classes/webhooks.default.html +0 -1
  91. package/docs/enums/interfaces_DomainTemplates.Pages.html +0 -1
  92. package/docs/enums/interfaces_DomainTemplates.YesNo.html +0 -1
  93. package/docs/index.html +0 -1140
  94. package/docs/interfaces/interfaces_APIErrorOptions.default.html +0 -1
  95. package/docs/interfaces/interfaces_ApiResponse.default.html +0 -1
  96. package/docs/interfaces/interfaces_DomainCredentials.CreatedUpdatedDomainCredentialsResponse.html +0 -1
  97. package/docs/interfaces/interfaces_DomainCredentials.DeletedDomainCredentialsResponse.html +0 -1
  98. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentials.html +0 -1
  99. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsItem.html +0 -1
  100. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsList.html +0 -1
  101. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsQuery.html +0 -1
  102. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsResponseData.html +0 -1
  103. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsResult.html +0 -1
  104. package/docs/interfaces/interfaces_DomainCredentials.IDomainCredentials.html +0 -1
  105. package/docs/interfaces/interfaces_DomainCredentials.UpdateDomainCredentialsData.html +0 -1
  106. package/docs/interfaces/interfaces_DomainTemplates.CreateDomainTemplateAPIResponse.html +0 -1
  107. package/docs/interfaces/interfaces_DomainTemplates.CreateDomainTemplateVersionAPIResponse.html +0 -1
  108. package/docs/interfaces/interfaces_DomainTemplates.CreateDomainTemplateVersionResult.html +0 -1
  109. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplate.html +0 -1
  110. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateData.html +0 -1
  111. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateUpdateData.html +0 -1
  112. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateUpdateVersionData.html +0 -1
  113. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateVersionData.html +0 -1
  114. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplatesQuery.html +0 -1
  115. package/docs/interfaces/interfaces_DomainTemplates.GetDomainTemplateAPIResponse.html +0 -1
  116. package/docs/interfaces/interfaces_DomainTemplates.IDomainTemplatesClient.html +0 -1
  117. package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplateVersionsAPIResponse.html +0 -1
  118. package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplateVersionsResult.html +0 -1
  119. package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplatesAPIResponse.html +0 -1
  120. package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplatesResult.html +0 -1
  121. package/docs/interfaces/interfaces_DomainTemplates.MutateDomainTemplateVersionAPIResponse.html +0 -1
  122. package/docs/interfaces/interfaces_DomainTemplates.MutateDomainTemplateVersionResult.html +0 -1
  123. package/docs/interfaces/interfaces_DomainTemplates.NotificationAPIResponse.html +0 -1
  124. package/docs/interfaces/interfaces_DomainTemplates.NotificationResult.html +0 -1
  125. package/docs/interfaces/interfaces_DomainTemplates.ShortTemplateVersion.html +0 -1
  126. package/docs/interfaces/interfaces_DomainTemplates.TemplateQuery.html +0 -1
  127. package/docs/interfaces/interfaces_DomainTemplates.TemplateVersion.html +0 -1
  128. package/docs/interfaces/interfaces_DomainTemplates.UpdateOrDeleteDomainTemplateAPIResponse.html +0 -1
  129. package/docs/interfaces/interfaces_DomainTemplates.UpdateOrDeleteDomainTemplateResult.html +0 -1
  130. package/docs/interfaces/interfaces_DomainTracking.ClickTrackingInfo.html +0 -1
  131. package/docs/interfaces/interfaces_DomainTracking.DomainTrackingData.html +0 -1
  132. package/docs/interfaces/interfaces_DomainTracking.DomainTrackingResponse.html +0 -1
  133. package/docs/interfaces/interfaces_DomainTracking.OpenTrackingInfo.html +0 -1
  134. package/docs/interfaces/interfaces_DomainTracking.UnsubscribeTrackingInfo.html +0 -1
  135. package/docs/interfaces/interfaces_DomainTracking.UpdateDomainTrackingResponse.html +0 -1
  136. package/docs/interfaces/interfaces_DomainTracking.UpdatedOpenTracking.html +0 -1
  137. package/docs/interfaces/interfaces_Domains.ConnectionSettings.html +0 -1
  138. package/docs/interfaces/interfaces_Domains.ConnectionSettingsResponse.html +0 -1
  139. package/docs/interfaces/interfaces_Domains.DKIMAuthorityInfo.html +0 -1
  140. package/docs/interfaces/interfaces_Domains.DKIMSelectorInfo.html +0 -1
  141. package/docs/interfaces/interfaces_Domains.DNSRecord.html +0 -1
  142. package/docs/interfaces/interfaces_Domains.DestroyedDomainResponse.html +0 -1
  143. package/docs/interfaces/interfaces_Domains.DomainData.html +0 -1
  144. package/docs/interfaces/interfaces_Domains.DomainInfo.html +0 -1
  145. package/docs/interfaces/interfaces_Domains.DomainListResponseData.html +0 -1
  146. package/docs/interfaces/interfaces_Domains.DomainResponseData.html +0 -1
  147. package/docs/interfaces/interfaces_Domains.DomainShortData.html +0 -1
  148. package/docs/interfaces/interfaces_Domains.DomainsListItem.html +0 -1
  149. package/docs/interfaces/interfaces_Domains.DomainsQuery.html +0 -1
  150. package/docs/interfaces/interfaces_Domains.MessageResponse.html +0 -1
  151. package/docs/interfaces/interfaces_Domains.ReplacementForPool.html +0 -1
  152. package/docs/interfaces/interfaces_Domains.UpdatedConnectionSettings.html +0 -1
  153. package/docs/interfaces/interfaces_Domains.UpdatedConnectionSettingsRes.html +0 -1
  154. package/docs/interfaces/interfaces_Domains.UpdatedDKIMAuthority.html +0 -1
  155. package/docs/interfaces/interfaces_Domains.UpdatedDKIMAuthorityResponse.html +0 -1
  156. package/docs/interfaces/interfaces_Domains.UpdatedDKIMSelectorResponse.html +0 -1
  157. package/docs/interfaces/interfaces_Domains.UpdatedWebPrefix.html +0 -1
  158. package/docs/interfaces/interfaces_Domains.UpdatedWebPrefixResponse.html +0 -1
  159. package/docs/interfaces/interfaces_Domains.WebPrefixInfo.html +0 -1
  160. package/docs/interfaces/interfaces_Events.DomainEvent.html +0 -1
  161. package/docs/interfaces/interfaces_Events.EventsList.html +0 -1
  162. package/docs/interfaces/interfaces_Events.EventsPage.html +0 -1
  163. package/docs/interfaces/interfaces_Events.EventsResponse.html +0 -1
  164. package/docs/interfaces/interfaces_Events.PagesList.html +0 -1
  165. package/docs/interfaces/interfaces_Events.PagesListAccumulator.html +0 -1
  166. package/docs/interfaces/interfaces_Events.ParsedPage.html +0 -1
  167. package/docs/interfaces/interfaces_Events.ParsedPagesList.html +0 -1
  168. package/docs/interfaces/interfaces_IFormData.IFormDataOptions.html +0 -1
  169. package/docs/interfaces/interfaces_IFormData.InputFormData.html +0 -1
  170. package/docs/interfaces/interfaces_IpPools.IpPool.html +0 -1
  171. package/docs/interfaces/interfaces_IpPools.IpPoolListResponse.html +0 -1
  172. package/docs/interfaces/interfaces_IpPools.IpPoolUpdateData.html +0 -1
  173. package/docs/interfaces/interfaces_Ips.IpData.html +0 -1
  174. package/docs/interfaces/interfaces_Ips.IpsListResponseBody.html +0 -1
  175. package/docs/interfaces/interfaces_MultipleValidation.CanceledMultipleValidationJob.html +0 -1
  176. package/docs/interfaces/interfaces_MultipleValidation.CreatedMultipleValidationJob.html +0 -1
  177. package/docs/interfaces/interfaces_MultipleValidation.IMultipleValidationClient.html +0 -1
  178. package/docs/interfaces/interfaces_MultipleValidation.MultipleValidationJob.html +0 -1
  179. package/docs/interfaces/interfaces_MultipleValidation.MultipleValidationJobsListResponse.html +0 -1
  180. package/docs/interfaces/interfaces_MultipleValidation.MultipleValidationJobsListResult.html +0 -1
  181. package/docs/interfaces/interfaces_MultipleValidation.PagesList.html +0 -1
  182. package/docs/interfaces/interfaces_Options.default.html +0 -1
  183. package/docs/interfaces/interfaces_RequestOptions.default.html +0 -1
  184. package/docs/interfaces/interfaces_StatsOptions.Stat.html +0 -1
  185. package/docs/interfaces/interfaces_StatsOptions.StatsOptions.html +0 -1
  186. package/docs/interfaces/interfaces_StatsOptions.StatsQuery.html +0 -1
  187. package/docs/interfaces/interfaces_Supressions.BounceData.html +0 -1
  188. package/docs/interfaces/interfaces_Supressions.ComplaintData.html +0 -1
  189. package/docs/interfaces/interfaces_Supressions.UnsubscribeData.html +0 -1
  190. package/docs/interfaces/interfaces_Supressions.WhiteListData.html +0 -1
  191. package/docs/interfaces/interfaces_Validate.ValidationResponse.html +0 -1
  192. package/docs/interfaces/interfaces_Validate.ValidationResult.html +0 -1
  193. package/docs/interfaces/interfaces_Webhooks.APIWebhook.html +0 -1
  194. package/docs/interfaces/interfaces_Webhooks.ValidationResponse.html +0 -1
  195. package/docs/interfaces/interfaces_Webhooks.WebhookList.html +0 -1
  196. package/docs/interfaces/interfaces_Webhooks.WebhookResponse.html +0 -1
  197. package/docs/interfaces/interfaces_Webhooks.WebhookResponseBody.html +0 -1
  198. package/docs/interfaces/interfaces_Webhooks.WebhooksQuery.html +0 -1
  199. package/docs/interfaces/interfaces_lists.CreateUpdateList.html +0 -1
  200. package/docs/interfaces/interfaces_lists.DestroyedList.html +0 -1
  201. package/docs/interfaces/interfaces_lists.ListsQuery.html +0 -1
  202. package/docs/interfaces/interfaces_lists.MailingList.html +0 -1
  203. package/docs/interfaces/interfaces_mailListMembers.CreateUpdateMailListMembers.html +0 -1
  204. package/docs/interfaces/interfaces_mailListMembers.CreateUpdateMailListMembersReq.html +0 -1
  205. package/docs/interfaces/interfaces_mailListMembers.DeletedMember.html +0 -1
  206. package/docs/interfaces/interfaces_mailListMembers.IMailListsMembers.html +0 -1
  207. package/docs/interfaces/interfaces_mailListMembers.MailListMember.html +0 -1
  208. package/docs/interfaces/interfaces_mailListMembers.MailListMembersQuery.html +0 -1
  209. package/docs/interfaces/interfaces_mailListMembers.MultipleMembersData.html +0 -1
  210. package/docs/interfaces/interfaces_mailListMembers.MultipleMembersReqData.html +0 -1
  211. package/docs/interfaces/interfaces_mailListMembers.NewMultipleMembersResponse.html +0 -1
  212. package/docs/interfaces/interfaces_routes.CreateUpdateRouteData.html +0 -1
  213. package/docs/interfaces/interfaces_routes.DestroyRouteResponse.html +0 -1
  214. package/docs/interfaces/interfaces_routes.Route.html +0 -1
  215. package/docs/interfaces/interfaces_routes.RoutesListQuery.html +0 -1
  216. package/docs/interfaces/interfaces_routes.UpdateRouteResponse.html +0 -1
  217. package/docs/modules/client.html +0 -1
  218. package/docs/modules/domains.html +0 -1
  219. package/docs/modules/domainsCredentials.html +0 -1
  220. package/docs/modules/domainsTemplates.html +0 -1
  221. package/docs/modules/error.html +0 -1
  222. package/docs/modules/events.html +0 -1
  223. package/docs/modules/interfaces_APIErrorOptions.html +0 -1
  224. package/docs/modules/interfaces_ApiResponse.html +0 -1
  225. package/docs/modules/interfaces_DomainCredentials.html +0 -1
  226. package/docs/modules/interfaces_DomainTemplates.html +0 -1
  227. package/docs/modules/interfaces_DomainTracking.html +0 -1
  228. package/docs/modules/interfaces_Domains.html +0 -1
  229. package/docs/modules/interfaces_Events.html +0 -1
  230. package/docs/modules/interfaces_IFormData.html +0 -1
  231. package/docs/modules/interfaces_IpPools.html +0 -1
  232. package/docs/modules/interfaces_Ips.html +0 -1
  233. package/docs/modules/interfaces_MultipleValidation.html +0 -1
  234. package/docs/modules/interfaces_Options.html +0 -1
  235. package/docs/modules/interfaces_RequestOptions.html +0 -1
  236. package/docs/modules/interfaces_StatsOptions.html +0 -1
  237. package/docs/modules/interfaces_Supressions.html +0 -1
  238. package/docs/modules/interfaces_Validate.html +0 -1
  239. package/docs/modules/interfaces_Webhooks.html +0 -1
  240. package/docs/modules/interfaces_lists.html +0 -1
  241. package/docs/modules/interfaces_mailListMembers.html +0 -1
  242. package/docs/modules/interfaces_routes.html +0 -1
  243. package/docs/modules/ip_pools.html +0 -1
  244. package/docs/modules/ips.html +0 -1
  245. package/docs/modules/lists.html +0 -1
  246. package/docs/modules/mailListMembers.html +0 -1
  247. package/docs/modules/messages.html +0 -1
  248. package/docs/modules/multipleValidation.html +0 -1
  249. package/docs/modules/request.html +0 -1
  250. package/docs/modules/routes.html +0 -1
  251. package/docs/modules/stats.html +0 -1
  252. package/docs/modules/suppressions.html +0 -1
  253. package/docs/modules/validate.html +0 -1
  254. package/docs/modules/webhooks.html +0 -1
  255. package/docs/modules.html +0 -1
  256. package/dts-bundle.js +0 -8
  257. package/examples/addresses.js +0 -20
  258. package/examples/index.html +0 -285
  259. package/examples/list-domains.js +0 -8
  260. package/examples/mailgun.png +0 -0
  261. package/examples/rackspace.png +0 -0
  262. package/examples/send-email.js +0 -24
  263. package/lib/client.ts +0 -79
  264. package/lib/domains.ts +0 -224
  265. package/lib/domainsCredentials.ts +0 -88
  266. package/lib/domainsTags.ts +0 -165
  267. package/lib/domainsTemplates.ts +0 -235
  268. package/lib/error.ts +0 -22
  269. package/lib/events.ts +0 -54
  270. package/lib/index.ts +0 -16
  271. package/lib/interfaces/APIErrorOptions.ts +0 -10
  272. package/lib/interfaces/IpPools.ts +0 -22
  273. package/lib/interfaces/Ips.ts +0 -12
  274. package/lib/interfaces/Options.ts +0 -10
  275. package/lib/interfaces/StatsOptions.ts +0 -25
  276. package/lib/interfaces/Supressions.ts +0 -123
  277. package/lib/ip-pools.ts +0 -36
  278. package/lib/ips.ts +0 -24
  279. package/lib/lists.ts +0 -45
  280. package/lib/mailListMembers.ts +0 -83
  281. package/lib/messages.ts +0 -27
  282. package/lib/multipleValidation.ts +0 -37
  283. package/lib/request.ts +0 -271
  284. package/lib/routes.ts +0 -37
  285. package/lib/stats.ts +0 -62
  286. package/lib/suppressions.ts +0 -253
  287. package/lib/validate.ts +0 -20
  288. package/lib/webhooks.ts +0 -83
  289. package/test/client.test.ts +0 -96
  290. package/test/data/emailsValidation1.csv +0 -3
  291. package/test/domains.test.ts +0 -313
  292. package/test/domainsCredentials.test.ts +0 -97
  293. package/test/domainsTags.test.ts +0 -345
  294. package/test/domainsTemplates.test.ts +0 -392
  295. package/test/error.test.ts +0 -32
  296. package/test/events.test.ts +0 -104
  297. package/test/img/mailgun.png +0 -0
  298. package/test/ips.test.ts +0 -57
  299. package/test/lists.test.ts +0 -100
  300. package/test/mailListMembers.test.ts +0 -198
  301. package/test/messageAttachment.test.ts +0 -50
  302. package/test/messages.test.ts +0 -89
  303. package/test/multipleValidation.test.ts +0 -159
  304. package/test/request.test.ts +0 -103
  305. package/test/routes.test.ts +0 -136
  306. package/test/stats.test.ts +0 -90
  307. package/test/suppressions.test.ts +0 -303
  308. package/test/validate.test.ts +0 -43
  309. package/test/webhooks.test.ts +0 -112
  310. package/tsconfig.json +0 -22
  311. package/tsconfig.webpack.json +0 -10
  312. package/webpack/webpack.common.config.js +0 -46
  313. package/webpack/webpack.dev.config.js +0 -36
  314. package/webpack/webpack.release.config.js +0 -45
@@ -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
- });
@@ -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,303 +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
- import { WhiteListData } from '../lib/interfaces/Supressions';
10
-
11
- chai.should();
12
-
13
- describe('SuppressionsClient', function () {
14
- let client: any;
15
- let api: any;
16
-
17
- beforeEach(function () {
18
- client = new SuppressionClient(new Request({ url: 'https://api.mailgun.net' } as RequestOptions, formData as InputFormData));
19
- api = nock('https://api.mailgun.net');
20
- });
21
-
22
- afterEach(function () {
23
- api.done();
24
- });
25
-
26
- describe('list', function () {
27
- let response: any;
28
-
29
- beforeEach(function () {
30
- response = {
31
- items: [],
32
- paging: {
33
- first: 'https://api.mailgun.net/v3/mailgun.com/bounces?page=first',
34
- last: 'https://api.mailgun.net/v3/mailgun.com/bounces?page=last',
35
- next: 'https://api.mailgun.net/v3/mailgun.com/bounces?page=next&address=next@mailgun.com',
36
- previous: 'https://api.mailgun.net/v3/mailgun.com/bounces?page=previous&address=previous@mailgun.com'
37
- }
38
- };
39
- });
40
-
41
- it('fetches bounces', function () {
42
- response.items = [{
43
- address: 'unknown@unknown.com',
44
- code: 550,
45
- error: 'No such mailbox',
46
- created_at: 'Fri, 21 Oct 2011 11:02:55 GMT'
47
- }, {
48
- address: 'full@disk.com',
49
- code: 552,
50
- error: 'Mailbox full',
51
- created_at: 'Fri, 21 Oct 2011 12:02:55 GMT'
52
- }];
53
-
54
- api.get('/v3/domain.com/bounces').reply(200, response);
55
-
56
- return client.list('domain.com', 'bounces')
57
- .then(function (bounces: { items: any }) {
58
- let b;
59
- b = bounces.items[0];
60
- b.address.should.eql('unknown@unknown.com');
61
- b.code.should.eql(550);
62
- b.error.should.eql('No such mailbox');
63
- (b.created_at as Date).toUTCString().should.eql('Fri, 21 Oct 2011 11:02:55 GMT');
64
-
65
- b = bounces.items[1];
66
- b.address.should.eql('full@disk.com');
67
- b.code.should.eql(552);
68
- b.error.should.eql('Mailbox full');
69
- (b.created_at as Date).toUTCString().should.eql('Fri, 21 Oct 2011 12:02:55 GMT');
70
- });
71
- });
72
-
73
- it('fetches unsubscribes', function () {
74
- response.items = [{
75
- address: 'brad@example.com',
76
- tags: ['*'],
77
- created_at: 'Fri, 21 Oct 2011 11:02:55 GMT'
78
- }, {
79
- address: 'roman@example.com',
80
- tags: ['*'],
81
- created_at: 'Fri, 21 Oct 2011 12:02:55 GMT'
82
- }];
83
-
84
- api.get('/v3/domain.com/unsubscribes').reply(200, response);
85
-
86
- return client.list('domain.com', 'unsubscribes')
87
- .then(function (unsubscribes: { items: any }) {
88
- let u;
89
-
90
- u = unsubscribes.items[0];
91
- u.address.should.eql('brad@example.com');
92
- u.tags.should.eql(['*']);
93
- u.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 11:02:55 GMT');
94
-
95
- u = unsubscribes.items[1];
96
- u.address.should.eql('roman@example.com');
97
- u.tags.should.eql(['*']);
98
- u.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 12:02:55 GMT');
99
- });
100
- });
101
-
102
- it('fetches complaints', function () {
103
- response.items = [{
104
- address: 'brad@example.com',
105
- created_at: 'Fri, 21 Oct 2011 11:02:55 GMT'
106
- }, {
107
- address: 'roman@example.com',
108
- created_at: 'Fri, 21 Oct 2011 12:02:55 GMT'
109
- }];
110
-
111
- api.get('/v3/domain.com/complaints').reply(200, response);
112
-
113
- return client.list('domain.com', 'complaints')
114
- .then(function (complaints: { items: any }) {
115
- let c;
116
-
117
- c = complaints.items[0];
118
- c.address.should.eql('brad@example.com');
119
- c.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 11:02:55 GMT');
120
-
121
- c = complaints.items[1];
122
- c.address.should.eql('roman@example.com');
123
- c.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 12:02:55 GMT');
124
- });
125
- });
126
-
127
- it('fetches WhiteLists', function () {
128
- response.items = [{
129
- type: 'whitelists',
130
- value: 'brad@example.com',
131
- reason: 'first reason',
132
- createdAt: '2021-11-30T10:38:56.000Z'
133
- }, {
134
- type: 'whitelists',
135
- value: 'roman@example.com',
136
- reason: 'second reason',
137
- createdAt: '2021-11-30T10:38:56.000Z'
138
- }];
139
-
140
- api.get('/v3/domain.com/whitelists').reply(200, response);
141
-
142
- return client.list('domain.com', 'whitelists')
143
- .then(function (complaints: { items: WhiteListData[] }) {
144
- let c;
145
- c = complaints.items[0];
146
- c.type.should.eql('whitelists');
147
- c.value.should.eql('brad@example.com');
148
- c.reason.should.eql('first reason');
149
- c.createdAt.should.eql(new Date('2021-11-30T10:38:56.000Z'));
150
-
151
- c = complaints.items[1];
152
- c.type.should.eql('whitelists');
153
- c.value.should.eql('roman@example.com');
154
- c.reason.should.eql('second reason');
155
- c.createdAt.should.eql(new Date('2021-11-30T10:38:56.000Z'));
156
- });
157
- });
158
-
159
- it('parses page links', function () {
160
- api.get('/v3/domain.com/bounces').reply(200, response);
161
-
162
- return client.list('domain.com', 'bounces')
163
- .then(function (bounces: { pages: any }) {
164
- let page;
165
-
166
- page = bounces.pages.first;
167
- page.url.should.eql('https://api.mailgun.net/v3/mailgun.com/bounces?page=first');
168
- expect(page.page).to.eql('first');
169
- expect(page.address).to.be.eql(undefined);
170
-
171
- page = bounces.pages.last;
172
- page.url.should.eql('https://api.mailgun.net/v3/mailgun.com/bounces?page=last');
173
- expect(page.page).to.be.eql('last');
174
- expect(page.address).to.be.eql(undefined);
175
-
176
- page = bounces.pages.next;
177
- page.url.should.eql('https://api.mailgun.net/v3/mailgun.com/bounces?page=next&address=next@mailgun.com');
178
- expect(page.page).to.be.eql('next');
179
- page.address.should.eql('next@mailgun.com');
180
-
181
- page = bounces.pages.previous;
182
- page.url.should.eql('https://api.mailgun.net/v3/mailgun.com/bounces?page=previous&address=previous@mailgun.com');
183
- expect(page.page).to.be.eql('previous');
184
- page.address.should.eql('previous@mailgun.com');
185
- });
186
- });
187
- });
188
-
189
- describe('get', function () {
190
- it('fetches bounce for address', function () {
191
- api.get('/v3/domain.com/bounces/address%3F%40unknown.com').reply(200, {
192
- address: 'address?@unknown.com',
193
- code: 550,
194
- error: 'No such mailbox',
195
- created_at: 'Fri, 21 Oct 2011 11:02:55 GMT'
196
- });
197
-
198
- return client.get('domain.com', 'bounces', 'address?@unknown.com')
199
- .then(function (bounce: any) {
200
- bounce.address.should.eql('address?@unknown.com');
201
- bounce.code.should.eql(550);
202
- bounce.error.should.eql('No such mailbox');
203
- bounce.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 11:02:55 GMT');
204
- });
205
- });
206
-
207
- it('fetches unsubscribe for address', function () {
208
- api.get('/v3/domain.com/unsubscribes/roman%3F%40example.com').reply(200, {
209
- address: 'address?@unknown.com',
210
- tags: ['*'],
211
- created_at: 'Fri, 21 Oct 2011 12:02:55 GMT'
212
- });
213
-
214
- return client.get('domain.com', 'unsubscribes', 'roman?@example.com')
215
- .then(function (unsubscribe: any) {
216
- unsubscribe.address.should.eql('address?@unknown.com');
217
- unsubscribe.tags.should.eql(['*']);
218
- unsubscribe.created_at.toUTCString().should.eql('Fri, 21 Oct 2011 12:02:55 GMT');
219
- });
220
- });
221
- });
222
- describe('create', function () {
223
- describe('create bounce', function () {
224
- it('creates suppression', function () {
225
- api.post('/v3/domain.com/bounces').reply(200, {
226
- message: '1 addresses have been added to the bounces table'
227
- });
228
-
229
- return client.create('domain.com', 'bounces', {
230
- address: 'myaddress',
231
- code: 550
232
- }).then(function (data: { message: string }) {
233
- data.message.should.eql('1 addresses have been added to the bounces table');
234
- });
235
- });
236
- });
237
-
238
- describe('create multiple bounces', function () {
239
- it('creates bounces', async function () {
240
- const message = '2 addresses have been added to the bounces table';
241
- api.post('/v3/domain.com/bounces').reply(200, {
242
- message
243
- });
244
- return client.create('domain.com', 'bounces',
245
- [{ address: 'myaddress' }, { address: 'myaddress1' }])
246
- .then(function (data: { message: string }) {
247
- data.message.should.eql(message);
248
- });
249
- });
250
- });
251
- describe('create whitelists', function () {
252
- it('creates whitelist', async function () {
253
- const message = '1 addresses have been added to the whitelists table';
254
- api.post('/v3/domain.com/whitelists').reply(200, {
255
- message
256
- });
257
- return client.create('domain.com', 'whitelists',
258
- { address: 'myaddress' })
259
- .then(function (data: { message: string }) {
260
- data.message.should.eql(message);
261
- });
262
- });
263
- });
264
-
265
- describe('create multiple whitelists', function () {
266
- it('throws in case multiple whitelists provided', async function () {
267
- try {
268
- await client.create('domain.com', 'whitelists',
269
- [{ address: 'myaddress' }, { address: 'myaddress1' }]);
270
- } catch (error: any) {
271
- error.message.should.eql('Data property should be an object');
272
- error.details.should.eql("Whitelist's creation process does not support multiple creations. Data property should be an object");
273
- error.status.should.eql(400);
274
- }
275
- });
276
- });
277
-
278
- it('throws in case type is unknown', async function () {
279
- try {
280
- await client.create('domain.com', 'wrong type',
281
- { address: 'myaddress' });
282
- } catch (error: any) {
283
- error.message.should.eql('Unknown type value');
284
- error.details.should.eql('Type may be only one of [bounces, complaints, unsubscribes, whitelists]');
285
- error.status.should.eql(400);
286
- }
287
- });
288
- });
289
-
290
- describe('destroy', function () {
291
- it('deletes suppression', function () {
292
- api.delete('/v3/domain.com/bounces/my%3F%40address.com').reply(200, {
293
- message: 'Bounced address has been removed',
294
- address: 'my?@address.com'
295
- });
296
-
297
- return client.destroy('domain.com', 'bounces', 'my?@address.com')
298
- .then(function (data: { address: string }) {
299
- data.address.should.eql('my?@address.com');
300
- });
301
- });
302
- });
303
- });
@@ -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
- });
@@ -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
- });