pingram 1.0.31 → 1.0.32-alpha.1509

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 (54) hide show
  1. package/dist/generated/src/apis/BroadcastsApi.d.ts +374 -0
  2. package/dist/generated/src/apis/BroadcastsApi.js +846 -0
  3. package/dist/generated/src/apis/LibraryApi.d.ts +80 -0
  4. package/dist/generated/src/apis/LibraryApi.js +176 -0
  5. package/dist/generated/src/apis/index.d.ts +5 -1
  6. package/dist/generated/src/apis/index.js +5 -1
  7. package/dist/generated/src/models/BroadcastMetricsResponse.d.ts +129 -0
  8. package/dist/generated/src/models/BroadcastMetricsResponse.js +122 -0
  9. package/dist/generated/src/models/BroadcastResponse.d.ts +161 -0
  10. package/dist/generated/src/models/BroadcastResponse.js +141 -0
  11. package/dist/generated/src/models/BroadcastResponseAudience.d.ts +40 -0
  12. package/dist/generated/src/models/BroadcastResponseAudience.js +50 -0
  13. package/dist/generated/src/models/CreateBroadcastRequest.d.ts +94 -0
  14. package/dist/generated/src/models/CreateBroadcastRequest.js +88 -0
  15. package/dist/generated/src/models/CreateLibraryRequest.d.ts +38 -0
  16. package/dist/generated/src/models/CreateLibraryRequest.js +54 -0
  17. package/dist/generated/src/models/CreateLibraryResponse.d.ts +76 -0
  18. package/dist/generated/src/models/CreateLibraryResponse.js +84 -0
  19. package/dist/generated/src/models/GetUsersResponseUsersInner.d.ts +9 -0
  20. package/dist/generated/src/models/GetUsersResponseUsersInner.js +8 -0
  21. package/dist/generated/src/models/GetUsersResponseUsersInnerPropertiesValue.d.ts +26 -0
  22. package/dist/generated/src/models/GetUsersResponseUsersInnerPropertiesValue.js +38 -0
  23. package/dist/generated/src/models/ListBroadcastRecipientsResponse.d.ts +39 -0
  24. package/dist/generated/src/models/ListBroadcastRecipientsResponse.js +53 -0
  25. package/dist/generated/src/models/ListBroadcastRecipientsResponseRecipientsInner.d.ts +116 -0
  26. package/dist/generated/src/models/ListBroadcastRecipientsResponseRecipientsInner.js +82 -0
  27. package/dist/generated/src/models/ListBroadcastsResponse.d.ts +39 -0
  28. package/dist/generated/src/models/ListBroadcastsResponse.js +53 -0
  29. package/dist/generated/src/models/ListBroadcastsResponseBroadcastsInner.d.ts +149 -0
  30. package/dist/generated/src/models/ListBroadcastsResponseBroadcastsInner.js +135 -0
  31. package/dist/generated/src/models/ListLibraryResponse.d.ts +39 -0
  32. package/dist/generated/src/models/ListLibraryResponse.js +53 -0
  33. package/dist/generated/src/models/ListLibraryResponseItemsInner.d.ts +76 -0
  34. package/dist/generated/src/models/ListLibraryResponseItemsInner.js +84 -0
  35. package/dist/generated/src/models/LogsGetResponseLogsInner.d.ts +2 -0
  36. package/dist/generated/src/models/LogsGetResponseLogsInner.js +2 -0
  37. package/dist/generated/src/models/MFAStatusResponse.d.ts +1 -1
  38. package/dist/generated/src/models/PostUserRequest.d.ts +9 -0
  39. package/dist/generated/src/models/PostUserRequest.js +10 -2
  40. package/dist/generated/src/models/ScheduleBroadcastRequest.d.ts +32 -0
  41. package/dist/generated/src/models/ScheduleBroadcastRequest.js +50 -0
  42. package/dist/generated/src/models/SenderPostBodyTo.d.ts +9 -0
  43. package/dist/generated/src/models/SenderPostBodyTo.js +8 -0
  44. package/dist/generated/src/models/SenderPostBodyUser.d.ts +9 -0
  45. package/dist/generated/src/models/SenderPostBodyUser.js +8 -0
  46. package/dist/generated/src/models/UpdateBroadcastRequest.d.ts +94 -0
  47. package/dist/generated/src/models/UpdateBroadcastRequest.js +78 -0
  48. package/dist/generated/src/models/User.d.ts +9 -0
  49. package/dist/generated/src/models/User.js +8 -0
  50. package/dist/generated/src/models/index.d.ts +15 -0
  51. package/dist/generated/src/models/index.js +15 -0
  52. package/dist/src/client.d.ts +4 -0
  53. package/dist/src/client.js +51 -45
  54. package/package.json +2 -2
