/
AccountClient.ts
328 lines (296 loc) · 15.7 KB
/
AccountClient.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
import BaseClient from "./BaseClient";
import {
Callback,
ClientOptions,
DefaultResponse,
FilteringParameters,
} from "./models";
import {
CreateDomainRequest,
CreateServerRequest,
CreateSignatureRequest,
DomainDetails,
Domains,
Server,
ServerFilteringParameters,
Servers,
SignatureDetails,
Signatures,
TemplatesPush,
TemplatesPushRequest,
UpdateDomainRequest,
UpdateServerRequest,
UpdateSignatureRequest,
DataRemovalRequest,
DataRemovalStatus
} from "./models";
export default class AccountClient extends BaseClient {
/**
* Create a new AccountClient
* @param accountToken The account token that should be used with requests.
* @param configOptions Various options to customize client behavior.
*/
constructor(accountToken: string, configOptions?: ClientOptions.Configuration) {
super(accountToken, ClientOptions.AuthHeaderNames.ACCOUNT_TOKEN, configOptions);
}
/**
* Retrieve a list of Servers.
*
* @param filter - An optional filter for which data is retrieved.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public getServers(filter: ServerFilteringParameters = new ServerFilteringParameters(), callback?: Callback<Servers>): Promise<Servers> {
this.setDefaultPaginationValues(filter);
return this.processRequestWithoutBody(ClientOptions.HttpMethod.GET, "/servers", filter, callback);
}
/**
* Retrieve a single server by ID.
*
* @param id - The ID of the Server for which you wish to retrieve details.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public getServer(id: number, callback?: Callback<Server>): Promise<Server> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.GET, `/servers/${id}`, {}, callback);
}
/**
* Create a new Server.
*
* @param options - The options to be used to create new Server.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public createServer(options: CreateServerRequest, callback?: Callback<Server>): Promise<Server> {
return this.processRequestWithBody(ClientOptions.HttpMethod.POST, "/servers", options, callback);
}
/**
* Modify the Server associated with this Client.
*
* @param id - The ID of the Server you wish to update.
* @param options - The options to be used to create new Server.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public editServer(id: number, options: UpdateServerRequest, callback?: Callback<Server>): Promise<Server> {
return this.processRequestWithBody(ClientOptions.HttpMethod.PUT, `/servers/${id}`, options, callback);
}
/**
* Modify the Server associated with this Client.
*
* @param id - The ID of the Domain you wish to delete.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public deleteServer(id: number, callback?: Callback<DefaultResponse>): Promise<DefaultResponse> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.DELETE, `/servers/${id}`, {}, callback);
}
/**
* Retrieve a batch of Domains.
*
* @param filter - An optional filter for which data is retrieved.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public getDomains(filter: FilteringParameters = new FilteringParameters(), callback?: Callback<Domains>): Promise<Domains> {
this.setDefaultPaginationValues(filter);
return this.processRequestWithoutBody(ClientOptions.HttpMethod.GET, "/domains", filter, callback);
}
/**
* Retrieve a single Domain by ID.
*
* @param id - The ID of the Domain for which you wish to retrieve details.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public getDomain(id: number, callback?: Callback<DomainDetails>): Promise<DomainDetails> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.GET, `/domains/${id}`, {}, callback);
}
/**
* Create a new Domain.
*
* @param options - The options to be used to create new Domain.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public createDomain(options: CreateDomainRequest, callback?: Callback<DomainDetails>): Promise<DomainDetails> {
return this.processRequestWithBody(ClientOptions.HttpMethod.POST, "/domains/", options, callback);
}
/**
* Update a Domain.
*
* @param id - The ID of the Domain you wish to update.
* @param domain - The values on the Domain you wish to update.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public editDomain(id: number, options: UpdateDomainRequest, callback?: Callback<DomainDetails>): Promise<DomainDetails> {
return this.processRequestWithBody(ClientOptions.HttpMethod.PUT, `/domains/${id}`, options, callback);
}
/**
* Delete a Domain.
*
* @param id - The ID of the Domain you wish to delete.
* @param options - The options to be used in create Domain.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public deleteDomain(id: number, callback?: Callback<DefaultResponse>): Promise<DefaultResponse> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.DELETE, `/domains/${id}`, {}, callback);
}
/**
* Trigger Domain DKIM key verification.
*
* @param id - The ID of the Domain you wish to trigger DKIM verification for.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public verifyDomainDKIM(id: number, callback?: Callback<DomainDetails>): Promise<DomainDetails> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.PUT, `/domains/${id}/verifyDKIM`, {}, callback);
}
/**
* Trigger Domain DKIM key verification.
*
* @param id - The ID of the Domain you wish to trigger DKIM verification for.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public verifyDomainReturnPath(id: number, callback?: Callback<DomainDetails>): Promise<DomainDetails> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.PUT, `/domains/${id}/verifyReturnPath`, {}, callback);
}
/**
* Trigger Domain DKIM key verification.
*
* @param id - The ID of the Domain you wish to trigger DKIM verification for.
* @param callback If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public verifyDomainSPF(id: number, callback?: Callback<DomainDetails>): Promise<DomainDetails> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.POST, `/domains/${id}/verifySPF`, {}, callback);
}
/**
* Trigger Domain DKIM key verification.
*
* @param id - The ID of the Domain you wish to trigger DKIM verification for.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public rotateDomainDKIM(id: number, callback?: Callback<DomainDetails>): Promise<DomainDetails> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.POST, `/domains/${id}/rotateDKIM`, {}, callback);
}
/**
* Retrieve a single Sender Signature by ID.
*
* @param id - The ID of the Sender Signature for which you wish to retrieve details.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public getSenderSignature(id: number, callback?: Callback<SignatureDetails>): Promise<SignatureDetails> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.GET, `/senders/${id}`, {}, callback);
}
/**
* Retrieve a batch of Sender Signatures.
*
* @param filter - An optional filter for which data is retrieved.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public getSenderSignatures(filter: FilteringParameters = new FilteringParameters(),
callback?: Callback<Signatures>): Promise<Signatures> {
this.setDefaultPaginationValues(filter);
return this.processRequestWithoutBody(ClientOptions.HttpMethod.GET, "/senders", filter, callback);
}
/**
* Create a new Sender Signature.
*
* @param options - The options to be used to create new Sender Signature.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public createSenderSignature(options: CreateSignatureRequest, callback?: Callback<SignatureDetails>): Promise<SignatureDetails> {
return this.processRequestWithBody(ClientOptions.HttpMethod.POST, "/senders/", options, callback);
}
/**
* Update a Sender Signature.
*
* @param id - The ID of the Sender Signature for which you wish to update.
* @param options - The values on the Sender Signature you wish to update.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public editSenderSignature(id: number, options: UpdateSignatureRequest,
callback?: Callback<SignatureDetails>): Promise<SignatureDetails> {
return this.processRequestWithBody(ClientOptions.HttpMethod.PUT, `/senders/${id}`, options, callback);
}
/**
* Delete a Domain.
*
* @param id - The ID of the Domain you wish to delete.
* @param options - The options to be used in create Domain.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public deleteSenderSignature(id: number, callback?: Callback<DefaultResponse>): Promise<DefaultResponse> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.DELETE, `/senders/${id}`, {}, callback);
}
/**
* Request a new confirmation email to be sent to the email address associated with a Sender Signature.
*
* @param id - The ID of the Sender Signature.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public resendSenderSignatureConfirmation(id: number, callback?: Callback<DefaultResponse>): Promise<DefaultResponse> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.POST, `/senders/${id}/resend`, {}, callback);
}
/**
* Request that the SPF records for Sender Signature be verified.
*
* @param id - The ID of the Sender Signature.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public verifySenderSignatureSPF(id: number, callback?: Callback<SignatureDetails>): Promise<SignatureDetails> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.POST, `/senders/${id}/verifySpf`, {}, callback);
}
/**
* Request that the SPF records for Sender Signature be verified.
*
* @param id - The ID of the Sender Signature.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public requestNewDKIMForSenderSignature(id: number, callback?: Callback<SignatureDetails>): Promise<SignatureDetails> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.POST, `/senders/${id}/requestNewDkim`, {}, callback);
}
/**
* Request a push of templates from one server to another.
*
* @param options - details for pushing templates from one place to another.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public pushTemplates(options: TemplatesPushRequest, callback?: Callback<TemplatesPush>): Promise<TemplatesPush> {
return this.processRequestWithBody(ClientOptions.HttpMethod.PUT, "/templates/push", options, callback);
}
/**
* Request a data removal.
*
* @param options - details for creating data removal request
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public requestDataRemoval(options: DataRemovalRequest, callback?: Callback<DataRemovalStatus>): Promise<DataRemovalStatus> {
return this.processRequestWithBody(ClientOptions.HttpMethod.POST, "/data-removals", options, callback);
}
/**
* Retrieve a single data removal status by ID.
*
* @param id - The ID of the DataRemoval for which you wish to retrieve details.
* @param callback - If the callback is provided, it will be passed to the resulting promise as a continuation.
* @returns A promise that will complete when the API responds (or an error occurs).
*/
public getDataRemovalStatus(id: number, callback?: Callback<DataRemovalStatus>): Promise<DataRemovalStatus> {
return this.processRequestWithoutBody(ClientOptions.HttpMethod.GET, `/data-removals/${id}`, {}, callback);
}
}