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.
Files changed (314) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +15 -3
  3. package/client.d.ts +29 -0
  4. package/domains.d.ts +53 -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 -83
  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} +32 -53
  18. package/{lib/interfaces/Events.ts → interfaces/Events.d.ts} +11 -12
  19. package/interfaces/IFormData.d.ts +7 -0
  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/{lib/interfaces/MultipleValidation.ts → interfaces/MultipleValidation.d.ts} +9 -16
  24. package/interfaces/Options.d.ts +8 -0
  25. package/{lib/interfaces/RequestOptions.ts → interfaces/RequestOptions.d.ts} +2 -4
  26. package/interfaces/StatsOptions.d.ts +22 -0
  27. package/interfaces/Supressions.d.ts +103 -0
  28. package/{lib/interfaces/Validate.ts → interfaces/Validate.d.ts} +0 -3
  29. package/{lib/interfaces/Webhooks.ts → interfaces/Webhooks.d.ts} +11 -17
  30. package/{lib/interfaces/lists.ts → interfaces/lists.d.ts} +1 -5
  31. package/{lib/interfaces/mailListMembers.ts → interfaces/mailListMembers.d.ts} +8 -23
  32. package/{lib/interfaces/routes.ts → interfaces/routes.d.ts} +1 -6
  33. package/ip-pools.d.ts +21 -0
  34. package/ips.d.ts +9 -0
  35. package/lists.d.ts +14 -0
  36. package/mailListMembers.d.ts +14 -0
  37. package/mailgun.node.js +3 -0
  38. package/{dist/mailgun.node.js.LICENSE.txt → mailgun.node.js.LICENSE.txt} +1 -1
  39. package/mailgun.web.js +3 -0
  40. package/{dist/mailgun.web.js.LICENSE.txt → mailgun.web.js.LICENSE.txt} +1 -3
  41. package/messages.d.ts +9 -0
  42. package/multipleValidation.d.ts +10 -0
  43. package/package.json +9 -83
  44. package/request.d.ts +31 -0
  45. package/routes.d.ts +11 -0
  46. package/stats.d.ts +20 -0
  47. package/suppressions.d.ts +50 -0
  48. package/validate.d.ts +9 -0
  49. package/version.md +1 -0
  50. package/webhooks.d.ts +32 -0
  51. package/.editorconfig +0 -10
  52. package/.eslintrc +0 -56
  53. package/.husky/commit-msg +0 -4
  54. package/.travis.yml +0 -5
  55. package/LICENSE +0 -191
  56. package/commitlint.config.js +0 -7
  57. package/dist/mailgun.js.d.ts +0 -1572
  58. package/dist/mailgun.node.js +0 -3
  59. package/dist/mailgun.web.js +0 -3
  60. package/docs/.nojekyll +0 -1
  61. package/docs/assets/highlight.css +0 -127
  62. package/docs/assets/icons.css +0 -1043
  63. package/docs/assets/icons.png +0 -0
  64. package/docs/assets/icons@2x.png +0 -0
  65. package/docs/assets/main.js +0 -52
  66. package/docs/assets/search.js +0 -1
  67. package/docs/assets/style.css +0 -1413
  68. package/docs/assets/widgets.png +0 -0
  69. package/docs/assets/widgets@2x.png +0 -0
  70. package/docs/classes/client.default.html +0 -1
  71. package/docs/classes/domains.Domain.html +0 -1
  72. package/docs/classes/domains.default.html +0 -1
  73. package/docs/classes/domainsCredentials.default.html +0 -1
  74. package/docs/classes/domainsTemplates.DomainTemplateItem.html +0 -1
  75. package/docs/classes/domainsTemplates.default.html +0 -1
  76. package/docs/classes/error.default.html +0 -6
  77. package/docs/classes/events.default.html +0 -1
  78. package/docs/classes/ip_pools.default.html +0 -1
  79. package/docs/classes/ips.default.html +0 -1
  80. package/docs/classes/lists.default.html +0 -1
  81. package/docs/classes/mailListMembers.default.html +0 -1
  82. package/docs/classes/messages.default.html +0 -1
  83. package/docs/classes/multipleValidation.default.html +0 -1
  84. package/docs/classes/request.default.html +0 -1
  85. package/docs/classes/routes.default.html +0 -1
  86. package/docs/classes/stats.default.html +0 -1
  87. package/docs/classes/suppressions.default.html +0 -1
  88. package/docs/classes/validate.default.html +0 -1
  89. package/docs/classes/webhooks.default.html +0 -1
  90. package/docs/enums/interfaces_DomainTemplates.Pages.html +0 -1
  91. package/docs/enums/interfaces_DomainTemplates.YesNo.html +0 -1
  92. package/docs/index.html +0 -1140
  93. package/docs/interfaces/interfaces_APIErrorOptions.default.html +0 -1
  94. package/docs/interfaces/interfaces_ApiResponse.default.html +0 -1
  95. package/docs/interfaces/interfaces_DomainCredentials.CreatedUpdatedDomainCredentialsResponse.html +0 -1
  96. package/docs/interfaces/interfaces_DomainCredentials.DeletedDomainCredentialsResponse.html +0 -1
  97. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentials.html +0 -1
  98. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsItem.html +0 -1
  99. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsList.html +0 -1
  100. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsQuery.html +0 -1
  101. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsResponseData.html +0 -1
  102. package/docs/interfaces/interfaces_DomainCredentials.DomainCredentialsResult.html +0 -1
  103. package/docs/interfaces/interfaces_DomainCredentials.IDomainCredentials.html +0 -1
  104. package/docs/interfaces/interfaces_DomainCredentials.UpdateDomainCredentialsData.html +0 -1
  105. package/docs/interfaces/interfaces_DomainTemplates.CreateDomainTemplateAPIResponse.html +0 -1
  106. package/docs/interfaces/interfaces_DomainTemplates.CreateDomainTemplateVersionAPIResponse.html +0 -1
  107. package/docs/interfaces/interfaces_DomainTemplates.CreateDomainTemplateVersionResult.html +0 -1
  108. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplate.html +0 -1
  109. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateData.html +0 -1
  110. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateUpdateData.html +0 -1
  111. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateUpdateVersionData.html +0 -1
  112. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplateVersionData.html +0 -1
  113. package/docs/interfaces/interfaces_DomainTemplates.DomainTemplatesQuery.html +0 -1
  114. package/docs/interfaces/interfaces_DomainTemplates.GetDomainTemplateAPIResponse.html +0 -1
  115. package/docs/interfaces/interfaces_DomainTemplates.IDomainTemplatesClient.html +0 -1
  116. package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplateVersionsAPIResponse.html +0 -1
  117. package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplateVersionsResult.html +0 -1
  118. package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplatesAPIResponse.html +0 -1
  119. package/docs/interfaces/interfaces_DomainTemplates.ListDomainTemplatesResult.html +0 -1
  120. package/docs/interfaces/interfaces_DomainTemplates.MutateDomainTemplateVersionAPIResponse.html +0 -1
  121. package/docs/interfaces/interfaces_DomainTemplates.MutateDomainTemplateVersionResult.html +0 -1
  122. package/docs/interfaces/interfaces_DomainTemplates.NotificationAPIResponse.html +0 -1
  123. package/docs/interfaces/interfaces_DomainTemplates.NotificationResult.html +0 -1
  124. package/docs/interfaces/interfaces_DomainTemplates.ShortTemplateVersion.html +0 -1
  125. package/docs/interfaces/interfaces_DomainTemplates.TemplateQuery.html +0 -1
  126. package/docs/interfaces/interfaces_DomainTemplates.TemplateVersion.html +0 -1
  127. package/docs/interfaces/interfaces_DomainTemplates.UpdateOrDeleteDomainTemplateAPIResponse.html +0 -1
  128. package/docs/interfaces/interfaces_DomainTemplates.UpdateOrDeleteDomainTemplateResult.html +0 -1
  129. package/docs/interfaces/interfaces_DomainTracking.ClickTrackingInfo.html +0 -1
  130. package/docs/interfaces/interfaces_DomainTracking.DomainTrackingData.html +0 -1
  131. package/docs/interfaces/interfaces_DomainTracking.DomainTrackingResponse.html +0 -1
  132. package/docs/interfaces/interfaces_DomainTracking.OpenTrackingInfo.html +0 -1
  133. package/docs/interfaces/interfaces_DomainTracking.UnsubscribeTrackingInfo.html +0 -1
  134. package/docs/interfaces/interfaces_DomainTracking.UpdateDomainTrackingResponse.html +0 -1
  135. package/docs/interfaces/interfaces_DomainTracking.UpdatedOpenTracking.html +0 -1
  136. package/docs/interfaces/interfaces_Domains.ConnectionSettings.html +0 -1
  137. package/docs/interfaces/interfaces_Domains.ConnectionSettingsResponse.html +0 -1
  138. package/docs/interfaces/interfaces_Domains.DKIMAuthorityInfo.html +0 -1
  139. package/docs/interfaces/interfaces_Domains.DKIMSelectorInfo.html +0 -1
  140. package/docs/interfaces/interfaces_Domains.DNSRecord.html +0 -1
  141. package/docs/interfaces/interfaces_Domains.DestroyedDomainResponse.html +0 -1
  142. package/docs/interfaces/interfaces_Domains.DomainData.html +0 -1
  143. package/docs/interfaces/interfaces_Domains.DomainInfo.html +0 -1
  144. package/docs/interfaces/interfaces_Domains.DomainListResponseData.html +0 -1
  145. package/docs/interfaces/interfaces_Domains.DomainResponseData.html +0 -1
  146. package/docs/interfaces/interfaces_Domains.DomainShortData.html +0 -1
  147. package/docs/interfaces/interfaces_Domains.DomainsListItem.html +0 -1
  148. package/docs/interfaces/interfaces_Domains.DomainsQuery.html +0 -1
  149. package/docs/interfaces/interfaces_Domains.MessageResponse.html +0 -1
  150. package/docs/interfaces/interfaces_Domains.ReplacementForPool.html +0 -1
  151. package/docs/interfaces/interfaces_Domains.UpdatedConnectionSettings.html +0 -1
  152. package/docs/interfaces/interfaces_Domains.UpdatedConnectionSettingsRes.html +0 -1
  153. package/docs/interfaces/interfaces_Domains.UpdatedDKIMAuthority.html +0 -1
  154. package/docs/interfaces/interfaces_Domains.UpdatedDKIMAuthorityResponse.html +0 -1
  155. package/docs/interfaces/interfaces_Domains.UpdatedDKIMSelectorResponse.html +0 -1
  156. package/docs/interfaces/interfaces_Domains.UpdatedWebPrefix.html +0 -1
  157. package/docs/interfaces/interfaces_Domains.UpdatedWebPrefixResponse.html +0 -1
  158. package/docs/interfaces/interfaces_Domains.WebPrefixInfo.html +0 -1
  159. package/docs/interfaces/interfaces_Events.DomainEvent.html +0 -1
  160. package/docs/interfaces/interfaces_Events.EventsList.html +0 -1
  161. package/docs/interfaces/interfaces_Events.EventsPage.html +0 -1
  162. package/docs/interfaces/interfaces_Events.EventsResponse.html +0 -1
  163. package/docs/interfaces/interfaces_Events.PagesList.html +0 -1
  164. package/docs/interfaces/interfaces_Events.PagesListAccumulator.html +0 -1
  165. package/docs/interfaces/interfaces_Events.ParsedPage.html +0 -1
  166. package/docs/interfaces/interfaces_Events.ParsedPagesList.html +0 -1
  167. package/docs/interfaces/interfaces_IFormData.IFormDataOptions.html +0 -1
  168. package/docs/interfaces/interfaces_IFormData.InputFormData.html +0 -1
  169. package/docs/interfaces/interfaces_IpPools.IpPool.html +0 -1
  170. package/docs/interfaces/interfaces_IpPools.IpPoolListResponse.html +0 -1
  171. package/docs/interfaces/interfaces_IpPools.IpPoolUpdateData.html +0 -1
  172. package/docs/interfaces/interfaces_Ips.IpData.html +0 -1
  173. package/docs/interfaces/interfaces_Ips.IpsListResponseBody.html +0 -1
  174. package/docs/interfaces/interfaces_MultipleValidation.CanceledMultipleValidationJob.html +0 -1
  175. package/docs/interfaces/interfaces_MultipleValidation.CreatedMultipleValidationJob.html +0 -1
  176. package/docs/interfaces/interfaces_MultipleValidation.IMultipleValidationClient.html +0 -1
  177. package/docs/interfaces/interfaces_MultipleValidation.MultipleValidationJob.html +0 -1
  178. package/docs/interfaces/interfaces_MultipleValidation.MultipleValidationJobsListResponse.html +0 -1
  179. package/docs/interfaces/interfaces_MultipleValidation.MultipleValidationJobsListResult.html +0 -1
  180. package/docs/interfaces/interfaces_MultipleValidation.PagesList.html +0 -1
  181. package/docs/interfaces/interfaces_Options.default.html +0 -1
  182. package/docs/interfaces/interfaces_RequestOptions.default.html +0 -1
  183. package/docs/interfaces/interfaces_StatsOptions.Stat.html +0 -1
  184. package/docs/interfaces/interfaces_StatsOptions.StatsOptions.html +0 -1
  185. package/docs/interfaces/interfaces_StatsOptions.StatsQuery.html +0 -1
  186. package/docs/interfaces/interfaces_Supressions.BounceData.html +0 -1
  187. package/docs/interfaces/interfaces_Supressions.ComplaintData.html +0 -1
  188. package/docs/interfaces/interfaces_Supressions.UnsubscribeData.html +0 -1
  189. package/docs/interfaces/interfaces_Supressions.WhiteListData.html +0 -1
  190. package/docs/interfaces/interfaces_Validate.ValidationResponse.html +0 -1
  191. package/docs/interfaces/interfaces_Validate.ValidationResult.html +0 -1
  192. package/docs/interfaces/interfaces_Webhooks.APIWebhook.html +0 -1
  193. package/docs/interfaces/interfaces_Webhooks.ValidationResponse.html +0 -1
  194. package/docs/interfaces/interfaces_Webhooks.WebhookList.html +0 -1
  195. package/docs/interfaces/interfaces_Webhooks.WebhookResponse.html +0 -1
  196. package/docs/interfaces/interfaces_Webhooks.WebhookResponseBody.html +0 -1
  197. package/docs/interfaces/interfaces_Webhooks.WebhooksQuery.html +0 -1
  198. package/docs/interfaces/interfaces_lists.CreateUpdateList.html +0 -1
  199. package/docs/interfaces/interfaces_lists.DestroyedList.html +0 -1
  200. package/docs/interfaces/interfaces_lists.ListsQuery.html +0 -1
  201. package/docs/interfaces/interfaces_lists.MailingList.html +0 -1
  202. package/docs/interfaces/interfaces_mailListMembers.CreateUpdateMailListMembers.html +0 -1
  203. package/docs/interfaces/interfaces_mailListMembers.CreateUpdateMailListMembersReq.html +0 -1
  204. package/docs/interfaces/interfaces_mailListMembers.DeletedMember.html +0 -1
  205. package/docs/interfaces/interfaces_mailListMembers.IMailListsMembers.html +0 -1
  206. package/docs/interfaces/interfaces_mailListMembers.MailListMember.html +0 -1
  207. package/docs/interfaces/interfaces_mailListMembers.MailListMembersQuery.html +0 -1
  208. package/docs/interfaces/interfaces_mailListMembers.MultipleMembersData.html +0 -1
  209. package/docs/interfaces/interfaces_mailListMembers.MultipleMembersReqData.html +0 -1
  210. package/docs/interfaces/interfaces_mailListMembers.NewMultipleMembersResponse.html +0 -1
  211. package/docs/interfaces/interfaces_routes.CreateUpdateRouteData.html +0 -1
  212. package/docs/interfaces/interfaces_routes.DestroyRouteResponse.html +0 -1
  213. package/docs/interfaces/interfaces_routes.Route.html +0 -1
  214. package/docs/interfaces/interfaces_routes.RoutesListQuery.html +0 -1
  215. package/docs/interfaces/interfaces_routes.UpdateRouteResponse.html +0 -1
  216. package/docs/modules/client.html +0 -1
  217. package/docs/modules/domains.html +0 -1
  218. package/docs/modules/domainsCredentials.html +0 -1
  219. package/docs/modules/domainsTemplates.html +0 -1
  220. package/docs/modules/error.html +0 -1
  221. package/docs/modules/events.html +0 -1
  222. package/docs/modules/interfaces_APIErrorOptions.html +0 -1
  223. package/docs/modules/interfaces_ApiResponse.html +0 -1
  224. package/docs/modules/interfaces_DomainCredentials.html +0 -1
  225. package/docs/modules/interfaces_DomainTemplates.html +0 -1
  226. package/docs/modules/interfaces_DomainTracking.html +0 -1
  227. package/docs/modules/interfaces_Domains.html +0 -1
  228. package/docs/modules/interfaces_Events.html +0 -1
  229. package/docs/modules/interfaces_IFormData.html +0 -1
  230. package/docs/modules/interfaces_IpPools.html +0 -1
  231. package/docs/modules/interfaces_Ips.html +0 -1
  232. package/docs/modules/interfaces_MultipleValidation.html +0 -1
  233. package/docs/modules/interfaces_Options.html +0 -1
  234. package/docs/modules/interfaces_RequestOptions.html +0 -1
  235. package/docs/modules/interfaces_StatsOptions.html +0 -1
  236. package/docs/modules/interfaces_Supressions.html +0 -1
  237. package/docs/modules/interfaces_Validate.html +0 -1
  238. package/docs/modules/interfaces_Webhooks.html +0 -1
  239. package/docs/modules/interfaces_lists.html +0 -1
  240. package/docs/modules/interfaces_mailListMembers.html +0 -1
  241. package/docs/modules/interfaces_routes.html +0 -1
  242. package/docs/modules/ip_pools.html +0 -1
  243. package/docs/modules/ips.html +0 -1
  244. package/docs/modules/lists.html +0 -1
  245. package/docs/modules/mailListMembers.html +0 -1
  246. package/docs/modules/messages.html +0 -1
  247. package/docs/modules/multipleValidation.html +0 -1
  248. package/docs/modules/request.html +0 -1
  249. package/docs/modules/routes.html +0 -1
  250. package/docs/modules/stats.html +0 -1
  251. package/docs/modules/suppressions.html +0 -1
  252. package/docs/modules/validate.html +0 -1
  253. package/docs/modules/webhooks.html +0 -1
  254. package/docs/modules.html +0 -1
  255. package/dts-bundle.js +0 -8
  256. package/examples/addresses.js +0 -20
  257. package/examples/index.html +0 -285
  258. package/examples/list-domains.js +0 -8
  259. package/examples/mailgun.png +0 -0
  260. package/examples/rackspace.png +0 -0
  261. package/examples/send-email.js +0 -24
  262. package/lib/client.ts +0 -79
  263. package/lib/domains.ts +0 -224
  264. package/lib/domainsCredentials.ts +0 -88
  265. package/lib/domainsTags.ts +0 -165
  266. package/lib/domainsTemplates.ts +0 -235
  267. package/lib/error.ts +0 -22
  268. package/lib/events.ts +0 -54
  269. package/lib/index.ts +0 -17
  270. package/lib/interfaces/APIErrorOptions.ts +0 -10
  271. package/lib/interfaces/IFormData.ts +0 -9
  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 -23
  276. package/lib/interfaces/Supressions.ts +0 -86
  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 -198
  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 -219
  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 -47
  313. package/webpack/webpack.dev.config.js +0 -28
  314. package/webpack/webpack.release.config.js +0 -37
