mailgun.js 8.2.2 → 9.0.1

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 (136) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/Classes/Domains/domain.d.ts +16 -0
  3. package/{domains.d.ts → Classes/Domains/domains.d.ts} +5 -8
  4. package/Classes/Domains/domainsClient.d.ts +36 -0
  5. package/{domainsCredentials.d.ts → Classes/Domains/domainsCredentials.d.ts} +3 -2
  6. package/{domainsTags.d.ts → Classes/Domains/domainsTags.d.ts} +6 -4
  7. package/{domainsTemplates.d.ts → Classes/Domains/domainsTemplates.d.ts} +9 -8
  8. package/{events.d.ts → Classes/Events.d.ts} +4 -3
  9. package/{ip-pools.d.ts → Classes/IPPools.d.ts} +4 -3
  10. package/Classes/IPs.d.ts +10 -0
  11. package/Classes/MailgunClient.d.ts +18 -0
  12. package/{mailListMembers.d.ts → Classes/MailingLists/mailListMembers.d.ts} +4 -3
  13. package/Classes/MailingLists/mailingLists.d.ts +21 -0
  14. package/{messages.d.ts → Classes/Messages.d.ts} +4 -3
  15. package/{routes.d.ts → Classes/Routes.d.ts} +4 -3
  16. package/Classes/Stats/StatsClient.d.ts +14 -0
  17. package/Classes/Stats/StatsContainer.d.ts +9 -0
  18. package/Classes/Suppressions/Bounce.d.ts +10 -0
  19. package/Classes/Suppressions/Complaint.d.ts +8 -0
  20. package/Classes/Suppressions/Suppression.d.ts +5 -0
  21. package/Classes/Suppressions/SuppressionsClient.d.ts +23 -0
  22. package/Classes/Suppressions/Unsubscribe.d.ts +9 -0
  23. package/Classes/Suppressions/WhiteList.d.ts +9 -0
  24. package/{multipleValidation.d.ts → Classes/Validations/multipleValidation.d.ts} +4 -3
  25. package/Classes/Validations/validate.d.ts +9 -0
  26. package/Classes/Webhooks.d.ts +21 -0
  27. package/Classes/common/Error.d.ts +8 -0
  28. package/{formDataBuilder.d.ts → Classes/common/FormDataBuilder.d.ts} +1 -1
  29. package/Classes/common/NavigationThruPages.d.ts +17 -0
  30. package/{request.d.ts → Classes/common/Request.d.ts} +2 -4
  31. package/Enums/index.d.ts +24 -0
  32. package/Interfaces/Common/Logger.d.ts +3 -0
  33. package/Interfaces/Common/index.d.ts +1 -0
  34. package/Interfaces/Domains/DomainCredentials.d.ts +7 -0
  35. package/Interfaces/Domains/DomainTags.d.ts +20 -0
  36. package/Interfaces/Domains/DomainTemplates.d.ts +23 -0
  37. package/Interfaces/Domains/DomainsClient.d.ts +27 -0
  38. package/Interfaces/Domains/index.d.ts +4 -0
  39. package/Interfaces/EventClient/IEventClient.d.ts +4 -0
  40. package/Interfaces/EventClient/index.d.ts +1 -0
  41. package/Interfaces/IPPools/IIPPoolsClient.d.ts +7 -0
  42. package/Interfaces/IPPools/index.d.ts +1 -0
  43. package/Interfaces/IPs/IIPsClient.d.ts +5 -0
  44. package/Interfaces/IPs/index.d.ts +1 -0
  45. package/Interfaces/MailgunClient/IMailgunClient.d.ts +24 -0
  46. package/Interfaces/MailgunClient/index.d.ts +1 -0
  47. package/Interfaces/MailingLists/MailingListMembers.d.ts +9 -0
  48. package/Interfaces/MailingLists/MailingListsClient.d.ts +13 -0
  49. package/Interfaces/MailingLists/index.d.ts +2 -0
  50. package/Interfaces/Messages/IMessagesClient.d.ts +4 -0
  51. package/Interfaces/Messages/index.d.ts +1 -0
  52. package/Interfaces/Routes/IRoutesClient.d.ts +8 -0
  53. package/Interfaces/Routes/index.d.ts +1 -0
  54. package/Interfaces/Stats/StatsClient.d.ts +6 -0
  55. package/Interfaces/Stats/StatsContainer.d.ts +7 -0
  56. package/Interfaces/Stats/index.d.ts +2 -0
  57. package/{interfaces → Interfaces}/Suppressions/Bounce.d.ts +0 -6
  58. package/{interfaces → Interfaces}/Suppressions/Complaint.d.ts +0 -4
  59. package/Interfaces/Suppressions/ISuppressionsClient.d.ts +11 -0
  60. package/{interfaces → Interfaces}/Suppressions/Unsubscribe.d.ts +0 -5
  61. package/Interfaces/Suppressions/WhiteList.d.ts +6 -0
  62. package/Interfaces/Suppressions/index.d.ts +5 -0
  63. package/Interfaces/Validations/MultipleValidation.d.ts +7 -0
  64. package/Interfaces/Validations/Validation.d.ts +6 -0
  65. package/Interfaces/Validations/index.d.ts +2 -0
  66. package/Interfaces/Webhooks/IWebHooksClient.d.ts +9 -0
  67. package/Interfaces/Webhooks/index.d.ts +1 -0
  68. package/Interfaces/index.d.ts +13 -0
  69. package/README.md +42 -13
  70. package/Types/Common/ApiResponse.d.ts +4 -0
  71. package/Types/Common/Error.d.ts +19 -0
  72. package/Types/Common/FormData.d.ts +7 -0
  73. package/{interfaces → Types/Common}/NavigationThruPages.d.ts +14 -14
  74. package/{interfaces → Types/Common}/RequestOptions.d.ts +7 -7
  75. package/Types/Common/index.d.ts +5 -0
  76. package/Types/Domains/DomainCredentials.d.ts +46 -0
  77. package/{interfaces → Types/Domains}/DomainTags.d.ts +34 -57
  78. package/Types/Domains/DomainTemplates.d.ts +153 -0
  79. package/{interfaces → Types/Domains}/DomainTracking.d.ts +8 -8
  80. package/{interfaces → Types/Domains}/Domains.d.ts +50 -36
  81. package/Types/Domains/index.d.ts +5 -0
  82. package/{interfaces → Types/Events}/Events.d.ts +15 -15
  83. package/Types/Events/index.d.ts +1 -0
  84. package/{interfaces → Types/IPPools}/IpPools.d.ts +6 -6
  85. package/Types/IPPools/index.d.ts +1 -0
  86. package/{interfaces/Ips.d.ts → Types/IPs/IPs.d.ts} +7 -4
  87. package/Types/IPs/index.d.ts +1 -0
  88. package/{interfaces/Options.d.ts → Types/MailgunClient/MailgunClientOptions.d.ts} +2 -3
  89. package/Types/MailgunClient/index.d.ts +1 -0
  90. package/Types/MailingLists/MailingListMembers.d.ts +60 -0
  91. package/{interfaces/lists.d.ts → Types/MailingLists/MailingLists.d.ts} +22 -22
  92. package/Types/MailingLists/index.d.ts +2 -0
  93. package/{interfaces → Types/Messages}/Messages.d.ts +5 -5
  94. package/Types/Messages/index.d.ts +1 -0
  95. package/{interfaces/routes.d.ts → Types/Routes/Routes.d.ts} +6 -6
  96. package/Types/Routes/index.d.ts +1 -0
  97. package/{interfaces/StatsOptions.d.ts → Types/Stats/Stats.d.ts} +6 -6
  98. package/Types/Stats/index.d.ts +1 -0
  99. package/Types/Suppressions/Bounce.d.ts +6 -0
  100. package/Types/Suppressions/Complaint.d.ts +4 -0
  101. package/{interfaces → Types}/Suppressions/Suppressions.d.ts +19 -28
  102. package/Types/Suppressions/Unsubscribe.d.ts +5 -0
  103. package/Types/Suppressions/WhiteList.d.ts +6 -0
  104. package/Types/Suppressions/index.d.ts +5 -0
  105. package/{interfaces → Types/Validations}/MultipleValidation.d.ts +20 -26
  106. package/{interfaces/Validate.d.ts → Types/Validations/Validation.d.ts} +4 -4
  107. package/Types/Validations/index.d.ts +2 -0
  108. package/Types/Webhooks/Webhooks.d.ts +29 -0
  109. package/Types/Webhooks/index.d.ts +1 -0
  110. package/Types/index.d.ts +13 -0
  111. package/index.d.ts +7 -4
  112. package/mailgun.node.js +2 -2
  113. package/mailgun.node.js.LICENSE.txt +1 -1
  114. package/mailgun.web.js +2 -2
  115. package/mailgun.web.js.LICENSE.txt +1 -1
  116. package/package.json +1 -1
  117. package/version.md +1 -1
  118. package/client.d.ts +0 -29
  119. package/common/NavigationThruPages.d.ts +0 -19
  120. package/error.d.ts +0 -8
  121. package/interfaces/APIErrorOptions.d.ts +0 -11
  122. package/interfaces/ApiResponse.d.ts +0 -5
  123. package/interfaces/DomainCredentials.d.ts +0 -52
  124. package/interfaces/DomainTemplates.d.ts +0 -178
  125. package/interfaces/IFormData.d.ts +0 -7
  126. package/interfaces/IMailgunClient.d.ts +0 -24
  127. package/interfaces/Suppressions/WhiteList.d.ts +0 -12
  128. package/interfaces/Supressions.d.ts +0 -103
  129. package/interfaces/Webhooks.d.ts +0 -34
  130. package/interfaces/mailListMembers.d.ts +0 -68
  131. package/ips.d.ts +0 -9
  132. package/lists.d.ts +0 -20
  133. package/stats.d.ts +0 -20
  134. package/suppressions.d.ts +0 -53
  135. package/validate.d.ts +0 -9
  136. package/webhooks.d.ts +0 -32