@@ -0,0 +1,846 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Pingram
6
+ * Internal API for notification delivery and management
7
+ *
8
+ * The version of the OpenAPI document: 1.0.0
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
28
+ }) : function(o, v) {
29
+ o["default"] = v;
30
+ });
31
+ var __importStar = (this && this.__importStar) || (function () {
32
+ var ownKeys = function(o) {
33
+ ownKeys = Object.getOwnPropertyNames || function (o) {
34
+ var ar = [];
35
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
36
+ return ar;
37
+ };
38
+ return ownKeys(o);
39
+ };
40
+ return function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
47
+ })();
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ exports.BroadcastsApi = void 0;
50
+ const runtime = __importStar(require("../runtime"));
51
+ const index_1 = require("../models/index");
52
+ /**
53
+ *
54
+ */
55
+ class BroadcastsApi extends runtime.BaseAPI {
56
+ /**
57
+ * Delete an email broadcast. Allowed for drafts, scheduled, paused, completed, and canceled broadcasts. Not allowed while status is sending.
58
+ */
59
+ async _deleteRaw(requestParameters, initOverrides) {
60
+ if (requestParameters['broadcastId'] == null) {
61
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling _delete().');
62
+ }
63
+ const queryParameters = {};
64
+ const headerParameters = {};
65
+ if (this.configuration &&
66
+ (this.configuration.username !== undefined ||
67
+ this.configuration.password !== undefined)) {
68
+ headerParameters['Authorization'] =
69
+ 'Basic ' +
70
+ btoa(this.configuration.username + ':' + this.configuration.password);
71
+ }
72
+ if (this.configuration &&
73
+ (this.configuration.username !== undefined ||
74
+ this.configuration.password !== undefined)) {
75
+ headerParameters['Authorization'] =
76
+ 'Basic ' +
77
+ btoa(this.configuration.username + ':' + this.configuration.password);
78
+ }
79
+ if (this.configuration && this.configuration.accessToken) {
80
+ const token = this.configuration.accessToken;
81
+ const tokenString = await token('apiKey', []);
82
+ if (tokenString) {
83
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
84
+ }
85
+ }
86
+ if (this.configuration &&
87
+ (this.configuration.username !== undefined ||
88
+ this.configuration.password !== undefined)) {
89
+ headerParameters['Authorization'] =
90
+ 'Basic ' +
91
+ btoa(this.configuration.username + ':' + this.configuration.password);
92
+ }
93
+ let urlPath = `/broadcasts/{broadcastId}`;
94
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
95
+ const response = await this.request({
96
+ path: urlPath,
97
+ method: 'DELETE',
98
+ headers: headerParameters,
99
+ query: queryParameters
100
+ }, initOverrides);
101
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.MessageResponseFromJSON)(jsonValue));
102
+ }
103
+ /**
104
+ * Delete an email broadcast. Allowed for drafts, scheduled, paused, completed, and canceled broadcasts. Not allowed while status is sending.
105
+ */
106
+ async _delete(broadcastId, initOverrides) {
107
+ const response = await this._deleteRaw({ broadcastId: broadcastId }, initOverrides);
108
+ return await response.value();
109
+ }
110
+ /**
111
+ * Archive an email broadcast so it is hidden from the default broadcast list. Allowed for draft, paused, sent, and canceled broadcasts. Not allowed while sending or scheduled.
112
+ */
113
+ async archiveRaw(requestParameters, initOverrides) {
114
+ if (requestParameters['broadcastId'] == null) {
115
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling archive().');
116
+ }
117
+ const queryParameters = {};
118
+ const headerParameters = {};
119
+ if (this.configuration &&
120
+ (this.configuration.username !== undefined ||
121
+ this.configuration.password !== undefined)) {
122
+ headerParameters['Authorization'] =
123
+ 'Basic ' +
124
+ btoa(this.configuration.username + ':' + this.configuration.password);
125
+ }
126
+ if (this.configuration &&
127
+ (this.configuration.username !== undefined ||
128
+ this.configuration.password !== undefined)) {
129
+ headerParameters['Authorization'] =
130
+ 'Basic ' +
131
+ btoa(this.configuration.username + ':' + this.configuration.password);
132
+ }
133
+ if (this.configuration && this.configuration.accessToken) {
134
+ const token = this.configuration.accessToken;
135
+ const tokenString = await token('apiKey', []);
136
+ if (tokenString) {
137
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
138
+ }
139
+ }
140
+ if (this.configuration &&
141
+ (this.configuration.username !== undefined ||
142
+ this.configuration.password !== undefined)) {
143
+ headerParameters['Authorization'] =
144
+ 'Basic ' +
145
+ btoa(this.configuration.username + ':' + this.configuration.password);
146
+ }
147
+ let urlPath = `/broadcasts/{broadcastId}/archive`;
148
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
149
+ const response = await this.request({
150
+ path: urlPath,
151
+ method: 'POST',
152
+ headers: headerParameters,
153
+ query: queryParameters
154
+ }, initOverrides);
155
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BroadcastResponseFromJSON)(jsonValue));
156
+ }
157
+ /**
158
+ * Archive an email broadcast so it is hidden from the default broadcast list. Allowed for draft, paused, sent, and canceled broadcasts. Not allowed while sending or scheduled.
159
+ */
160
+ async archive(broadcastId, initOverrides) {
161
+ const response = await this.archiveRaw({ broadcastId: broadcastId }, initOverrides);
162
+ return await response.value();
163
+ }
164
+ /**
165
+ * Cancel an email broadcast. Scheduled broadcasts revert to draft and drop their schedule. Sending or paused broadcasts become canceled; remaining pending recipients are skipped.
166
+ */
167
+ async cancelRaw(requestParameters, initOverrides) {
168
+ if (requestParameters['broadcastId'] == null) {
169
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling cancel().');
170
+ }
171
+ const queryParameters = {};
172
+ const headerParameters = {};
173
+ if (this.configuration &&
174
+ (this.configuration.username !== undefined ||
175
+ this.configuration.password !== undefined)) {
176
+ headerParameters['Authorization'] =
177
+ 'Basic ' +
178
+ btoa(this.configuration.username + ':' + this.configuration.password);
179
+ }
180
+ if (this.configuration &&
181
+ (this.configuration.username !== undefined ||
182
+ this.configuration.password !== undefined)) {
183
+ headerParameters['Authorization'] =
184
+ 'Basic ' +
185
+ btoa(this.configuration.username + ':' + this.configuration.password);
186
+ }
187
+ if (this.configuration && this.configuration.accessToken) {
188
+ const token = this.configuration.accessToken;
189
+ const tokenString = await token('apiKey', []);
190
+ if (tokenString) {
191
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
192
+ }
193
+ }
194
+ if (this.configuration &&
195
+ (this.configuration.username !== undefined ||
196
+ this.configuration.password !== undefined)) {
197
+ headerParameters['Authorization'] =
198
+ 'Basic ' +
199
+ btoa(this.configuration.username + ':' + this.configuration.password);
200
+ }
201
+ let urlPath = `/broadcasts/{broadcastId}/cancel`;
202
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
203
+ const response = await this.request({
204
+ path: urlPath,
205
+ method: 'POST',
206
+ headers: headerParameters,
207
+ query: queryParameters
208
+ }, initOverrides);
209
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BroadcastResponseFromJSON)(jsonValue));
210
+ }
211
+ /**
212
+ * Cancel an email broadcast. Scheduled broadcasts revert to draft and drop their schedule. Sending or paused broadcasts become canceled; remaining pending recipients are skipped.
213
+ */
214
+ async cancel(broadcastId, initOverrides) {
215
+ const response = await this.cancelRaw({ broadcastId: broadcastId }, initOverrides);
216
+ return await response.value();
217
+ }
218
+ /**
219
+ * Create a draft email broadcast. html is the send-ready body. Optional internalTemplate is visual-editor source; if set it must be paired with html and cannot be added later. Set audience to either a Mongo-style user filter (sync users via Users API first; for large lists) or a raw email list (max 10,000). Include name, from fields, subject, and HTML. Notification type is optional on create and required before send or schedule; it is created automatically if missing.
220
+ */
221
+ async createRaw(requestParameters, initOverrides) {
222
+ if (requestParameters['createBroadcastRequest'] == null) {
223
+ throw new runtime.RequiredError('createBroadcastRequest', 'Required parameter "createBroadcastRequest" was null or undefined when calling create().');
224
+ }
225
+ const queryParameters = {};
226
+ const headerParameters = {};
227
+ headerParameters['Content-Type'] = 'application/json';
228
+ if (this.configuration &&
229
+ (this.configuration.username !== undefined ||
230
+ this.configuration.password !== undefined)) {
231
+ headerParameters['Authorization'] =
232
+ 'Basic ' +
233
+ btoa(this.configuration.username + ':' + this.configuration.password);
234
+ }
235
+ if (this.configuration &&
236
+ (this.configuration.username !== undefined ||
237
+ this.configuration.password !== undefined)) {
238
+ headerParameters['Authorization'] =
239
+ 'Basic ' +
240
+ btoa(this.configuration.username + ':' + this.configuration.password);
241
+ }
242
+ if (this.configuration && this.configuration.accessToken) {
243
+ const token = this.configuration.accessToken;
244
+ const tokenString = await token('apiKey', []);
245
+ if (tokenString) {
246
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
247
+ }
248
+ }
249
+ if (this.configuration &&
250
+ (this.configuration.username !== undefined ||
251
+ this.configuration.password !== undefined)) {
252
+ headerParameters['Authorization'] =
253
+ 'Basic ' +
254
+ btoa(this.configuration.username + ':' + this.configuration.password);
255
+ }
256
+ let urlPath = `/broadcasts`;
257
+ const response = await this.request({
258
+ path: urlPath,
259
+ method: 'POST',
260
+ headers: headerParameters,
261
+ query: queryParameters,
262
+ body: (0, index_1.CreateBroadcastRequestToJSON)(requestParameters['createBroadcastRequest'])
263
+ }, initOverrides);
264
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BroadcastResponseFromJSON)(jsonValue));
265
+ }
266
+ /**
267
+ * Create a draft email broadcast. html is the send-ready body. Optional internalTemplate is visual-editor source; if set it must be paired with html and cannot be added later. Set audience to either a Mongo-style user filter (sync users via Users API first; for large lists) or a raw email list (max 10,000). Include name, from fields, subject, and HTML. Notification type is optional on create and required before send or schedule; it is created automatically if missing.
268
+ */
269
+ async create(createBroadcastRequest, initOverrides) {
270
+ const response = await this.createRaw({ createBroadcastRequest: createBroadcastRequest }, initOverrides);
271
+ return await response.value();
272
+ }
273
+ /**
274
+ * Get one email broadcast by ID, including the send-ready html body, optional internalTemplate (visual-editor source), and audience definition.
275
+ */
276
+ async getRaw(requestParameters, initOverrides) {
277
+ if (requestParameters['broadcastId'] == null) {
278
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling get().');
279
+ }
280
+ const queryParameters = {};
281
+ const headerParameters = {};
282
+ if (this.configuration &&
283
+ (this.configuration.username !== undefined ||
284
+ this.configuration.password !== undefined)) {
285
+ headerParameters['Authorization'] =
286
+ 'Basic ' +
287
+ btoa(this.configuration.username + ':' + this.configuration.password);
288
+ }
289
+ if (this.configuration &&
290
+ (this.configuration.username !== undefined ||
291
+ this.configuration.password !== undefined)) {
292
+ headerParameters['Authorization'] =
293
+ 'Basic ' +
294
+ btoa(this.configuration.username + ':' + this.configuration.password);
295
+ }
296
+ if (this.configuration && this.configuration.accessToken) {
297
+ const token = this.configuration.accessToken;
298
+ const tokenString = await token('apiKey', []);
299
+ if (tokenString) {
300
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
301
+ }
302
+ }
303
+ if (this.configuration &&
304
+ (this.configuration.username !== undefined ||
305
+ this.configuration.password !== undefined)) {
306
+ headerParameters['Authorization'] =
307
+ 'Basic ' +
308
+ btoa(this.configuration.username + ':' + this.configuration.password);
309
+ }
310
+ let urlPath = `/broadcasts/{broadcastId}`;
311
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
312
+ const response = await this.request({
313
+ path: urlPath,
314
+ method: 'GET',
315
+ headers: headerParameters,
316
+ query: queryParameters
317
+ }, initOverrides);
318
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BroadcastResponseFromJSON)(jsonValue));
319
+ }
320
+ /**
321
+ * Get one email broadcast by ID, including the send-ready html body, optional internalTemplate (visual-editor source), and audience definition.
322
+ */
323
+ async get(broadcastId, initOverrides) {
324
+ const response = await this.getRaw({ broadcastId: broadcastId }, initOverrides);
325
+ return await response.value();
326
+ }
327
+ /**
328
+ * Poll live email broadcast metrics: status, optional pausedReason or scheduleAt, and aggregate counters (total, sent, delivered, opened, clicked, bounced, complained, unsubscribed, skipped, failed).
329
+ */
330
+ async getMetricsRaw(requestParameters, initOverrides) {
331
+ if (requestParameters['broadcastId'] == null) {
332
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling getMetrics().');
333
+ }
334
+ const queryParameters = {};
335
+ const headerParameters = {};
336
+ if (this.configuration &&
337
+ (this.configuration.username !== undefined ||
338
+ this.configuration.password !== undefined)) {
339
+ headerParameters['Authorization'] =
340
+ 'Basic ' +
341
+ btoa(this.configuration.username + ':' + this.configuration.password);
342
+ }
343
+ if (this.configuration &&
344
+ (this.configuration.username !== undefined ||
345
+ this.configuration.password !== undefined)) {
346
+ headerParameters['Authorization'] =
347
+ 'Basic ' +
348
+ btoa(this.configuration.username + ':' + this.configuration.password);
349
+ }
350
+ if (this.configuration && this.configuration.accessToken) {
351
+ const token = this.configuration.accessToken;
352
+ const tokenString = await token('apiKey', []);
353
+ if (tokenString) {
354
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
355
+ }
356
+ }
357
+ if (this.configuration &&
358
+ (this.configuration.username !== undefined ||
359
+ this.configuration.password !== undefined)) {
360
+ headerParameters['Authorization'] =
361
+ 'Basic ' +
362
+ btoa(this.configuration.username + ':' + this.configuration.password);
363
+ }
364
+ let urlPath = `/broadcasts/{broadcastId}/metrics`;
365
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
366
+ const response = await this.request({
367
+ path: urlPath,
368
+ method: 'GET',
369
+ headers: headerParameters,
370
+ query: queryParameters
371
+ }, initOverrides);
372
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BroadcastMetricsResponseFromJSON)(jsonValue));
373
+ }
374
+ /**
375
+ * Poll live email broadcast metrics: status, optional pausedReason or scheduleAt, and aggregate counters (total, sent, delivered, opened, clicked, bounced, complained, unsubscribed, skipped, failed).
376
+ */
377
+ async getMetrics(broadcastId, initOverrides) {
378
+ const response = await this.getMetricsRaw({ broadcastId: broadcastId }, initOverrides);
379
+ return await response.value();
380
+ }
381
+ /**
382
+ * List email broadcasts for the account, newest first. Returns metadata and counters without html or internalTemplate bodies. Paginate with limit (default 50, max 100) and nextToken.
383
+ */
384
+ async listRaw(requestParameters, initOverrides) {
385
+ const queryParameters = {};
386
+ if (requestParameters['limit'] != null) {
387
+ queryParameters['limit'] = requestParameters['limit'];
388
+ }
389
+ if (requestParameters['nextToken'] != null) {
390
+ queryParameters['nextToken'] = requestParameters['nextToken'];
391
+ }
392
+ const headerParameters = {};
393
+ if (this.configuration &&
394
+ (this.configuration.username !== undefined ||
395
+ this.configuration.password !== undefined)) {
396
+ headerParameters['Authorization'] =
397
+ 'Basic ' +
398
+ btoa(this.configuration.username + ':' + this.configuration.password);
399
+ }
400
+ if (this.configuration &&
401
+ (this.configuration.username !== undefined ||
402
+ this.configuration.password !== undefined)) {
403
+ headerParameters['Authorization'] =
404
+ 'Basic ' +
405
+ btoa(this.configuration.username + ':' + this.configuration.password);
406
+ }
407
+ if (this.configuration && this.configuration.accessToken) {
408
+ const token = this.configuration.accessToken;
409
+ const tokenString = await token('apiKey', []);
410
+ if (tokenString) {
411
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
412
+ }
413
+ }
414
+ if (this.configuration &&
415
+ (this.configuration.username !== undefined ||
416
+ this.configuration.password !== undefined)) {
417
+ headerParameters['Authorization'] =
418
+ 'Basic ' +
419
+ btoa(this.configuration.username + ':' + this.configuration.password);
420
+ }
421
+ let urlPath = `/broadcasts`;
422
+ const response = await this.request({
423
+ path: urlPath,
424
+ method: 'GET',
425
+ headers: headerParameters,
426
+ query: queryParameters
427
+ }, initOverrides);
428
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.ListBroadcastsResponseFromJSON)(jsonValue));
429
+ }
430
+ /**
431
+ * List email broadcasts for the account, newest first. Returns metadata and counters without html or internalTemplate bodies. Paginate with limit (default 50, max 100) and nextToken.
432
+ */
433
+ async list(limit, nextToken, initOverrides) {
434
+ const response = await this.listRaw({ limit: limit, nextToken: nextToken }, initOverrides);
435
+ return await response.value();
436
+ }
437
+ /**
438
+ * List email broadcast recipients with per-recipient delivery fact timestamps (sentAt, deliveredAt, openedAt, etc.). Derive display status client-side from timestamps. Filter by status (pending, sent, delivered, opened, clicked, bounced, complained, unsubscribed, skipped, failed, problems). Paginate with limit (default 50, max 200) and nextToken.
439
+ */
440
+ async listRecipientsRaw(requestParameters, initOverrides) {
441
+ if (requestParameters['broadcastId'] == null) {
442
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling listRecipients().');
443
+ }
444
+ const queryParameters = {};
445
+ if (requestParameters['status'] != null) {
446
+ queryParameters['status'] = requestParameters['status'];
447
+ }
448
+ if (requestParameters['limit'] != null) {
449
+ queryParameters['limit'] = requestParameters['limit'];
450
+ }
451
+ if (requestParameters['nextToken'] != null) {
452
+ queryParameters['nextToken'] = requestParameters['nextToken'];
453
+ }
454
+ const headerParameters = {};
455
+ if (this.configuration &&
456
+ (this.configuration.username !== undefined ||
457
+ this.configuration.password !== undefined)) {
458
+ headerParameters['Authorization'] =
459
+ 'Basic ' +
460
+ btoa(this.configuration.username + ':' + this.configuration.password);
461
+ }
462
+ if (this.configuration &&
463
+ (this.configuration.username !== undefined ||
464
+ this.configuration.password !== undefined)) {
465
+ headerParameters['Authorization'] =
466
+ 'Basic ' +
467
+ btoa(this.configuration.username + ':' + this.configuration.password);
468
+ }
469
+ if (this.configuration && this.configuration.accessToken) {
470
+ const token = this.configuration.accessToken;
471
+ const tokenString = await token('apiKey', []);
472
+ if (tokenString) {
473
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
474
+ }
475
+ }
476
+ if (this.configuration &&
477
+ (this.configuration.username !== undefined ||
478
+ this.configuration.password !== undefined)) {
479
+ headerParameters['Authorization'] =
480
+ 'Basic ' +
481
+ btoa(this.configuration.username + ':' + this.configuration.password);
482
+ }
483
+ let urlPath = `/broadcasts/{broadcastId}/recipients`;
484
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
485
+ const response = await this.request({
486
+ path: urlPath,
487
+ method: 'GET',
488
+ headers: headerParameters,
489
+ query: queryParameters
490
+ }, initOverrides);
491
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.ListBroadcastRecipientsResponseFromJSON)(jsonValue));
492
+ }
493
+ /**
494
+ * List email broadcast recipients with per-recipient delivery fact timestamps (sentAt, deliveredAt, openedAt, etc.). Derive display status client-side from timestamps. Filter by status (pending, sent, delivered, opened, clicked, bounced, complained, unsubscribed, skipped, failed, problems). Paginate with limit (default 50, max 200) and nextToken.
495
+ */
496
+ async listRecipients(broadcastId, status, limit, nextToken, initOverrides) {
497
+ const response = await this.listRecipientsRaw({
498
+ broadcastId: broadcastId,
499
+ status: status,
500
+ limit: limit,
501
+ nextToken: nextToken
502
+ }, initOverrides);
503
+ return await response.value();
504
+ }
505
+ /**
506
+ * Pause an actively sending email broadcast. Status becomes paused with pausedReason PAUSED_BY_USER.
507
+ */
508
+ async pauseRaw(requestParameters, initOverrides) {
509
+ if (requestParameters['broadcastId'] == null) {
510
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling pause().');
511
+ }
512
+ const queryParameters = {};
513
+ const headerParameters = {};
514
+ if (this.configuration &&
515
+ (this.configuration.username !== undefined ||
516
+ this.configuration.password !== undefined)) {
517
+ headerParameters['Authorization'] =
518
+ 'Basic ' +
519
+ btoa(this.configuration.username + ':' + this.configuration.password);
520
+ }
521
+ if (this.configuration &&
522
+ (this.configuration.username !== undefined ||
523
+ this.configuration.password !== undefined)) {
524
+ headerParameters['Authorization'] =
525
+ 'Basic ' +
526
+ btoa(this.configuration.username + ':' + this.configuration.password);
527
+ }
528
+ if (this.configuration && this.configuration.accessToken) {
529
+ const token = this.configuration.accessToken;
530
+ const tokenString = await token('apiKey', []);
531
+ if (tokenString) {
532
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
533
+ }
534
+ }
535
+ if (this.configuration &&
536
+ (this.configuration.username !== undefined ||
537
+ this.configuration.password !== undefined)) {
538
+ headerParameters['Authorization'] =
539
+ 'Basic ' +
540
+ btoa(this.configuration.username + ':' + this.configuration.password);
541
+ }
542
+ let urlPath = `/broadcasts/{broadcastId}/pause`;
543
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
544
+ const response = await this.request({
545
+ path: urlPath,
546
+ method: 'POST',
547
+ headers: headerParameters,
548
+ query: queryParameters
549
+ }, initOverrides);
550
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BroadcastResponseFromJSON)(jsonValue));
551
+ }
552
+ /**
553
+ * Pause an actively sending email broadcast. Status becomes paused with pausedReason PAUSED_BY_USER.
554
+ */
555
+ async pause(broadcastId, initOverrides) {
556
+ const response = await this.pauseRaw({ broadcastId: broadcastId }, initOverrides);
557
+ return await response.value();
558
+ }
559
+ /**
560
+ * Resume a paused email broadcast. Continues sending remaining recipients. Broadcasts paused for spam content cannot be resumed.
561
+ */
562
+ async resumeRaw(requestParameters, initOverrides) {
563
+ if (requestParameters['broadcastId'] == null) {
564
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling resume().');
565
+ }
566
+ const queryParameters = {};
567
+ const headerParameters = {};
568
+ if (this.configuration &&
569
+ (this.configuration.username !== undefined ||
570
+ this.configuration.password !== undefined)) {
571
+ headerParameters['Authorization'] =
572
+ 'Basic ' +
573
+ btoa(this.configuration.username + ':' + this.configuration.password);
574
+ }
575
+ if (this.configuration &&
576
+ (this.configuration.username !== undefined ||
577
+ this.configuration.password !== undefined)) {
578
+ headerParameters['Authorization'] =
579
+ 'Basic ' +
580
+ btoa(this.configuration.username + ':' + this.configuration.password);
581
+ }
582
+ if (this.configuration && this.configuration.accessToken) {
583
+ const token = this.configuration.accessToken;
584
+ const tokenString = await token('apiKey', []);
585
+ if (tokenString) {
586
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
587
+ }
588
+ }
589
+ if (this.configuration &&
590
+ (this.configuration.username !== undefined ||
591
+ this.configuration.password !== undefined)) {
592
+ headerParameters['Authorization'] =
593
+ 'Basic ' +
594
+ btoa(this.configuration.username + ':' + this.configuration.password);
595
+ }
596
+ let urlPath = `/broadcasts/{broadcastId}/resume`;
597
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
598
+ const response = await this.request({
599
+ path: urlPath,
600
+ method: 'POST',
601
+ headers: headerParameters,
602
+ query: queryParameters
603
+ }, initOverrides);
604
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BroadcastResponseFromJSON)(jsonValue));
605
+ }
606
+ /**
607
+ * Resume a paused email broadcast. Continues sending remaining recipients. Broadcasts paused for spam content cannot be resumed.
608
+ */
609
+ async resume(broadcastId, initOverrides) {
610
+ const response = await this.resumeRaw({ broadcastId: broadcastId }, initOverrides);
611
+ return await response.value();
612
+ }
613
+ /**
614
+ * Schedule a draft email broadcast for a future ISO datetime (sendAt). Requires a non-empty subject. fromAddress must be the platform default sender or a domain verified for this account (Settings → Domain Verification). The platform default sender is for testing only (at most 10 recipients, heavily throttled). Cancels any existing schedule when the broadcast is returned to draft via cancel.
615
+ */
616
+ async scheduleRaw(requestParameters, initOverrides) {
617
+ if (requestParameters['broadcastId'] == null) {
618
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling schedule().');
619
+ }
620
+ if (requestParameters['scheduleBroadcastRequest'] == null) {
621
+ throw new runtime.RequiredError('scheduleBroadcastRequest', 'Required parameter "scheduleBroadcastRequest" was null or undefined when calling schedule().');
622
+ }
623
+ const queryParameters = {};
624
+ const headerParameters = {};
625
+ headerParameters['Content-Type'] = 'application/json';
626
+ if (this.configuration &&
627
+ (this.configuration.username !== undefined ||
628
+ this.configuration.password !== undefined)) {
629
+ headerParameters['Authorization'] =
630
+ 'Basic ' +
631
+ btoa(this.configuration.username + ':' + this.configuration.password);
632
+ }
633
+ if (this.configuration &&
634
+ (this.configuration.username !== undefined ||
635
+ this.configuration.password !== undefined)) {
636
+ headerParameters['Authorization'] =
637
+ 'Basic ' +
638
+ btoa(this.configuration.username + ':' + this.configuration.password);
639
+ }
640
+ if (this.configuration && this.configuration.accessToken) {
641
+ const token = this.configuration.accessToken;
642
+ const tokenString = await token('apiKey', []);
643
+ if (tokenString) {
644
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
645
+ }
646
+ }
647
+ if (this.configuration &&
648
+ (this.configuration.username !== undefined ||
649
+ this.configuration.password !== undefined)) {
650
+ headerParameters['Authorization'] =
651
+ 'Basic ' +
652
+ btoa(this.configuration.username + ':' + this.configuration.password);
653
+ }
654
+ let urlPath = `/broadcasts/{broadcastId}/schedule`;
655
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
656
+ const response = await this.request({
657
+ path: urlPath,
658
+ method: 'POST',
659
+ headers: headerParameters,
660
+ query: queryParameters,
661
+ body: (0, index_1.ScheduleBroadcastRequestToJSON)(requestParameters['scheduleBroadcastRequest'])
662
+ }, initOverrides);
663
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BroadcastResponseFromJSON)(jsonValue));
664
+ }
665
+ /**
666
+ * Schedule a draft email broadcast for a future ISO datetime (sendAt). Requires a non-empty subject. fromAddress must be the platform default sender or a domain verified for this account (Settings → Domain Verification). The platform default sender is for testing only (at most 10 recipients, heavily throttled). Cancels any existing schedule when the broadcast is returned to draft via cancel.
667
+ */
668
+ async schedule(broadcastId, scheduleBroadcastRequest, initOverrides) {
669
+ const response = await this.scheduleRaw({
670
+ broadcastId: broadcastId,
671
+ scheduleBroadcastRequest: scheduleBroadcastRequest
672
+ }, initOverrides);
673
+ return await response.value();
674
+ }
675
+ /**
676
+ * Send a draft email broadcast immediately. Requires a non-empty subject. fromAddress must be the platform default sender or a domain verified for this account (Settings → Domain Verification). The platform default sender is for testing only (at most 10 recipients, heavily throttled). Transitions status to sending and starts delivery.
677
+ */
678
+ async sendRaw(requestParameters, initOverrides) {
679
+ if (requestParameters['broadcastId'] == null) {
680
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling send().');
681
+ }
682
+ const queryParameters = {};
683
+ const headerParameters = {};
684
+ if (this.configuration &&
685
+ (this.configuration.username !== undefined ||
686
+ this.configuration.password !== undefined)) {
687
+ headerParameters['Authorization'] =
688
+ 'Basic ' +
689
+ btoa(this.configuration.username + ':' + this.configuration.password);
690
+ }
691
+ if (this.configuration &&
692
+ (this.configuration.username !== undefined ||
693
+ this.configuration.password !== undefined)) {
694
+ headerParameters['Authorization'] =
695
+ 'Basic ' +
696
+ btoa(this.configuration.username + ':' + this.configuration.password);
697
+ }
698
+ if (this.configuration && this.configuration.accessToken) {
699
+ const token = this.configuration.accessToken;
700
+ const tokenString = await token('apiKey', []);
701
+ if (tokenString) {
702
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
703
+ }
704
+ }
705
+ if (this.configuration &&
706
+ (this.configuration.username !== undefined ||
707
+ this.configuration.password !== undefined)) {
708
+ headerParameters['Authorization'] =
709
+ 'Basic ' +
710
+ btoa(this.configuration.username + ':' + this.configuration.password);
711
+ }
712
+ let urlPath = `/broadcasts/{broadcastId}/send`;
713
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
714
+ const response = await this.request({
715
+ path: urlPath,
716
+ method: 'POST',
717
+ headers: headerParameters,
718
+ query: queryParameters
719
+ }, initOverrides);
720
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BroadcastResponseFromJSON)(jsonValue));
721
+ }
722
+ /**
723
+ * Send a draft email broadcast immediately. Requires a non-empty subject. fromAddress must be the platform default sender or a domain verified for this account (Settings → Domain Verification). The platform default sender is for testing only (at most 10 recipients, heavily throttled). Transitions status to sending and starts delivery.
724
+ */
725
+ async send(broadcastId, initOverrides) {
726
+ const response = await this.sendRaw({ broadcastId: broadcastId }, initOverrides);
727
+ return await response.value();
728
+ }
729
+ /**
730
+ * Restore an archived email broadcast to the default broadcast list.
731
+ */
732
+ async unarchiveRaw(requestParameters, initOverrides) {
733
+ if (requestParameters['broadcastId'] == null) {
734
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling unarchive().');
735
+ }
736
+ const queryParameters = {};
737
+ const headerParameters = {};
738
+ if (this.configuration &&
739
+ (this.configuration.username !== undefined ||
740
+ this.configuration.password !== undefined)) {
741
+ headerParameters['Authorization'] =
742
+ 'Basic ' +
743
+ btoa(this.configuration.username + ':' + this.configuration.password);
744
+ }
745
+ if (this.configuration &&
746
+ (this.configuration.username !== undefined ||
747
+ this.configuration.password !== undefined)) {
748
+ headerParameters['Authorization'] =
749
+ 'Basic ' +
750
+ btoa(this.configuration.username + ':' + this.configuration.password);
751
+ }
752
+ if (this.configuration && this.configuration.accessToken) {
753
+ const token = this.configuration.accessToken;
754
+ const tokenString = await token('apiKey', []);
755
+ if (tokenString) {
756
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
757
+ }
758
+ }
759
+ if (this.configuration &&
760
+ (this.configuration.username !== undefined ||
761
+ this.configuration.password !== undefined)) {
762
+ headerParameters['Authorization'] =
763
+ 'Basic ' +
764
+ btoa(this.configuration.username + ':' + this.configuration.password);
765
+ }
766
+ let urlPath = `/broadcasts/{broadcastId}/unarchive`;
767
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
768
+ const response = await this.request({
769
+ path: urlPath,
770
+ method: 'POST',
771
+ headers: headerParameters,
772
+ query: queryParameters
773
+ }, initOverrides);
774
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BroadcastResponseFromJSON)(jsonValue));
775
+ }
776
+ /**
777
+ * Restore an archived email broadcast to the default broadcast list.
778
+ */
779
+ async unarchive(broadcastId, initOverrides) {
780
+ const response = await this.unarchiveRaw({ broadcastId: broadcastId }, initOverrides);
781
+ return await response.value();
782
+ }
783
+ /**
784
+ * Update a draft email broadcast (name, type, audience, sender, subject, html). html is the send-ready body. Send an empty replyToAddress to clear Reply-To. internalTemplate can be updated only when the broadcast was created with it; it cannot be added to an html-only broadcast or removed. Only drafts can be edited; scheduled or active broadcasts are locked.
785
+ */
786
+ async updateRaw(requestParameters, initOverrides) {
787
+ if (requestParameters['broadcastId'] == null) {
788
+ throw new runtime.RequiredError('broadcastId', 'Required parameter "broadcastId" was null or undefined when calling update().');
789
+ }
790
+ if (requestParameters['updateBroadcastRequest'] == null) {
791
+ throw new runtime.RequiredError('updateBroadcastRequest', 'Required parameter "updateBroadcastRequest" was null or undefined when calling update().');
792
+ }
793
+ const queryParameters = {};
794
+ const headerParameters = {};
795
+ headerParameters['Content-Type'] = 'application/json';
796
+ if (this.configuration &&
797
+ (this.configuration.username !== undefined ||
798
+ this.configuration.password !== undefined)) {
799
+ headerParameters['Authorization'] =
800
+ 'Basic ' +
801
+ btoa(this.configuration.username + ':' + this.configuration.password);
802
+ }
803
+ if (this.configuration &&
804
+ (this.configuration.username !== undefined ||
805
+ this.configuration.password !== undefined)) {
806
+ headerParameters['Authorization'] =
807
+ 'Basic ' +
808
+ btoa(this.configuration.username + ':' + this.configuration.password);
809
+ }
810
+ if (this.configuration && this.configuration.accessToken) {
811
+ const token = this.configuration.accessToken;
812
+ const tokenString = await token('apiKey', []);
813
+ if (tokenString) {
814
+ headerParameters['Authorization'] = `Bearer ${tokenString}`;
815
+ }
816
+ }
817
+ if (this.configuration &&
818
+ (this.configuration.username !== undefined ||
819
+ this.configuration.password !== undefined)) {
820
+ headerParameters['Authorization'] =
821
+ 'Basic ' +
822
+ btoa(this.configuration.username + ':' + this.configuration.password);
823
+ }
824
+ let urlPath = `/broadcasts/{broadcastId}`;
825
+ urlPath = urlPath.replace(`{${'broadcastId'}}`, encodeURIComponent(String(requestParameters['broadcastId'])));
826
+ const response = await this.request({
827
+ path: urlPath,
828
+ method: 'PATCH',
829
+ headers: headerParameters,
830
+ query: queryParameters,
831
+ body: (0, index_1.UpdateBroadcastRequestToJSON)(requestParameters['updateBroadcastRequest'])
832
+ }, initOverrides);
833
+ return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.BroadcastResponseFromJSON)(jsonValue));
834
+ }
835
+ /**
836
+ * Update a draft email broadcast (name, type, audience, sender, subject, html). html is the send-ready body. Send an empty replyToAddress to clear Reply-To. internalTemplate can be updated only when the broadcast was created with it; it cannot be added to an html-only broadcast or removed. Only drafts can be edited; scheduled or active broadcasts are locked.
837
+ */
838
+ async update(broadcastId, updateBroadcastRequest, initOverrides) {
839
+ const response = await this.updateRaw({
840
+ broadcastId: broadcastId,
841
+ updateBroadcastRequest: updateBroadcastRequest
842
+ }, initOverrides);
843
+ return await response.value();
844
+ }
845
+ }
846
+ exports.BroadcastsApi = BroadcastsApi;