package/lib/stats.ts DELETED
@@ -1,62 +0,0 @@
1
- import urljoin from 'url-join';
2
- import Request from './request';
3
- import { StatsQuery, StatsOptions, Stat } from './interfaces/StatsOptions';
4
-
5
- class Stats {
6
- start: Date;
7
- end: Date;
8
- resolution: string;
9
- stats: Stat[];
10
-
11
- constructor(data: StatsOptions) {
12
- this.start = new Date(data.start);
13
- this.end = new Date(data.end);
14
- this.resolution = data.resolution;
15
- this.stats = data.stats.map(function (stat: Stat) {
16
- const res = { ...stat };
17
- res.time = new Date(stat.time);
18
- return res;
19
- });
20
- }
21
- }
22
-
23
- export default class StatsClient {
24
- request: Request;
25
-
26
- constructor(request: Request) {
27
- this.request = request;
28
- }
29
-
30
- private prepareSearchParams(query: StatsQuery | undefined): Array<Array<string>> {
31
- let searchParams = [] as Array<Array<string>>;
32
- if (typeof query === 'object' && Object.keys(query).length) {
33
- searchParams = Object.entries(query).reduce((arrayWithPairs, currentPair) => {
34
- const [key, value] = currentPair;
35
- if (Array.isArray(value) && value.length) {
36
- const repeatedProperty = value.map((item) => [key, item]);
37
- return [...arrayWithPairs, ...repeatedProperty];
38
- }
39
- arrayWithPairs.push([key, value]);
40
- return arrayWithPairs;
41
- }, [] as Array<Array<string>>);
42
- }
43
-
44
- return searchParams;
45
- }
46
-
47
- _parseStats(response: { body: StatsOptions }): Stats {
48
- return new Stats(response.body);
49
- }
50
-
51
- getDomain(domain: string, query?: StatsQuery): Promise<Stats> {
52
- const searchParams = this.prepareSearchParams(query);
53
- return this.request.get(urljoin('/v3', domain, 'stats/total'), searchParams)
54
- .then(this._parseStats);
55
- }
56
-
57
- getAccount(query?: StatsQuery): Promise<Stats> {
58
- const searchParams = this.prepareSearchParams(query);
59
- return this.request.get('/v3/stats/total', searchParams)
60
- .then(this._parseStats);
61
- }
62
- }
@@ -1,198 +0,0 @@
1
- /* eslint-disable camelcase */
2
- import url from 'url';
3
- import urljoin from 'url-join';
4
-
5
- import Request from './request';
6
- import {
7
- BounceData,
8
- ComplaintData,
9
- IBounce,
10
- IComplaint,
11
- IUnsubscribe,
12
- IWhiteList,
13
- PagesList,
14
- PagesListAccumulator,
15
- ParsedPage,
16
- ParsedPagesList,
17
- SuppressionList,
18
- SuppressionModels,
19
- UnsubscribeData,
20
- WhiteListData
21
- } from './interfaces/Supressions';
22
-
23
- const createOptions = {
24
- headers: { 'Content-Type': 'application/json' }
25
- };
26
-
27
- class Bounce implements IBounce {
28
- type: string;
29
- address: string;
30
- code: number;
31
- error: string;
32
- created_at: Date;
33
-
34
- constructor(data: BounceData) {
35
- this.type = 'bounces';
36
- this.address = data.address;
37
- this.code = +data.code;
38
- this.error = data.error;
39
- this.created_at = new Date(data.created_at);
40
- }
41
- }
42
-
43
- class Complaint implements IComplaint {
44
- type: string;
45
- address: any;
46
- created_at: Date;
47
-
48
- constructor(data: ComplaintData) {
49
- this.type = 'complaints';
50
- this.address = data.address;
51
- this.created_at = new Date(data.created_at);
52
- }
53
- }
54
-
55
- class Unsubscribe implements IUnsubscribe {
56
- type: string;
57
- address: string;
58
- tags: any;
59
- created_at: Date;
60
-
61
- constructor(data: UnsubscribeData) {
62
- this.type = 'unsubscribes';
63
- this.address = data.address;
64
- this.tags = data.tags;
65
- this.created_at = new Date(data.created_at);
66
- }
67
- }
68
-
69
- class WhiteList implements IWhiteList {
70
- type: string;
71
- value: string;
72
- reason: string;
73
- createdAt: Date;
74
-
75
- constructor(data: WhiteListData) {
76
- this.type = 'whitelists';
77
- this.value = data.value;
78
- this.reason = data.reason;
79
- this.createdAt = new Date(data.createdAt);
80
- }
81
- }
82
-
83
- type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe | typeof WhiteList;
84
-
85
- export default class SuppressionClient {
86
- request: any;
87
- models: {
88
- bounces: typeof Bounce;
89
- complaints: typeof Complaint;
90
- unsubscribes: typeof Unsubscribe;
91
- whitelists: typeof WhiteList;
92
- };
93
-
94
- constructor(request: Request) {
95
- this.request = request;
96
- this.models = {
97
- bounces: Bounce,
98
- complaints: Complaint,
99
- unsubscribes: Unsubscribe,
100
- whitelists: WhiteList,
101
- };
102
- }
103
-
104
- _parsePage(id: string, pageUrl: string) : ParsedPage {
105
- const parsedUrl = url.parse(pageUrl, true);
106
- const { query } = parsedUrl;
107
-
108
- return {
109
- id,
110
- page: query.page as string,
111
- address: query.address as string,
112
- url: pageUrl
113
- };
114
- }
115
-
116
- _parsePageLinks(response: { body: { paging: any } }): ParsedPagesList {
117
- const pages = Object.entries(response.body.paging as PagesList);
118
- return pages.reduce(
119
- (acc: PagesListAccumulator, pair: [pageUrl: string, id: string]) => {
120
- const id = pair[0];
121
- const pageUrl = pair[1];
122
- acc[id] = this._parsePage(id, pageUrl);
123
- return acc;
124
- }, {}
125
- ) as unknown as ParsedPagesList;
126
- }
127
-
128
- _parseList(
129
- response: { body: { items: any, paging: any } }, Model: TModel
130
- ): SuppressionList {
131
- const data = {} as SuppressionList;
132
-
133
- data.items = response.body.items.map((d: any) => new Model(d));
134
-
135
- data.pages = this._parsePageLinks(response);
136
-
137
- return data;
138
- }
139
-
140
- _parseItem(
141
- response: { body: any },
142
- Model: TModel
143
- ): IBounce | IComplaint | IUnsubscribe | IWhiteList {
144
- return new Model(response.body);
145
- }
146
-
147
- private createWhiteList(domain: string, data: any) {
148
- return this.request
149
- .postWithFD(urljoin('v3', domain, 'whitelists'), data, createOptions)
150
- .then((response: { body: any }) => response.body);
151
- }
152
-
153
- list(domain: string, type: SuppressionModels, query: any) : Promise<SuppressionList> {
154
- const model = (this.models)[type];
155
-
156
- return this.request
157
- .get(urljoin('v3', domain, type), query)
158
- .then((response: { body: { items: any, paging: any } }) => this._parseList(response, model));
159
- }
160
-
161
- get(
162
- domain: string,
163
- type: SuppressionModels,
164
- address: string
165
- ): Promise<IBounce | IComplaint | IUnsubscribe | IWhiteList> {
166
- const model = (this.models)[type];
167
-
168
- return this.request
169
- .get(urljoin('v3', domain, type, encodeURIComponent(address)))
170
- .then((response: { body: any }) => this._parseItem(response, model));
171
- }
172
-
173
- create(domain: string, type: string, data: any) {
174
- // supports adding multiple suppressions by default
175
- let postData;
176
- if (type === 'whitelists') {
177
- return this.createWhiteList(domain, data);
178
- }
179
-
180
- if (!Array.isArray(data)) {
181
- postData = [data];
182
- } else {
183
- postData = [...data];
184
- }
185
-
186
- return this.request
187
- .post(urljoin('v3', domain, type), JSON.stringify(postData), createOptions)
188
- .then((response: { body: any }) => response.body);
189
- }
190
-
191
- destroy(domain: string, type: string, address: string) {
192
- return this.request
193
- .delete(urljoin('v3', domain, type, encodeURIComponent(address)))
194
- .then((response: { body: any }) => response.body);
195
- }
196
- }
197
-
198
- module.exports = SuppressionClient;
package/lib/validate.ts DELETED
@@ -1,20 +0,0 @@
1
- import APIResponse from './interfaces/ApiResponse';
2
- import { IMultipleValidationClient } from './interfaces/MultipleValidation';
3
- import { ValidationResult, ValidationResponse } from './interfaces/Validate';
4
- import Request from './request';
5
-
6
- export default class ValidateClient {
7
- public multipleValidation;
8
- request: Request;
9
-
10
- constructor(request: Request, multipleValidationClient: IMultipleValidationClient) {
11
- this.request = request;
12
- this.multipleValidation = multipleValidationClient;
13
- }
14
-
15
- get(address: string): Promise<ValidationResult> {
16
- return this.request.get('/v4/address/validate', { address })
17
- .then((response : APIResponse) => response)
18
- .then((res : ValidationResponse) => res.body as ValidationResult);
19
- }
20
- }
package/lib/webhooks.ts DELETED
@@ -1,83 +0,0 @@
1
- import urljoin from 'url-join';
2
-
3
- import {
4
- ValidationResponse,
5
- WebhookList,
6
- WebhookResponse,
7
- WebhooksIds,
8
- WebhooksQuery
9
- } from './interfaces/Webhooks';
10
- import Request from './request';
11
-
12
- class Webhook {
13
- id: string;
14
- url: string | undefined;
15
-
16
- constructor(id: string, url: string | undefined) {
17
- this.id = id;
18
- this.url = url;
19
- }
20
- }
21
-
22
- export default class WebhookClient {
23
- request: Request;
24
-
25
- constructor(request: Request) {
26
- this.request = request;
27
- }
28
-
29
- _parseWebhookList(response: { body: { webhooks: WebhookList } }): WebhookList {
30
- return response.body.webhooks;
31
- }
32
-
33
- _parseWebhookWithID(id: string) {
34
- return function (response: WebhookResponse): Webhook {
35
- const webhookResponse = response?.body?.webhook;
36
- let url = webhookResponse?.url;
37
- if (!url) {
38
- url = webhookResponse?.urls && webhookResponse.urls.length
39
- ? webhookResponse.urls[0]
40
- : undefined;
41
- }
42
- return new Webhook(id, url);
43
- };
44
- }
45
-
46
- _parseWebhookTest(response: { body: { code: number, message: string } })
47
- : {code: number, message:string} {
48
- return { code: response.body.code, message: response.body.message } as ValidationResponse;
49
- }
50
-
51
- list(domain: string, query: WebhooksQuery): Promise<WebhookList> {
52
- return this.request.get(urljoin('/v3/domains', domain, 'webhooks'), query)
53
- .then(this._parseWebhookList);
54
- }
55
-
56
- get(domain: string, id: WebhooksIds): Promise<Webhook> {
57
- return this.request.get(urljoin('/v3/domains', domain, 'webhooks', id))
58
- .then(this._parseWebhookWithID(id));
59
- }
60
-
61
- create(domain: string,
62
- id: string,
63
- url: string,
64
- test = false): Promise<Webhook | ValidationResponse> {
65
- if (test) {
66
- return this.request.putWithFD(urljoin('/v3/domains', domain, 'webhooks', id, 'test'), { url })
67
- .then(this._parseWebhookTest);
68
- }
69
-
70
- return this.request.postWithFD(urljoin('/v3/domains', domain, 'webhooks'), { id, url })
71
- .then(this._parseWebhookWithID(id));
72
- }
73
-
74
- update(domain: string, id: string, url: string): Promise<Webhook> {
75
- return this.request.putWithFD(urljoin('/v3/domains', domain, 'webhooks', id), { url })
76
- .then(this._parseWebhookWithID(id));
77
- }
78
-
79
- destroy(domain: string, id: string) : Promise<Webhook> {
80
- return this.request.delete(urljoin('/v3/domains', domain, 'webhooks', id))
81
- .then(this._parseWebhookWithID(id));
82
- }
83
- }
@@ -1,96 +0,0 @@
1
- import formData from 'form-data';
2
-
3
- import { expect } from 'chai';
4
-
5
- import Client from '../lib/client';
6
- import Request from '../lib/request';
7
- import DomainsClient from '../lib/domains';
8
- import EventsClient from '../lib/events';
9
- import WebhooksClient from '../lib/webhooks';
10
- import SuppressionsClient from '../lib/suppressions';
11
- import MessagesClient from '../lib/messages';
12
- import RoutesClient from '../lib/routes';
13
- import ValidateClient from '../lib/validate';
14
-
15
- import { InputFormData } from '../lib/interfaces/IFormData';
16
- import StatsClient from '../lib/stats';
17
- import ListsClient from '../lib/lists';
18
- import IpPoolsClient from '../lib/ip-pools';
19
- import IpsClient from '../lib/ips';
20
-
21
- describe('Client', function () {
22
- let client: any;
23
-
24
- beforeEach(function () {
25
- client = new Client({
26
- username: 'username',
27
- key: 'key',
28
- public_key: 'key',
29
- timeout: 10000
30
- }, formData as InputFormData);
31
- });
32
-
33
- it('raises error when username is not provided', function () {
34
- expect(
35
- function () {
36
- return new Client({ key: 'key' } as any, formData as InputFormData);
37
- }
38
- ).to.throw('Parameter "username" is required');
39
- });
40
-
41
- it('raises error when key is not provided', function () {
42
- expect(
43
- function () {
44
- return new Client({ username: 'username' } as any, formData as InputFormData);
45
- }
46
- ).to.throw('Parameter "key" is required');
47
- });
48
-
49
- it('exposes raw request client', function () {
50
- client.request.should.be.instanceOf(Request);
51
- });
52
-
53
- it('creates domain client', function () {
54
- client.domains.should.be.instanceOf(DomainsClient);
55
- });
56
-
57
- it('creates event client', function () {
58
- client.events.should.be.instanceOf(EventsClient);
59
- });
60
-
61
- it('creates webhook client', function () {
62
- client.webhooks.should.be.instanceOf(WebhooksClient);
63
- });
64
-
65
- it('creates suppressions client', function () {
66
- client.suppressions.should.be.instanceOf(SuppressionsClient);
67
- });
68
-
69
- it('creates stats client', function () {
70
- client.stats.should.be.instanceOf(StatsClient);
71
- });
72
-
73
- it('creates messages client', function () {
74
- client.messages.should.be.instanceOf(MessagesClient);
75
- });
76
-
77
- it('creates routes client', function () {
78
- client.routes.should.be.instanceOf(RoutesClient);
79
- });
80
-
81
- it('creates ips client', function () {
82
- client.ips.should.be.instanceOf(IpsClient);
83
- });
84
-
85
- it('creates ip_pools client', function () {
86
- client.ip_pools.should.be.instanceOf(IpPoolsClient);
87
- });
88
-
89
- it('creates lists client', function () {
90
- client.lists.should.be.instanceOf(ListsClient);
91
- });
92
-
93
- it('creates address validate client', function () {
94
- client.validate.should.be.instanceOf(ValidateClient);
95
- });
96
- });
@@ -1,3 +0,0 @@
1
- email
2
- 1testEmailAdressForCheck@test.com
3
- 2testEmailAdressForCheck@test.com