mailgun.js 3.7.1 → 4.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.
- package/CHANGELOG.md +31 -0
- package/README.md +335 -1
- package/dist/lib/client.d.ts +0 -4
- package/dist/lib/domains.d.ts +19 -13
- package/dist/lib/domainsCredentials.d.ts +14 -0
- package/dist/lib/events.d.ts +3 -3
- package/dist/lib/interfaces/DomainCredentials.d.ts +52 -0
- package/dist/lib/interfaces/DomainTracking.d.ts +4 -4
- package/dist/lib/interfaces/Domains.d.ts +53 -3
- package/dist/lib/interfaces/Events.d.ts +66 -2
- package/dist/lib/interfaces/MultipleValidation.d.ts +55 -0
- package/dist/lib/interfaces/Validate.d.ts +12 -0
- package/dist/lib/interfaces/Webhooks.d.ts +5 -1
- package/dist/lib/interfaces/lists.d.ts +1 -1
- package/dist/lib/multipleValidation.d.ts +10 -0
- package/dist/lib/parse.d.ts +0 -6
- package/dist/lib/request.d.ts +4 -1
- package/dist/lib/validate.d.ts +5 -2
- package/dist/lib/webhooks.d.ts +3 -3
- package/dist/mailgun.node.js +2 -2
- package/dist/mailgun.node.js.LICENSE.txt +1 -1
- package/dist/mailgun.web.js +2 -2
- package/dist/mailgun.web.js.LICENSE.txt +1 -1
- package/lib/client.ts +6 -12
- package/lib/domains.ts +82 -26
- package/lib/domainsCredentials.ts +88 -0
- package/lib/events.ts +6 -6
- package/lib/interfaces/DomainCredentials.ts +68 -0
- package/lib/interfaces/DomainTracking.ts +4 -4
- package/lib/interfaces/Domains.ts +65 -4
- package/lib/interfaces/Events.ts +66 -2
- package/lib/interfaces/MultipleValidation.ts +62 -0
- package/lib/interfaces/Validate.ts +15 -0
- package/lib/interfaces/Webhooks.ts +6 -1
- package/lib/interfaces/lists.ts +1 -1
- package/lib/multipleValidation.ts +37 -0
- package/lib/request.ts +75 -34
- package/lib/validate.ts +10 -4
- package/lib/webhooks.ts +19 -10
- package/package.json +6 -6
- package/test/client.test.ts +21 -5
- package/test/data/emailsValidation1.csv +3 -0
- package/test/domains.test.ts +118 -15
- package/test/domainsCredentials.test.ts +97 -0
- package/test/events.test.ts +15 -24
- package/test/multipleValidation.test.ts +159 -0
- package/test/validate.test.ts +7 -4
- package/test/webhooks.test.ts +6 -6
- package/webpack/webpack.dev.config.js +10 -0
- package/lib/parse.ts +0 -27
- package/test/parse.test.ts +0 -75
package/lib/client.ts
CHANGED
|
@@ -11,12 +11,13 @@ import WebhookClient from './webhooks';
|
|
|
11
11
|
import MessagesClient from './messages';
|
|
12
12
|
import RoutesClient from './routes';
|
|
13
13
|
import ValidateClient from './validate';
|
|
14
|
-
import ParseClient from './parse';
|
|
15
14
|
import IpsClient from './ips';
|
|
16
15
|
import IpPoolsClient from './ip-pools';
|
|
17
16
|
import ListsClient from './lists';
|
|
18
17
|
import MailListsMembers from './mailListMembers';
|
|
19
18
|
import { InputFormData } from './interfaces/IFormData';
|
|
19
|
+
import DomainCredentialsClient from './domainsCredentials';
|
|
20
|
+
import MultipleValidationClient from './multipleValidation';
|
|
20
21
|
|
|
21
22
|
export default class Client {
|
|
22
23
|
private request;
|
|
@@ -28,9 +29,7 @@ export default class Client {
|
|
|
28
29
|
public suppressions;
|
|
29
30
|
public messages;
|
|
30
31
|
public routes;
|
|
31
|
-
public public_request;
|
|
32
32
|
public validate;
|
|
33
|
-
public parse;
|
|
34
33
|
public ips;
|
|
35
34
|
public ip_pools;
|
|
36
35
|
public lists;
|
|
@@ -53,8 +52,10 @@ export default class Client {
|
|
|
53
52
|
/** @internal */
|
|
54
53
|
this.request = new Request(config, formData);
|
|
55
54
|
const mailListsMembers = new MailListsMembers(this.request);
|
|
55
|
+
const domainCredentialsClient = new DomainCredentialsClient(this.request);
|
|
56
|
+
const multipleValidationClient = new MultipleValidationClient(this.request);
|
|
56
57
|
|
|
57
|
-
this.domains = new DomainClient(this.request);
|
|
58
|
+
this.domains = new DomainClient(this.request, domainCredentialsClient);
|
|
58
59
|
this.webhooks = new WebhookClient(this.request);
|
|
59
60
|
this.events = new EventClient(this.request);
|
|
60
61
|
this.stats = new StatsClient(this.request);
|
|
@@ -64,13 +65,6 @@ export default class Client {
|
|
|
64
65
|
this.ips = new IpsClient(this.request);
|
|
65
66
|
this.ip_pools = new IpPoolsClient(this.request);
|
|
66
67
|
this.lists = new ListsClient(this.request, mailListsMembers);
|
|
67
|
-
|
|
68
|
-
if (config.public_key) {
|
|
69
|
-
config.key = config.public_key;
|
|
70
|
-
|
|
71
|
-
this.public_request = new Request(config, formData);
|
|
72
|
-
this.validate = new ValidateClient(this.public_request);
|
|
73
|
-
this.parse = new ParseClient(this.public_request);
|
|
74
|
-
}
|
|
68
|
+
this.validate = new ValidateClient(this.request, multipleValidationClient);
|
|
75
69
|
}
|
|
76
70
|
}
|
package/lib/domains.ts
CHANGED
|
@@ -2,13 +2,25 @@
|
|
|
2
2
|
import urljoin from 'url-join';
|
|
3
3
|
import {
|
|
4
4
|
DomainResponseData,
|
|
5
|
-
DestroyedDomain,
|
|
6
5
|
DestroyedDomainResponse,
|
|
7
6
|
DomainsQuery,
|
|
8
7
|
DomainInfo,
|
|
9
8
|
DomainListResponseData,
|
|
10
9
|
DomainShortData,
|
|
11
|
-
DNSRecord
|
|
10
|
+
DNSRecord,
|
|
11
|
+
ConnectionSettingsResponse,
|
|
12
|
+
ConnectionSettings,
|
|
13
|
+
UpdatedConnectionSettings,
|
|
14
|
+
UpdatedConnectionSettingsRes,
|
|
15
|
+
DKIMAuthorityInfo,
|
|
16
|
+
UpdatedDKIMAuthority,
|
|
17
|
+
UpdatedDKIMAuthorityResponse,
|
|
18
|
+
DKIMSelectorInfo,
|
|
19
|
+
UpdatedDKIMSelectorResponse,
|
|
20
|
+
WebPrefixInfo,
|
|
21
|
+
UpdatedWebPrefixResponse,
|
|
22
|
+
ReplacementForPool,
|
|
23
|
+
MessageResponse,
|
|
12
24
|
} from './interfaces/Domains';
|
|
13
25
|
|
|
14
26
|
import APIResponse from './interfaces/ApiResponse';
|
|
@@ -25,8 +37,9 @@ import {
|
|
|
25
37
|
UpdateDomainTrackingResponse,
|
|
26
38
|
UpdatedOpenTracking
|
|
27
39
|
} from './interfaces/DomainTracking';
|
|
40
|
+
import DomainCredentialsClient from './domainsCredentials';
|
|
28
41
|
|
|
29
|
-
class Domain {
|
|
42
|
+
export class Domain {
|
|
30
43
|
name: string;
|
|
31
44
|
require_tls: boolean;
|
|
32
45
|
skip_verification: boolean;
|
|
@@ -59,22 +72,24 @@ class Domain {
|
|
|
59
72
|
|
|
60
73
|
export default class DomainClient {
|
|
61
74
|
request: Request;
|
|
75
|
+
public domainCredentials: DomainCredentialsClient;
|
|
62
76
|
|
|
63
|
-
constructor(request: Request) {
|
|
77
|
+
constructor(request: Request, domainCredentialsClient: DomainCredentialsClient) {
|
|
64
78
|
this.request = request;
|
|
79
|
+
this.domainCredentials = domainCredentialsClient;
|
|
65
80
|
}
|
|
66
81
|
|
|
67
|
-
_parseMessage(response: DestroyedDomainResponse) :
|
|
82
|
+
private _parseMessage(response: DestroyedDomainResponse) : MessageResponse {
|
|
68
83
|
return response.body;
|
|
69
84
|
}
|
|
70
85
|
|
|
71
|
-
_parseDomainList(response: DomainListResponseData): Domain[] {
|
|
86
|
+
private _parseDomainList(response: DomainListResponseData): Domain[] {
|
|
72
87
|
return response.body.items.map(function (item) {
|
|
73
88
|
return new Domain(item);
|
|
74
89
|
});
|
|
75
90
|
}
|
|
76
91
|
|
|
77
|
-
_parseDomain(response: DomainResponseData): Domain {
|
|
92
|
+
private _parseDomain(response: DomainResponseData): Domain {
|
|
78
93
|
return new Domain(
|
|
79
94
|
response.body.domain,
|
|
80
95
|
response.body.receiving_dns_records,
|
|
@@ -82,38 +97,55 @@ export default class DomainClient {
|
|
|
82
97
|
);
|
|
83
98
|
}
|
|
84
99
|
|
|
85
|
-
_parseTrackingSettings(response: DomainTrackingResponse) : DomainTrackingData {
|
|
100
|
+
private _parseTrackingSettings(response: DomainTrackingResponse) : DomainTrackingData {
|
|
86
101
|
return response.body.tracking;
|
|
87
102
|
}
|
|
88
103
|
|
|
89
|
-
_parseTrackingUpdate(response: UpdateDomainTrackingResponse) :UpdatedOpenTracking {
|
|
104
|
+
private _parseTrackingUpdate(response: UpdateDomainTrackingResponse) :UpdatedOpenTracking {
|
|
90
105
|
return response.body;
|
|
91
106
|
}
|
|
92
107
|
|
|
93
|
-
list(query
|
|
94
|
-
return this.request.get('/
|
|
108
|
+
list(query?: DomainsQuery): Promise<Domain[]> {
|
|
109
|
+
return this.request.get('/v3/domains', query)
|
|
95
110
|
.then((res : APIResponse) => this._parseDomainList(res as DomainListResponseData));
|
|
96
111
|
}
|
|
97
112
|
|
|
98
113
|
get(domain: string) : Promise<Domain> {
|
|
99
|
-
return this.request.get(`/
|
|
114
|
+
return this.request.get(`/v3/domains/${domain}`)
|
|
100
115
|
.then((res : APIResponse) => this._parseDomain(res as DomainResponseData));
|
|
101
116
|
}
|
|
102
117
|
|
|
103
118
|
create(data: DomainInfo) : Promise<Domain> {
|
|
104
|
-
|
|
119
|
+
const postObj = { ...data };
|
|
120
|
+
if ('force_dkim_authority' in postObj && typeof postObj.force_dkim_authority === 'boolean') {
|
|
121
|
+
postObj.force_dkim_authority = postObj.toString() === 'true' ? 'true' : 'false';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return this.request.postWithFD('/v3/domains', postObj)
|
|
105
125
|
.then((res : APIResponse) => this._parseDomain(res as DomainResponseData));
|
|
106
126
|
}
|
|
107
127
|
|
|
108
|
-
destroy(domain: string): Promise<
|
|
109
|
-
return this.request.delete(`/
|
|
128
|
+
destroy(domain: string): Promise<MessageResponse> {
|
|
129
|
+
return this.request.delete(`/v3/domains/${domain}`)
|
|
110
130
|
.then((res : APIResponse) => this._parseMessage(res as DestroyedDomainResponse));
|
|
111
131
|
}
|
|
112
132
|
|
|
133
|
+
getConnection(domain: string): Promise<ConnectionSettings> {
|
|
134
|
+
return this.request.get(`/v3/domains/${domain}/connection`)
|
|
135
|
+
.then((res : APIResponse) => res as ConnectionSettingsResponse)
|
|
136
|
+
.then((res:ConnectionSettingsResponse) => res.body.connection as ConnectionSettings);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
updateConnection(domain: string, data: ConnectionSettings): Promise<UpdatedConnectionSettings> {
|
|
140
|
+
return this.request.put(`/v3/domains/${domain}/connection`, data)
|
|
141
|
+
.then((res : APIResponse) => res as UpdatedConnectionSettingsRes)
|
|
142
|
+
.then((res:UpdatedConnectionSettingsRes) => res.body as UpdatedConnectionSettings);
|
|
143
|
+
}
|
|
144
|
+
|
|
113
145
|
// Tracking
|
|
114
146
|
|
|
115
147
|
getTracking(domain: string) : Promise<DomainTrackingData> {
|
|
116
|
-
return this.request.get(urljoin('/
|
|
148
|
+
return this.request.get(urljoin('/v3/domains', domain, 'tracking'))
|
|
117
149
|
.then(this._parseTrackingSettings);
|
|
118
150
|
}
|
|
119
151
|
|
|
@@ -122,33 +154,57 @@ export default class DomainClient {
|
|
|
122
154
|
type: string,
|
|
123
155
|
data: OpenTrackingInfo | ClickTrackingInfo | UnsubscribeTrackingInfo
|
|
124
156
|
): Promise<UpdatedOpenTracking> {
|
|
125
|
-
if (
|
|
126
|
-
throw new APIError({ status: 400, statusText: '', body: { message: '
|
|
157
|
+
if (typeof data?.active === 'boolean') {
|
|
158
|
+
throw new APIError({ status: 400, statusText: '', body: { message: 'Property "active" must contain string value.' } } as APIErrorOptions);
|
|
127
159
|
}
|
|
128
|
-
return this.request.putWithFD(urljoin('/
|
|
129
|
-
.then(this._parseTrackingUpdate);
|
|
160
|
+
return this.request.putWithFD(urljoin('/v3/domains', domain, 'tracking', type), data)
|
|
161
|
+
.then((res : APIResponse) => this._parseTrackingUpdate(res as UpdateDomainTrackingResponse));
|
|
130
162
|
}
|
|
131
163
|
|
|
132
164
|
// IPs
|
|
133
165
|
|
|
134
166
|
getIps(domain: string): Promise<string[]> {
|
|
135
|
-
return this.request.get(urljoin('/
|
|
167
|
+
return this.request.get(urljoin('/v3/domains', domain, 'ips'))
|
|
136
168
|
.then((response: APIResponse) => response?.body?.items);
|
|
137
169
|
}
|
|
138
170
|
|
|
139
171
|
assignIp(domain: string, ip: string): Promise<APIResponse> {
|
|
140
|
-
return this.request.postWithFD(urljoin('/
|
|
172
|
+
return this.request.postWithFD(urljoin('/v3/domains', domain, 'ips'), { ip });
|
|
141
173
|
}
|
|
142
174
|
|
|
143
175
|
deleteIp(domain: string, ip: string): Promise<APIResponse> {
|
|
144
|
-
return this.request.delete(urljoin('/
|
|
176
|
+
return this.request.delete(urljoin('/v3/domains', domain, 'ips', ip));
|
|
145
177
|
}
|
|
146
178
|
|
|
147
179
|
linkIpPool(domain: string, pool_id: string): Promise<APIResponse> {
|
|
148
|
-
return this.request.postWithFD(urljoin('/
|
|
180
|
+
return this.request.postWithFD(urljoin('/v3/domains', domain, 'ips'), { pool_id });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
unlinkIpPoll(domain: string, replacement: ReplacementForPool): Promise<APIResponse> {
|
|
184
|
+
let searchParams = '';
|
|
185
|
+
if (replacement.pool_id && replacement.ip) {
|
|
186
|
+
throw new APIError({ status: 400, statusText: '', body: { message: 'Please specify either pool_id or ip (not both)' } } as APIErrorOptions);
|
|
187
|
+
} else if (replacement.pool_id) {
|
|
188
|
+
searchParams = `?pool_id=${replacement.pool_id}`;
|
|
189
|
+
} else if (replacement.ip) {
|
|
190
|
+
searchParams = `?ip=${replacement.ip}`;
|
|
191
|
+
}
|
|
192
|
+
return this.request.delete(urljoin('/v3/domains', domain, 'ips', 'ip_pool', searchParams));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
updateDKIMAuthority(domain: string, data: DKIMAuthorityInfo): Promise<UpdatedDKIMAuthority> {
|
|
196
|
+
return this.request.put(`/v3/domains/${domain}/dkim_authority`, {}, { query: `self=${data.self}` })
|
|
197
|
+
.then((res : APIResponse) => res)
|
|
198
|
+
.then((res : UpdatedDKIMAuthorityResponse) => res.body as UpdatedDKIMAuthority);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
updateDKIMSelector(domain: string, data: DKIMSelectorInfo): Promise<UpdatedDKIMSelectorResponse> {
|
|
202
|
+
return this.request.put(`/v3/domains/${domain}/dkim_selector`, {}, { query: `dkim_selector=${data.dkimSelector}` })
|
|
203
|
+
.then((res : APIResponse) => res as UpdatedDKIMSelectorResponse);
|
|
149
204
|
}
|
|
150
205
|
|
|
151
|
-
|
|
152
|
-
return this.request.
|
|
206
|
+
updateWebPrefix(domain: string, data: WebPrefixInfo): Promise<UpdatedWebPrefixResponse> {
|
|
207
|
+
return this.request.put(`/v3/domains/${domain}/web_prefix`, {}, { query: `web_prefix=${data.webPrefix}` })
|
|
208
|
+
.then((res : APIResponse) => res as UpdatedWebPrefixResponse);
|
|
153
209
|
}
|
|
154
210
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import urljoin from 'url-join';
|
|
2
|
+
import APIResponse from './interfaces/ApiResponse';
|
|
3
|
+
import Request from './request';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
CreatedUpdatedDomainCredentialsResponse,
|
|
7
|
+
DeletedDomainCredentialsResponse,
|
|
8
|
+
DomainCredentials,
|
|
9
|
+
DomainCredentialsList,
|
|
10
|
+
DomainCredentialsQuery,
|
|
11
|
+
DomainCredentialsResponseData,
|
|
12
|
+
DomainCredentialsResult,
|
|
13
|
+
IDomainCredentials,
|
|
14
|
+
UpdateDomainCredentialsData
|
|
15
|
+
} from './interfaces/DomainCredentials';
|
|
16
|
+
|
|
17
|
+
export default class DomainCredentialsClient implements IDomainCredentials {
|
|
18
|
+
baseRoute: string;
|
|
19
|
+
request: Request;
|
|
20
|
+
|
|
21
|
+
constructor(request: Request) {
|
|
22
|
+
this.request = request;
|
|
23
|
+
this.baseRoute = '/v3/domains/';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private _parseDomainCredentialsList(
|
|
27
|
+
response: DomainCredentialsResponseData
|
|
28
|
+
): DomainCredentialsList {
|
|
29
|
+
return {
|
|
30
|
+
items: response.body.items,
|
|
31
|
+
totalCount: response.body.total_count
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private _parseMessageResponse(
|
|
36
|
+
response: CreatedUpdatedDomainCredentialsResponse
|
|
37
|
+
): DomainCredentialsResult {
|
|
38
|
+
const result = {
|
|
39
|
+
status: response.status,
|
|
40
|
+
message: response.body.message
|
|
41
|
+
} as DomainCredentialsResult;
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private _parseDeletedResponse(
|
|
46
|
+
response:DeletedDomainCredentialsResponse
|
|
47
|
+
): DomainCredentialsResult {
|
|
48
|
+
const result = {
|
|
49
|
+
status: response.status,
|
|
50
|
+
message: response.body.message,
|
|
51
|
+
spec: response.body.spec
|
|
52
|
+
} as DomainCredentialsResult;
|
|
53
|
+
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
list(domain: string, query?: DomainCredentialsQuery): Promise<DomainCredentialsList> {
|
|
58
|
+
return this.request.get(urljoin(this.baseRoute, domain, '/credentials'), query)
|
|
59
|
+
.then(
|
|
60
|
+
(res: APIResponse) => this._parseDomainCredentialsList(res as DomainCredentialsResponseData)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
create(
|
|
65
|
+
domain: string,
|
|
66
|
+
data: DomainCredentials
|
|
67
|
+
): Promise<DomainCredentialsResult> {
|
|
68
|
+
return this.request.postWithFD(`${this.baseRoute}${domain}/credentials`, data)
|
|
69
|
+
.then((res: APIResponse) => this._parseMessageResponse(res));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
update(
|
|
73
|
+
domain: string,
|
|
74
|
+
credentialsLogin: string,
|
|
75
|
+
data: UpdateDomainCredentialsData
|
|
76
|
+
): Promise<DomainCredentialsResult> {
|
|
77
|
+
return this.request.putWithFD(`${this.baseRoute}${domain}/credentials/${credentialsLogin}`, data)
|
|
78
|
+
.then((res: APIResponse) => this._parseMessageResponse(res));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
destroy(
|
|
82
|
+
domain: string,
|
|
83
|
+
credentialsLogin: string
|
|
84
|
+
): Promise<DomainCredentialsResult> {
|
|
85
|
+
return this.request.delete(`${this.baseRoute}${domain}/credentials/${credentialsLogin}`)
|
|
86
|
+
.then((res: APIResponse) => this._parseDeletedResponse(res));
|
|
87
|
+
}
|
|
88
|
+
}
|
package/lib/events.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import urljoin from 'url-join';
|
|
2
2
|
import {
|
|
3
|
-
EventsList, EventsPage, EventsResponse, PagesList, PagesListAccumulator
|
|
3
|
+
EventsList, EventsPage, EventsResponse, PagesList, PagesListAccumulator, ParsedPagesList
|
|
4
4
|
} from './interfaces/Events';
|
|
5
5
|
|
|
6
6
|
import Request from './request';
|
|
@@ -20,7 +20,7 @@ export default class EventClient {
|
|
|
20
20
|
return { id, number: this._parsePageNumber(url), url };
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
_parsePageLinks(response: EventsResponse) :
|
|
23
|
+
_parsePageLinks(response: EventsResponse) : ParsedPagesList {
|
|
24
24
|
const pages = Object.entries(response.body.paging as PagesList);
|
|
25
25
|
return pages.reduce(
|
|
26
26
|
(acc: PagesListAccumulator, entrie: [url: string, id: string]) => {
|
|
@@ -29,7 +29,7 @@ export default class EventClient {
|
|
|
29
29
|
acc[id] = this._parsePage(id, url);
|
|
30
30
|
return acc;
|
|
31
31
|
}, {}
|
|
32
|
-
) as unknown as
|
|
32
|
+
) as unknown as ParsedPagesList;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
_parseEventList(response: EventsResponse) : EventsList {
|
|
@@ -39,14 +39,14 @@ export default class EventClient {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
get(domain: string, query
|
|
42
|
+
get(domain: string, query?: { page: string }) : Promise<EventsList> {
|
|
43
43
|
let url;
|
|
44
44
|
const queryCopy = { ...query };
|
|
45
45
|
if (queryCopy && queryCopy.page) {
|
|
46
|
-
url = urljoin('/
|
|
46
|
+
url = urljoin('/v3', domain, 'events', queryCopy.page);
|
|
47
47
|
delete queryCopy.page;
|
|
48
48
|
} else {
|
|
49
|
-
url = urljoin('/
|
|
49
|
+
url = urljoin('/v3', domain, 'events');
|
|
50
50
|
}
|
|
51
51
|
return this.request.get(url, queryCopy)
|
|
52
52
|
.then((response: EventsResponse) => this._parseEventList(response));
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
export interface DomainCredentialsQuery {
|
|
3
|
+
limit: number;
|
|
4
|
+
skip: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface DomainCredentials {
|
|
8
|
+
login: string;
|
|
9
|
+
password: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DomainCredentialsItem {
|
|
13
|
+
created_at: string,
|
|
14
|
+
login: string,
|
|
15
|
+
mailbox: string,
|
|
16
|
+
size_bytes: number | null
|
|
17
|
+
}
|
|
18
|
+
export interface DomainCredentialsResponseData {
|
|
19
|
+
status: number;
|
|
20
|
+
body: {
|
|
21
|
+
items: DomainCredentialsItem[];
|
|
22
|
+
total_count: number;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface DomainCredentialsList {
|
|
27
|
+
items: DomainCredentialsItem[];
|
|
28
|
+
totalCount: number;
|
|
29
|
+
}
|
|
30
|
+
export interface DomainCredentialsResult {
|
|
31
|
+
status: number,
|
|
32
|
+
message: string;
|
|
33
|
+
spec?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface CreatedUpdatedDomainCredentialsResponse {
|
|
37
|
+
status: number,
|
|
38
|
+
body: {
|
|
39
|
+
message: string;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface DeletedDomainCredentialsResponse {
|
|
44
|
+
status: number,
|
|
45
|
+
body: {
|
|
46
|
+
message: string;
|
|
47
|
+
spec: string;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface UpdateDomainCredentialsData {
|
|
52
|
+
password: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface IDomainCredentials {
|
|
56
|
+
list(domain: string, query: DomainCredentialsQuery): Promise<DomainCredentialsList>
|
|
57
|
+
create(domain: string, data: DomainCredentials
|
|
58
|
+
): Promise<DomainCredentialsResult>
|
|
59
|
+
update(
|
|
60
|
+
domain: string,
|
|
61
|
+
credentialsLogin: string,
|
|
62
|
+
data: UpdateDomainCredentialsData
|
|
63
|
+
): Promise<DomainCredentialsResult>
|
|
64
|
+
destroy(
|
|
65
|
+
domain: string,
|
|
66
|
+
credentialsLogin: string
|
|
67
|
+
): Promise<DomainCredentialsResult>
|
|
68
|
+
}
|
|
@@ -18,7 +18,7 @@ export interface DomainTrackingResponse {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface UpdatedOpenTracking {
|
|
21
|
-
message:
|
|
21
|
+
message: string;
|
|
22
22
|
open?: { active: boolean };
|
|
23
23
|
click?: { active: boolean | 'htmlonly'};
|
|
24
24
|
unsubscribe?: {
|
|
@@ -34,14 +34,14 @@ export interface UpdateDomainTrackingResponse {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export interface OpenTrackingInfo {
|
|
37
|
-
active: 'yes'
|
|
37
|
+
active: 'yes'| 'no' | 'true' | 'false';
|
|
38
38
|
}
|
|
39
39
|
export interface ClickTrackingInfo {
|
|
40
|
-
active: 'yes'
|
|
40
|
+
active: 'yes'| 'no' | 'true' | 'false' | 'htmlonly';
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export interface UnsubscribeTrackingInfo {
|
|
44
|
-
active:
|
|
44
|
+
active: 'yes'| 'no' | 'true' | 'false';
|
|
45
45
|
html_footer: string;
|
|
46
46
|
text_footer: string;
|
|
47
47
|
}
|
|
@@ -11,7 +11,7 @@ export interface DomainInfo {
|
|
|
11
11
|
smtp_password: string;
|
|
12
12
|
spam_action?: 'disabled' | 'block' | 'tag';
|
|
13
13
|
wildcard?: boolean;
|
|
14
|
-
force_dkim_authority?: true;
|
|
14
|
+
force_dkim_authority?: boolean | 'true' | 'false';
|
|
15
15
|
dkim_key_size?: 1024 | 2048;
|
|
16
16
|
ips?: '';
|
|
17
17
|
pool_id?: '';
|
|
@@ -69,13 +69,74 @@ export interface DomainListResponseData {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export interface
|
|
73
|
-
message: string
|
|
72
|
+
export interface MessageResponse {
|
|
73
|
+
message : string
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export interface DestroyedDomainResponse {
|
|
77
77
|
status: number;
|
|
78
|
+
body: MessageResponse
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ConnectionSettings {
|
|
82
|
+
require_tls: boolean;
|
|
83
|
+
skip_verification: boolean;
|
|
84
|
+
}
|
|
85
|
+
export interface ConnectionSettingsResponse {
|
|
78
86
|
body: {
|
|
79
|
-
|
|
87
|
+
connection: ConnectionSettings
|
|
80
88
|
}
|
|
89
|
+
status: number
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface UpdatedConnectionSettings {
|
|
93
|
+
message: string,
|
|
94
|
+
require_tls: boolean,
|
|
95
|
+
skip_verification: boolean
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface UpdatedConnectionSettingsRes {
|
|
99
|
+
body: UpdatedConnectionSettings,
|
|
100
|
+
status: number
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface DKIMAuthorityInfo {
|
|
104
|
+
self: boolean | 'yes' | 'no' | 'true' |'false'
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface UpdatedDKIMAuthority {
|
|
108
|
+
changed: boolean,
|
|
109
|
+
message: string,
|
|
110
|
+
sending_dns_records: DNSRecord[]
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface UpdatedDKIMAuthorityResponse {
|
|
114
|
+
body: UpdatedDKIMAuthority,
|
|
115
|
+
status: 200
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface DKIMSelectorInfo {
|
|
119
|
+
dkimSelector: string
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface UpdatedDKIMSelectorResponse {
|
|
123
|
+
body:MessageResponse,
|
|
124
|
+
status: number
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface WebPrefixInfo {
|
|
128
|
+
webPrefix: string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface UpdatedWebPrefix {
|
|
132
|
+
message : string
|
|
133
|
+
}
|
|
134
|
+
export interface UpdatedWebPrefixResponse {
|
|
135
|
+
body:MessageResponse,
|
|
136
|
+
status: number
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface ReplacementForPool {
|
|
140
|
+
pool_id?: string;
|
|
141
|
+
ip?: string;
|
|
81
142
|
}
|
package/lib/interfaces/Events.ts
CHANGED
|
@@ -15,10 +15,74 @@ export interface EventsResponse {
|
|
|
15
15
|
paging: PagesList;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
export interface DomainEvent {
|
|
19
|
+
severity: string;
|
|
20
|
+
tags: string[];
|
|
21
|
+
storage: {
|
|
22
|
+
url: string;
|
|
23
|
+
key: string
|
|
24
|
+
};
|
|
25
|
+
'delivery-status': {
|
|
26
|
+
tls: boolean;
|
|
27
|
+
'mx-host': string;
|
|
28
|
+
code: number;
|
|
29
|
+
description: string;
|
|
30
|
+
'session-seconds': number;
|
|
31
|
+
utf8: boolean;
|
|
32
|
+
'attempt-no': number;
|
|
33
|
+
message: string;
|
|
34
|
+
'certificate-verified': boolean
|
|
35
|
+
};
|
|
36
|
+
'recipient-domain': string;
|
|
37
|
+
id: string;
|
|
38
|
+
campaigns: [];
|
|
39
|
+
reason: string;
|
|
40
|
+
'user-variables': {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
};
|
|
43
|
+
flags: {
|
|
44
|
+
'is-routed': boolean;
|
|
45
|
+
'is-authenticated': boolean;
|
|
46
|
+
'is-system-test': boolean;
|
|
47
|
+
'is-test-mode': boolean
|
|
48
|
+
};
|
|
49
|
+
'log-level' : string;
|
|
50
|
+
template?: any;
|
|
51
|
+
timestamp: number;
|
|
52
|
+
envelope: {
|
|
53
|
+
transport: string;
|
|
54
|
+
sender: string;
|
|
55
|
+
'sending-ip': string;
|
|
56
|
+
targets: string
|
|
57
|
+
};
|
|
58
|
+
message: {
|
|
59
|
+
headers: {
|
|
60
|
+
to: string;
|
|
61
|
+
'message-id': string;
|
|
62
|
+
from: string;
|
|
63
|
+
subject: string
|
|
64
|
+
};
|
|
65
|
+
attachments: [];
|
|
66
|
+
size: 308
|
|
67
|
+
};
|
|
68
|
+
recipient: string;
|
|
69
|
+
event: string;
|
|
70
|
+
}
|
|
18
71
|
|
|
72
|
+
export interface ParsedPage{
|
|
73
|
+
id: string;
|
|
74
|
+
number: string;
|
|
75
|
+
url: string
|
|
76
|
+
}
|
|
77
|
+
export interface ParsedPagesList {
|
|
78
|
+
previous: ParsedPage;
|
|
79
|
+
first: ParsedPage;
|
|
80
|
+
last: ParsedPage;
|
|
81
|
+
next: ParsedPage;
|
|
82
|
+
}
|
|
19
83
|
export interface EventsList {
|
|
20
|
-
items: [];
|
|
21
|
-
pages:
|
|
84
|
+
items: DomainEvent[];
|
|
85
|
+
pages: ParsedPagesList;
|
|
22
86
|
}
|
|
23
87
|
export interface PagesListAccumulator {
|
|
24
88
|
[index: string]: EventsPage
|