@@ -0,0 +1,23 @@
1
+ import { CreateDomainTemplateVersionResult, DomainTemplateData, DomainTemplatesQuery, DomainTemplateUpdateData, DomainTemplateUpdateVersionData, DomainTemplateVersionData, ListDomainTemplatesResult, ListDomainTemplateVersionsResult, MutateDomainTemplateVersionResult, NotificationResult, ShortTemplateVersion, TemplateQuery, TemplateVersion, UpdateOrDeleteDomainTemplateResult } from '../../Types/Domains';
2
+ export interface IDomainTemplate {
3
+ name: string;
4
+ description: string;
5
+ createdAt: string | Date;
6
+ createdBy: string;
7
+ id: string;
8
+ version?: TemplateVersion;
9
+ versions?: ShortTemplateVersion[];
10
+ }
11
+ export interface IDomainTemplatesClient {
12
+ list(domain: string, query?: DomainTemplatesQuery): Promise<ListDomainTemplatesResult>;
13
+ get(domain: string, templateName: string, query?: TemplateQuery): Promise<IDomainTemplate>;
14
+ create(domain: string, data: DomainTemplateData): Promise<IDomainTemplate>;
15
+ update(domain: string, templateName: string, data: DomainTemplateUpdateData): Promise<UpdateOrDeleteDomainTemplateResult>;
16
+ destroy(domain: string, templateName: string): Promise<UpdateOrDeleteDomainTemplateResult>;
17
+ destroyAll(domain: string): Promise<NotificationResult>;
18
+ createVersion(domain: string, templateName: string, data: DomainTemplateVersionData): Promise<CreateDomainTemplateVersionResult>;
19
+ getVersion(domain: string, templateName: string, tag: string): Promise<IDomainTemplate>;
20
+ updateVersion(domain: string, templateName: string, tag: string, data: DomainTemplateUpdateVersionData): Promise<MutateDomainTemplateVersionResult>;
21
+ destroyVersion(domain: string, templateName: string, tag: string): Promise<MutateDomainTemplateVersionResult>;
22
+ listVersions(domain: string, templateName: string, query?: DomainTemplatesQuery): Promise<ListDomainTemplateVersionsResult>;
23
+ }
@@ -0,0 +1,27 @@
1
+ import { APIResponse } from '../../Types/Common';
2
+ import { ClickTrackingInfo, ConnectionSettings, DKIMAuthorityInfo, DKIMSelectorInfo, DomainInfo, DomainsQuery, DomainTrackingData, MessageResponse, OpenTrackingInfo, ReplacementForPool, TDomain, UnsubscribeTrackingInfo, UpdatedConnectionSettings, UpdatedDKIMAuthority, UpdatedDKIMSelectorResponse, UpdatedOpenTracking, UpdatedWebPrefixResponse, WebPrefixInfo } from '../../Types/Domains';
3
+ import { IDomainCredentials } from './DomainCredentials';
4
+ import { IDomainTagsClient } from './DomainTags';
5
+ import { IDomainTemplatesClient } from './DomainTemplates';
6
+ export interface IDomainsClient {
7
+ domainCredentials: IDomainCredentials;
8
+ domainTemplates: IDomainTemplatesClient;
9
+ domainTags: IDomainTagsClient;
10
+ list(query?: DomainsQuery): Promise<TDomain[]>;
11
+ get(domain: string): Promise<TDomain>;
12
+ create(data: DomainInfo): Promise<TDomain>;
13
+ verify(domain: string): Promise<TDomain>;
14
+ destroy(domain: string): Promise<MessageResponse>;
15
+ getConnection(domain: string): Promise<ConnectionSettings>;
16
+ updateConnection(domain: string, data: ConnectionSettings): Promise<UpdatedConnectionSettings>;
17
+ getTracking(domain: string): Promise<DomainTrackingData>;
18
+ updateTracking(domain: string, type: string, data: OpenTrackingInfo | ClickTrackingInfo | UnsubscribeTrackingInfo): Promise<UpdatedOpenTracking>;
19
+ getIps(domain: string): Promise<string[]>;
20
+ assignIp(domain: string, ip: string): Promise<APIResponse>;
21
+ deleteIp(domain: string, ip: string): Promise<APIResponse>;
22
+ linkIpPool(domain: string, pool_id: string): Promise<APIResponse>;
23
+ unlinkIpPoll(domain: string, replacement: ReplacementForPool): Promise<APIResponse>;
24
+ updateDKIMAuthority(domain: string, data: DKIMAuthorityInfo): Promise<UpdatedDKIMAuthority>;
25
+ updateDKIMSelector(domain: string, data: DKIMSelectorInfo): Promise<UpdatedDKIMSelectorResponse>;
26
+ updateWebPrefix(domain: string, data: WebPrefixInfo): Promise<UpdatedWebPrefixResponse>;
27
+ }
@@ -0,0 +1,4 @@
1
+ export * from './DomainCredentials';
2
+ export * from './DomainTags';
3
+ export * from './DomainTemplates';
4
+ export * from './DomainsClient';
@@ -0,0 +1,4 @@
1
+ import { EventsList, EventsQuery } from '../../Types/Events';
2
+ export interface IEventClient {
3
+ get(domain: string, query?: EventsQuery): Promise<EventsList>;
4
+ }
@@ -0,0 +1 @@
1
+ export * from './IEventClient';
@@ -0,0 +1,7 @@
1
+ import { IpPoolCreateData, IpPoolCreateResult, IpPoolDeleteData, IpPoolListResult, IpPoolMessageResult, IpPoolUpdateData } from '../../Types/IPPools';
2
+ export interface IIPPoolsClient {
3
+ list(): Promise<IpPoolListResult>;
4
+ create(data: IpPoolCreateData): Promise<IpPoolCreateResult>;
5
+ update(poolId: string, data: IpPoolUpdateData): Promise<IpPoolMessageResult>;
6
+ delete(poolId: string, data: IpPoolDeleteData): Promise<IpPoolMessageResult>;
7
+ }
@@ -0,0 +1 @@
1
+ export * from './IIPPoolsClient';
@@ -0,0 +1,5 @@
1
+ import { IpData, IPsListQuery, IpsListResponseBody } from '../../Types/IPs';
2
+ export interface IIPsClient {
3
+ list(query: IPsListQuery): Promise<IpsListResponseBody>;
4
+ get(ip: string): Promise<IpData>;
5
+ }
@@ -0,0 +1 @@
1
+ export * from './IIPsClient';
@@ -0,0 +1,24 @@
1
+ import { IWebHooksClient } from '../Webhooks';
2
+ import { IDomainsClient } from '../Domains';
3
+ import { IEventClient } from '../EventClient';
4
+ import { IStatsClient } from '../Stats';
5
+ import { IMessagesClient } from '../Messages';
6
+ import { ISuppressionClient } from '../Suppressions';
7
+ import { IRoutesClient } from '../Routes';
8
+ import { IValidationClient } from '../Validations';
9
+ import { IIPsClient } from '../IPs';
10
+ import { IIPPoolsClient } from '../IPPools';
11
+ import { IMailingListsClient } from '../MailingLists';
12
+ export interface IMailgunClient {
13
+ domains: IDomainsClient;
14
+ webhooks: IWebHooksClient;
15
+ events: IEventClient;
16
+ stats: IStatsClient;
17
+ suppressions: ISuppressionClient;
18
+ messages: IMessagesClient;
19
+ routes: IRoutesClient;
20
+ validate: IValidationClient;
21
+ ips: IIPsClient;
22
+ ip_pools: IIPPoolsClient;
23
+ lists: IMailingListsClient;
24
+ }
@@ -0,0 +1 @@
1
+ export * from './IMailgunClient';
@@ -0,0 +1,9 @@
1
+ import { MailListMembersQuery, MailListMembersResult, MailListMember, CreateUpdateMailListMembers, MultipleMembersData, NewMultipleMembersResponse, DeletedMember } from '../../Types/MailingLists';
2
+ export interface IMailListsMembers {
3
+ listMembers(mailListAddress: string, query?: MailListMembersQuery): Promise<MailListMembersResult>;
4
+ getMember(address: string, memberAddress: string): Promise<MailListMember>;
5
+ createMember(mailListAddress: string, data: CreateUpdateMailListMembers): Promise<MailListMember>;
6
+ createMembers(mailListAddress: string, data: MultipleMembersData): Promise<NewMultipleMembersResponse>;
7
+ updateMember(address: string, memberAddress: string, data: CreateUpdateMailListMembers): Promise<MailListMember>;
8
+ destroyMember(address: string, memberAddress: string): Promise<DeletedMember>;
9
+ }
@@ -0,0 +1,13 @@
1
+ import { CreateUpdateList, DestroyedList, ListsQuery, MailingList, MailingListCancelValidationResult, MailingListResult, MailingListValidationResult, StartValidationResult } from '../../Types/MailingLists';
2
+ import { IMailListsMembers } from './MailingListMembers';
3
+ export interface IMailingListsClient {
4
+ members: IMailListsMembers;
5
+ list(query?: ListsQuery): Promise<MailingListResult>;
6
+ get(mailListAddress: string): Promise<MailingList>;
7
+ create(data: CreateUpdateList): Promise<MailingList>;
8
+ update(mailListAddress: string, data: CreateUpdateList): Promise<MailingList>;
9
+ destroy(mailListAddress: string): Promise<DestroyedList>;
10
+ validate(mailListAddress: string): Promise<StartValidationResult>;
11
+ validationResult(mailListAddress: string): Promise<MailingListValidationResult>;
12
+ cancelValidation(mailListAddress: string): Promise<MailingListCancelValidationResult>;
13
+ }
@@ -0,0 +1,2 @@
1
+ export * from './MailingListMembers';
2
+ export * from './MailingListsClient';
@@ -0,0 +1,4 @@
1
+ import { MailgunMessageData, MessagesSendResult } from '../../Types/Messages';
2
+ export interface IMessagesClient {
3
+ create(domain: string, data: MailgunMessageData): Promise<MessagesSendResult>;
4
+ }
@@ -0,0 +1 @@
1
+ export * from './IMessagesClient';
@@ -0,0 +1,8 @@
1
+ import { CreateUpdateRouteData, DestroyRouteResponse, Route, RoutesListQuery, UpdateRouteResponse } from '../../Types/Routes';
2
+ export interface IRoutesClient {
3
+ list(query: RoutesListQuery): Promise<Route[]>;
4
+ get(id: string): Promise<Route>;
5
+ create(data: CreateUpdateRouteData): Promise<Route>;
6
+ update(id: string, data: CreateUpdateRouteData): Promise<UpdateRouteResponse>;
7
+ destroy(id: string): Promise<DestroyRouteResponse>;
8
+ }
@@ -0,0 +1 @@
1
+ export * from './IRoutesClient';
@@ -0,0 +1,6 @@
1
+ import { StatsQuery } from '../../Types/Stats';
2
+ import { IStatsContainer } from './StatsContainer';
3
+ export interface IStatsClient {
4
+ getDomain(domain: string, query?: StatsQuery): Promise<IStatsContainer>;
5
+ getAccount(query?: StatsQuery): Promise<IStatsContainer>;
6
+ }
@@ -0,0 +1,7 @@
1
+ import { Stat } from '../../Types/Stats';
2
+ export interface IStatsContainer {
3
+ start: Date;
4
+ end: Date;
5
+ resolution: string;
6
+ stats: Stat[];
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from './StatsClient';
2
+ export * from './StatsContainer';
@@ -1,9 +1,3 @@
1
- export interface BounceData {
2
- address: string;
3
- code: number;
4
- error: string;
5
- created_at: string | Date;
6
- }
7
1
  export interface IBounce {
8
2
  address: string;
9
3
  code: number;
@@ -1,7 +1,3 @@
1
- export interface ComplaintData {
2
- address: string;
3
- created_at: string | Date;
4
- }
5
1
  export interface IComplaint {
6
2
  address: string;
7
3
  created_at: Date;
@@ -0,0 +1,11 @@
1
+ import { SuppressionList, SuppressionCreationData, SuppressionCreationResult, SuppressionListQuery, SuppressionDestroyResult } from '../../Types/Suppressions';
2
+ import { IBounce } from './Bounce';
3
+ import { IComplaint } from './Complaint';
4
+ import { IUnsubscribe } from './Unsubscribe';
5
+ import { IWhiteList } from './WhiteList';
6
+ export interface ISuppressionClient {
7
+ list(domain: string, type: string, query?: SuppressionListQuery): Promise<SuppressionList>;
8
+ get(domain: string, type: string, address: string): Promise<IBounce | IComplaint | IUnsubscribe | IWhiteList>;
9
+ create(domain: string, type: string, data: SuppressionCreationData | SuppressionCreationData[]): Promise<SuppressionCreationResult>;
10
+ destroy(domain: string, type: string, address: string): Promise<SuppressionDestroyResult>;
11
+ }
@@ -1,8 +1,3 @@
1
- export interface UnsubscribeData {
2
- address: string;
3
- tags: any;
4
- created_at: string | Date;
5
- }
6
1
  export interface IUnsubscribe {
7
2
  address: string;
8
3
  tags: any;
@@ -0,0 +1,6 @@
1
+ export interface IWhiteList {
2
+ type: string;
3
+ value: string;
4
+ reason: string;
5
+ createdAt: Date;
6
+ }
@@ -0,0 +1,5 @@
1
+ export * from './Bounce';
2
+ export * from './Complaint';
3
+ export * from './Unsubscribe';
4
+ export * from './WhiteList';
5
+ export * from './ISuppressionsClient';
@@ -0,0 +1,7 @@
1
+ import { MultipleValidationJobsListResult, MultipleValidationJobResult, CreatedMultipleValidationJob, CanceledMultipleValidationJob, MultipleValidationCreationData, MultipleValidationJobsListQuery } from '../../Types/Validations';
2
+ export interface IMultipleValidationClient {
3
+ list(query?: MultipleValidationJobsListQuery): Promise<MultipleValidationJobsListResult>;
4
+ get(listId: string): Promise<MultipleValidationJobResult>;
5
+ create(listId: string, data: MultipleValidationCreationData): Promise<CreatedMultipleValidationJob>;
6
+ destroy(listId: string): Promise<CanceledMultipleValidationJob>;
7
+ }
@@ -0,0 +1,6 @@
1
+ import { ValidationResult } from '../../Types/Validations';
2
+ import { IMultipleValidationClient } from './MultipleValidation';
3
+ export interface IValidationClient {
4
+ multipleValidation: IMultipleValidationClient;
5
+ get(address: string): Promise<ValidationResult>;
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from './MultipleValidation';
2
+ export * from './Validation';
@@ -0,0 +1,9 @@
1
+ import { WebhooksIds } from '../../Enums';
2
+ import { WebhookList, WebhookResult, WebhooksQuery, WebhookValidationResponse } from '../../Types/Webhooks';
3
+ export interface IWebHooksClient {
4
+ list(domain: string, query: WebhooksQuery): Promise<WebhookList>;
5
+ get(domain: string, id: WebhooksIds): Promise<WebhookResult>;
6
+ create(domain: string, id: string, url: string, test: boolean): Promise<WebhookResult | WebhookValidationResponse>;
7
+ update(domain: string, id: string, url: string): Promise<WebhookResult>;
8
+ destroy(domain: string, id: string): Promise<WebhookResult>;
9
+ }
@@ -0,0 +1 @@
1
+ export * from './IWebHooksClient';
@@ -0,0 +1,13 @@
1
+ export * from './Common';
2
+ export * from './Domains';
3
+ export * from './MailgunClient';
4
+ export * from './MailingLists';
5
+ export * from './Stats';
6
+ export * from './Suppressions';
7
+ export * from './Validations';
8
+ export * from './EventClient';
9
+ export * from './Webhooks';
10
+ export * from './Messages';
11
+ export * from './Routes';
12
+ export * from './IPs';
13
+ export * from './IPPools';
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Mailgun.js [![Build Status](https://travis-ci.org/mailgun/mailgun-js.svg)](https://travis-ci.org/mailgun/mailgun-js)
1
+ # Mailgun.js
2
2
 
3
3
  A javascript sdk for Mailgun built with webpack, babel & es6. This can be used in node or in the browser*.
4
4
 
@@ -9,6 +9,10 @@ __Table of Contents__
9
9
  - [Documentation](#documentation)
10
10
  - [Install](#install)
11
11
  - [Setup Client](#setup-client)
12
+ - [Available Imports](#imports)
13
+ - [Types imports](#types-imports)
14
+ - [Interfaces and Enums imports](#interfaces-and-enums-imports)
15
+ - [Generated docs](#generated-docs)
12
16
  - [Methods](#methods)
13
17
  - [Browser Demo](#browser-demo)
14
18
  - [Examples](https://github.com/mailgun/mailgun-js/tree/master/examples)
@@ -19,6 +23,7 @@ __Table of Contents__
19
23
  - [Release Process](#release-process)
20
24
 
21
25
  # Documentation
26
+ [Mailgun API Documentation](https://documentation.mailgun.com/en/latest/api_reference.html):
22
27
 
23
28
  ## Install
24
29
 
@@ -36,19 +41,39 @@ Next, require the module and instantiate a mailgun client by calling `new Mailgu
36
41
 
37
42
  NOTE: starting from version 3.0 you need to pass FormData (we need this to keep library universal). For node.js you can use `form-data` library.
38
43
 
44
+ ### Imports
45
+ Once the package is installed, you can import the library using `import` or `require` approach:
46
+
39
47
  ```js
40
- const formData = require('form-data');
41
- const Mailgun = require('mailgun.js');
42
- const mailgun = new Mailgun(formData);
43
- const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY || 'key-yourkeyhere'});
48
+ const formData = require('form-data');
49
+ const Mailgun = require('mailgun.js');
50
+ const mailgun = new Mailgun(formData);
51
+ const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY || 'key-yourkeyhere'});
44
52
  ```
45
-
46
- In the case your mailgun account is eu hosted you would need to define eu's subdomain as `url` in mailgun's Client constructor:
47
-
48
53
  ```js
49
- const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY || 'key-yourkeyhere', url: 'https://api.eu.mailgun.net'});
54
+ import * as FormData from 'form-data';
55
+ import Mailgun from 'mailgun.js';
56
+ const mailgun = new Mailgun(formData);
57
+ const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY || 'key-yourkeyhere'});
58
+ ```
59
+ ### Types imports
60
+ Starting from version **9.0.0.** Types can be includes as named import:
61
+ ```TS
62
+ import Mailgun, { MailgunClientOptions, MessagesSendResult } from 'mailgun.js';
50
63
  ```
51
64
 
65
+ ### Interfaces and Enums imports
66
+ Starting from version **9.0.0.** Interfaces and Enums can be imported in the next way:
67
+ ```TS
68
+ import Mailgun, { Interfaces, Enums } from 'mailgun.js';
69
+ ...
70
+ const mailgunClient: Interfaces.IMailgunClient = mailgun.client(clientOptions);
71
+ const yes = Enums.YesNo.YES;
72
+ ...
73
+ ```
74
+
75
+ ### Generated docs
76
+ The list of all available Types, Interfaces and Enums is auto-generated and located in the docs/ folder.
52
77
 
53
78
  ## Methods
54
79
 
@@ -268,9 +293,7 @@ Method naming conventions:
268
293
  messageParams.inline = file;
269
294
  return mg.messages.create('sandbox-123.mailgun.org', messageParams);
270
295
  })
271
- .then(response => {
272
- console.log(response);
273
- })
296
+ .then(response => console.log(response))
274
297
  ```
275
298
 
276
299
  - Browser example of send file
@@ -317,7 +340,13 @@ Method naming conventions:
317
340
 
318
341
  To provide values for a substitution you need to use 'h:X-Mailgun-Variables' property in the message description.
319
342
 
320
- Make sure that this property is a JSON string like {"title":"A title", "body":"The body"}.
343
+ Make sure that this property is a JSON string like:
344
+ ```js
345
+ JSON.stringify({
346
+ "title": "A title",
347
+ "body": "The body"
348
+ })
349
+ ```
321
350
 
322
351
  You can find few examples of how to use templates below.
323
352
  - Providing values for **title** and **slug** variables to render in template
@@ -0,0 +1,4 @@
1
+ export type APIResponse = {
2
+ status: number;
3
+ body: any;
4
+ };
@@ -0,0 +1,19 @@
1
+ export type APIErrorOptions = {
2
+ headers?: {
3
+ [key: string]: unknown;
4
+ };
5
+ status: number;
6
+ message?: string;
7
+ body: {
8
+ error?: string;
9
+ message?: string;
10
+ };
11
+ url?: string;
12
+ statusText?: string;
13
+ };
14
+ export type APIErrorType = {
15
+ stack: string;
16
+ status: number;
17
+ message: string;
18
+ details: string;
19
+ };
@@ -0,0 +1,7 @@
1
+ import * as NodeFormData from 'form-data';
2
+ export type FormDataOptions = {
3
+ [key: string]: any;
4
+ };
5
+ export type InputFormData = {
6
+ new (options?: HTMLFormElement | FormDataOptions): NodeFormData | FormData;
7
+ };
@@ -1,33 +1,33 @@
1
- export interface PagesList {
1
+ export type PagesList = {
2
2
  previous: string;
3
3
  first: string;
4
4
  last: string;
5
5
  next: string;
6
- }
7
- export interface ParsedPage {
6
+ };
7
+ export type ParsedPage = {
8
8
  id: string;
9
9
  page: string;
10
10
  iteratorPosition: string | undefined;
11
11
  url: string;
12
- }
13
- export interface ParsedPagesList {
12
+ };
13
+ export type ParsedPagesList = {
14
14
  previous: ParsedPage;
15
15
  first: ParsedPage;
16
16
  last: ParsedPage;
17
17
  next: ParsedPage;
18
- }
19
- export interface PagesListAccumulator {
18
+ };
19
+ export type PagesListAccumulator = {
20
20
  [index: string]: ParsedPage;
21
- }
22
- export interface ResponseWithPaging {
21
+ };
22
+ export type ResponseWithPaging = {
23
23
  body: {
24
24
  paging: PagesList;
25
25
  };
26
- }
27
- export interface QueryWithPage {
26
+ };
27
+ export type QueryWithPage = {
28
28
  page?: string;
29
- }
30
- export interface UpdatedUrlAndQuery {
29
+ };
30
+ export type UpdatedUrlAndQuery = {
31
31
  url: string;
32
32
  updatedQuery: Record<string, unknown>;
33
- }
33
+ };
@@ -1,15 +1,15 @@
1
1
  import { AxiosRequestHeaders, RawAxiosRequestHeaders } from 'axios';
2
- import Options from './Options';
3
- export interface OnCallEmptyHeaders {
2
+ import { MailgunClientOptions } from '../MailgunClient';
3
+ export type OnCallEmptyHeaders = {
4
4
  [key: string]: undefined;
5
- }
6
- export interface RequestOptions extends Options {
5
+ };
6
+ export type RequestOptions = MailgunClientOptions & {
7
7
  headers: AxiosRequestHeaders | RawAxiosRequestHeaders;
8
8
  timeout: number;
9
- }
10
- export interface OnCallRequestOptions {
9
+ };
10
+ export type OnCallRequestOptions = {
11
11
  timeout?: number;
12
12
  headers?: AxiosRequestHeaders | RawAxiosRequestHeaders;
13
13
  query?: any;
14
14
  [key: string]: unknown | undefined;
15
- }
15
+ };
@@ -0,0 +1,5 @@
1
+ export * from './Error';
2
+ export * from './ApiResponse';
3
+ export * from './FormData';
4
+ export * from './NavigationThruPages';
5
+ export * from './RequestOptions';
@@ -0,0 +1,46 @@
1
+ export type DomainCredentialsQuery = {
2
+ limit: number;
3
+ skip: number;
4
+ };
5
+ export type DomainCredentials = {
6
+ login: string;
7
+ password: string;
8
+ };
9
+ export type DomainCredentialsItem = {
10
+ created_at: string;
11
+ login: string;
12
+ mailbox: string;
13
+ size_bytes: number | null;
14
+ };
15
+ export type DomainCredentialsResponseData = {
16
+ status: number;
17
+ body: {
18
+ items: DomainCredentialsItem[];
19
+ total_count: number;
20
+ };
21
+ };
22
+ export type DomainCredentialsList = {
23
+ items: DomainCredentialsItem[];
24
+ totalCount: number;
25
+ };
26
+ export type DomainCredentialsResult = {
27
+ status: number;
28
+ message: string;
29
+ spec?: string;
30
+ };
31
+ export type CreatedUpdatedDomainCredentialsResponse = {
32
+ status: number;
33
+ body: {
34
+ message: string;
35
+ };
36
+ };
37
+ export type DeletedDomainCredentialsResponse = {
38
+ status: number;
39
+ body: {
40
+ message: string;
41
+ spec: string;
42
+ };
43
+ };
44
+ export type UpdateDomainCredentialsData = {
45
+ password: string;
46
+ };