@scaleway/sdk-tem 1.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.
@@ -0,0 +1,551 @@
1
+ import { isJSONObject, unmarshalDate, unmarshalArrayOfObject } from "@scaleway/sdk-client";
2
+ const unmarshalEmailTry = (data) => {
3
+ if (!isJSONObject(data)) {
4
+ throw new TypeError(
5
+ `Unmarshalling the type 'EmailTry' failed as data isn't a dictionary.`
6
+ );
7
+ }
8
+ return {
9
+ code: data.code,
10
+ message: data.message,
11
+ rank: data.rank,
12
+ triedAt: unmarshalDate(data.tried_at)
13
+ };
14
+ };
15
+ const unmarshalEmail = (data) => {
16
+ if (!isJSONObject(data)) {
17
+ throw new TypeError(
18
+ `Unmarshalling the type 'Email' failed as data isn't a dictionary.`
19
+ );
20
+ }
21
+ return {
22
+ createdAt: unmarshalDate(data.created_at),
23
+ flags: data.flags,
24
+ id: data.id,
25
+ lastTries: unmarshalArrayOfObject(data.last_tries, unmarshalEmailTry),
26
+ mailFrom: data.mail_from,
27
+ mailRcpt: data.mail_rcpt,
28
+ messageId: data.message_id,
29
+ projectId: data.project_id,
30
+ rcptTo: data.rcpt_to,
31
+ rcptType: data.rcpt_type,
32
+ status: data.status,
33
+ statusDetails: data.status_details,
34
+ subject: data.subject,
35
+ tryCount: data.try_count,
36
+ updatedAt: unmarshalDate(data.updated_at)
37
+ };
38
+ };
39
+ const unmarshalDomainRecordsDMARC = (data) => {
40
+ if (!isJSONObject(data)) {
41
+ throw new TypeError(
42
+ `Unmarshalling the type 'DomainRecordsDMARC' failed as data isn't a dictionary.`
43
+ );
44
+ }
45
+ return {
46
+ name: data.name,
47
+ value: data.value
48
+ };
49
+ };
50
+ const unmarshalDomainRecords = (data) => {
51
+ if (!isJSONObject(data)) {
52
+ throw new TypeError(
53
+ `Unmarshalling the type 'DomainRecords' failed as data isn't a dictionary.`
54
+ );
55
+ }
56
+ return {
57
+ dmarc: data.dmarc ? unmarshalDomainRecordsDMARC(data.dmarc) : void 0
58
+ };
59
+ };
60
+ const unmarshalDomainReputation = (data) => {
61
+ if (!isJSONObject(data)) {
62
+ throw new TypeError(
63
+ `Unmarshalling the type 'DomainReputation' failed as data isn't a dictionary.`
64
+ );
65
+ }
66
+ return {
67
+ previousScore: data.previous_score,
68
+ previousScoredAt: unmarshalDate(data.previous_scored_at),
69
+ score: data.score,
70
+ scoredAt: unmarshalDate(data.scored_at),
71
+ status: data.status
72
+ };
73
+ };
74
+ const unmarshalDomainStatistics = (data) => {
75
+ if (!isJSONObject(data)) {
76
+ throw new TypeError(
77
+ `Unmarshalling the type 'DomainStatistics' failed as data isn't a dictionary.`
78
+ );
79
+ }
80
+ return {
81
+ canceledCount: data.canceled_count,
82
+ failedCount: data.failed_count,
83
+ sentCount: data.sent_count,
84
+ totalCount: data.total_count
85
+ };
86
+ };
87
+ const unmarshalDomain = (data) => {
88
+ if (!isJSONObject(data)) {
89
+ throw new TypeError(
90
+ `Unmarshalling the type 'Domain' failed as data isn't a dictionary.`
91
+ );
92
+ }
93
+ return {
94
+ autoconfig: data.autoconfig,
95
+ createdAt: unmarshalDate(data.created_at),
96
+ dkimConfig: data.dkim_config,
97
+ id: data.id,
98
+ lastError: data.last_error,
99
+ lastValidAt: unmarshalDate(data.last_valid_at),
100
+ name: data.name,
101
+ nextCheckAt: unmarshalDate(data.next_check_at),
102
+ organizationId: data.organization_id,
103
+ projectId: data.project_id,
104
+ records: data.records ? unmarshalDomainRecords(data.records) : void 0,
105
+ region: data.region,
106
+ reputation: data.reputation ? unmarshalDomainReputation(data.reputation) : void 0,
107
+ revokedAt: unmarshalDate(data.revoked_at),
108
+ spfConfig: data.spf_config,
109
+ statistics: data.statistics ? unmarshalDomainStatistics(data.statistics) : void 0,
110
+ status: data.status
111
+ };
112
+ };
113
+ const unmarshalOfferSubscription = (data) => {
114
+ if (!isJSONObject(data)) {
115
+ throw new TypeError(
116
+ `Unmarshalling the type 'OfferSubscription' failed as data isn't a dictionary.`
117
+ );
118
+ }
119
+ return {
120
+ cancellationAvailableAt: unmarshalDate(data.cancellation_available_at),
121
+ includedMonthlyEmails: data.included_monthly_emails,
122
+ maxCustomBlocklistsPerDomain: data.max_custom_blocklists_per_domain,
123
+ maxDedicatedIps: data.max_dedicated_ips,
124
+ maxDomains: data.max_domains,
125
+ maxWebhooksPerDomain: data.max_webhooks_per_domain,
126
+ offerName: data.offer_name,
127
+ organizationId: data.organization_id,
128
+ projectId: data.project_id,
129
+ sla: data.sla,
130
+ subscribedAt: unmarshalDate(data.subscribed_at)
131
+ };
132
+ };
133
+ const unmarshalWebhook = (data) => {
134
+ if (!isJSONObject(data)) {
135
+ throw new TypeError(
136
+ `Unmarshalling the type 'Webhook' failed as data isn't a dictionary.`
137
+ );
138
+ }
139
+ return {
140
+ createdAt: unmarshalDate(data.created_at),
141
+ domainId: data.domain_id,
142
+ eventTypes: data.event_types,
143
+ id: data.id,
144
+ name: data.name,
145
+ organizationId: data.organization_id,
146
+ projectId: data.project_id,
147
+ snsArn: data.sns_arn,
148
+ updatedAt: unmarshalDate(data.updated_at)
149
+ };
150
+ };
151
+ const unmarshalBlocklist = (data) => {
152
+ if (!isJSONObject(data)) {
153
+ throw new TypeError(
154
+ `Unmarshalling the type 'Blocklist' failed as data isn't a dictionary.`
155
+ );
156
+ }
157
+ return {
158
+ createdAt: unmarshalDate(data.created_at),
159
+ custom: data.custom,
160
+ domainId: data.domain_id,
161
+ email: data.email,
162
+ endsAt: unmarshalDate(data.ends_at),
163
+ id: data.id,
164
+ reason: data.reason,
165
+ type: data.type,
166
+ updatedAt: unmarshalDate(data.updated_at)
167
+ };
168
+ };
169
+ const unmarshalBulkCreateBlocklistsResponse = (data) => {
170
+ if (!isJSONObject(data)) {
171
+ throw new TypeError(
172
+ `Unmarshalling the type 'BulkCreateBlocklistsResponse' failed as data isn't a dictionary.`
173
+ );
174
+ }
175
+ return {
176
+ blocklists: unmarshalArrayOfObject(data.blocklists, unmarshalBlocklist)
177
+ };
178
+ };
179
+ const unmarshalCreateEmailResponse = (data) => {
180
+ if (!isJSONObject(data)) {
181
+ throw new TypeError(
182
+ `Unmarshalling the type 'CreateEmailResponse' failed as data isn't a dictionary.`
183
+ );
184
+ }
185
+ return {
186
+ emails: unmarshalArrayOfObject(data.emails, unmarshalEmail)
187
+ };
188
+ };
189
+ const unmarshalDomainLastStatusAutoconfigState = (data) => {
190
+ if (!isJSONObject(data)) {
191
+ throw new TypeError(
192
+ `Unmarshalling the type 'DomainLastStatusAutoconfigState' failed as data isn't a dictionary.`
193
+ );
194
+ }
195
+ return {
196
+ autoconfigurable: data.autoconfigurable,
197
+ enabled: data.enabled,
198
+ reason: data.reason ? data.reason : void 0
199
+ };
200
+ };
201
+ const unmarshalDomainLastStatusDkimRecord = (data) => {
202
+ if (!isJSONObject(data)) {
203
+ throw new TypeError(
204
+ `Unmarshalling the type 'DomainLastStatusDkimRecord' failed as data isn't a dictionary.`
205
+ );
206
+ }
207
+ return {
208
+ error: data.error,
209
+ lastValidAt: unmarshalDate(data.last_valid_at),
210
+ status: data.status
211
+ };
212
+ };
213
+ const unmarshalDomainLastStatusDmarcRecord = (data) => {
214
+ if (!isJSONObject(data)) {
215
+ throw new TypeError(
216
+ `Unmarshalling the type 'DomainLastStatusDmarcRecord' failed as data isn't a dictionary.`
217
+ );
218
+ }
219
+ return {
220
+ error: data.error,
221
+ lastValidAt: unmarshalDate(data.last_valid_at),
222
+ status: data.status
223
+ };
224
+ };
225
+ const unmarshalDomainLastStatusSpfRecord = (data) => {
226
+ if (!isJSONObject(data)) {
227
+ throw new TypeError(
228
+ `Unmarshalling the type 'DomainLastStatusSpfRecord' failed as data isn't a dictionary.`
229
+ );
230
+ }
231
+ return {
232
+ error: data.error,
233
+ lastValidAt: unmarshalDate(data.last_valid_at),
234
+ status: data.status
235
+ };
236
+ };
237
+ const unmarshalDomainLastStatus = (data) => {
238
+ if (!isJSONObject(data)) {
239
+ throw new TypeError(
240
+ `Unmarshalling the type 'DomainLastStatus' failed as data isn't a dictionary.`
241
+ );
242
+ }
243
+ return {
244
+ autoconfigState: data.autoconfig_state ? unmarshalDomainLastStatusAutoconfigState(data.autoconfig_state) : void 0,
245
+ dkimRecord: data.dkim_record ? unmarshalDomainLastStatusDkimRecord(data.dkim_record) : void 0,
246
+ dmarcRecord: data.dmarc_record ? unmarshalDomainLastStatusDmarcRecord(data.dmarc_record) : void 0,
247
+ domainId: data.domain_id,
248
+ domainName: data.domain_name,
249
+ spfRecord: data.spf_record ? unmarshalDomainLastStatusSpfRecord(data.spf_record) : void 0
250
+ };
251
+ };
252
+ const unmarshalListBlocklistsResponse = (data) => {
253
+ if (!isJSONObject(data)) {
254
+ throw new TypeError(
255
+ `Unmarshalling the type 'ListBlocklistsResponse' failed as data isn't a dictionary.`
256
+ );
257
+ }
258
+ return {
259
+ blocklists: unmarshalArrayOfObject(data.blocklists, unmarshalBlocklist),
260
+ totalCount: data.total_count
261
+ };
262
+ };
263
+ const unmarshalListDomainsResponse = (data) => {
264
+ if (!isJSONObject(data)) {
265
+ throw new TypeError(
266
+ `Unmarshalling the type 'ListDomainsResponse' failed as data isn't a dictionary.`
267
+ );
268
+ }
269
+ return {
270
+ domains: unmarshalArrayOfObject(data.domains, unmarshalDomain),
271
+ totalCount: data.total_count
272
+ };
273
+ };
274
+ const unmarshalListEmailsResponse = (data) => {
275
+ if (!isJSONObject(data)) {
276
+ throw new TypeError(
277
+ `Unmarshalling the type 'ListEmailsResponse' failed as data isn't a dictionary.`
278
+ );
279
+ }
280
+ return {
281
+ emails: unmarshalArrayOfObject(data.emails, unmarshalEmail),
282
+ totalCount: data.total_count
283
+ };
284
+ };
285
+ const unmarshalListOfferSubscriptionsResponse = (data) => {
286
+ if (!isJSONObject(data)) {
287
+ throw new TypeError(
288
+ `Unmarshalling the type 'ListOfferSubscriptionsResponse' failed as data isn't a dictionary.`
289
+ );
290
+ }
291
+ return {
292
+ offerSubscriptions: unmarshalArrayOfObject(
293
+ data.offer_subscriptions,
294
+ unmarshalOfferSubscription
295
+ ),
296
+ totalCount: data.total_count
297
+ };
298
+ };
299
+ const unmarshalOffer = (data) => {
300
+ if (!isJSONObject(data)) {
301
+ throw new TypeError(
302
+ `Unmarshalling the type 'Offer' failed as data isn't a dictionary.`
303
+ );
304
+ }
305
+ return {
306
+ commitmentPeriod: data.commitment_period,
307
+ createdAt: unmarshalDate(data.created_at),
308
+ includedMonthlyEmails: data.included_monthly_emails,
309
+ maxCustomBlocklistsPerDomain: data.max_custom_blocklists_per_domain,
310
+ maxDedicatedIps: data.max_dedicated_ips,
311
+ maxDomains: data.max_domains,
312
+ maxWebhooksPerDomain: data.max_webhooks_per_domain,
313
+ name: data.name,
314
+ sla: data.sla
315
+ };
316
+ };
317
+ const unmarshalListOffersResponse = (data) => {
318
+ if (!isJSONObject(data)) {
319
+ throw new TypeError(
320
+ `Unmarshalling the type 'ListOffersResponse' failed as data isn't a dictionary.`
321
+ );
322
+ }
323
+ return {
324
+ offers: unmarshalArrayOfObject(data.offers, unmarshalOffer),
325
+ totalCount: data.total_count
326
+ };
327
+ };
328
+ const unmarshalPool = (data) => {
329
+ if (!isJSONObject(data)) {
330
+ throw new TypeError(
331
+ `Unmarshalling the type 'Pool' failed as data isn't a dictionary.`
332
+ );
333
+ }
334
+ return {
335
+ details: data.details,
336
+ ips: data.ips,
337
+ projectId: data.project_id,
338
+ reverse: data.reverse,
339
+ status: data.status,
340
+ zone: data.zone
341
+ };
342
+ };
343
+ const unmarshalListPoolsResponse = (data) => {
344
+ if (!isJSONObject(data)) {
345
+ throw new TypeError(
346
+ `Unmarshalling the type 'ListPoolsResponse' failed as data isn't a dictionary.`
347
+ );
348
+ }
349
+ return {
350
+ pools: unmarshalArrayOfObject(data.pools, unmarshalPool),
351
+ totalCount: data.total_count
352
+ };
353
+ };
354
+ const unmarshalWebhookEvent = (data) => {
355
+ if (!isJSONObject(data)) {
356
+ throw new TypeError(
357
+ `Unmarshalling the type 'WebhookEvent' failed as data isn't a dictionary.`
358
+ );
359
+ }
360
+ return {
361
+ createdAt: unmarshalDate(data.created_at),
362
+ data: data.data,
363
+ domainId: data.domain_id,
364
+ emailId: data.email_id,
365
+ id: data.id,
366
+ organizationId: data.organization_id,
367
+ projectId: data.project_id,
368
+ status: data.status,
369
+ type: data.type,
370
+ updatedAt: unmarshalDate(data.updated_at),
371
+ webhookId: data.webhook_id
372
+ };
373
+ };
374
+ const unmarshalListWebhookEventsResponse = (data) => {
375
+ if (!isJSONObject(data)) {
376
+ throw new TypeError(
377
+ `Unmarshalling the type 'ListWebhookEventsResponse' failed as data isn't a dictionary.`
378
+ );
379
+ }
380
+ return {
381
+ totalCount: data.total_count,
382
+ webhookEvents: unmarshalArrayOfObject(
383
+ data.webhook_events,
384
+ unmarshalWebhookEvent
385
+ )
386
+ };
387
+ };
388
+ const unmarshalListWebhooksResponse = (data) => {
389
+ if (!isJSONObject(data)) {
390
+ throw new TypeError(
391
+ `Unmarshalling the type 'ListWebhooksResponse' failed as data isn't a dictionary.`
392
+ );
393
+ }
394
+ return {
395
+ totalCount: data.total_count,
396
+ webhooks: unmarshalArrayOfObject(data.webhooks, unmarshalWebhook)
397
+ };
398
+ };
399
+ const unmarshalProjectConsumption = (data) => {
400
+ if (!isJSONObject(data)) {
401
+ throw new TypeError(
402
+ `Unmarshalling the type 'ProjectConsumption' failed as data isn't a dictionary.`
403
+ );
404
+ }
405
+ return {
406
+ customBlocklistsCount: data.custom_blocklists_count,
407
+ dedicatedIpsCount: data.dedicated_ips_count,
408
+ domainsCount: data.domains_count,
409
+ monthlyEmailsCount: data.monthly_emails_count,
410
+ projectId: data.project_id,
411
+ webhooksCount: data.webhooks_count
412
+ };
413
+ };
414
+ const unmarshalProjectSettingsPeriodicReport = (data) => {
415
+ if (!isJSONObject(data)) {
416
+ throw new TypeError(
417
+ `Unmarshalling the type 'ProjectSettingsPeriodicReport' failed as data isn't a dictionary.`
418
+ );
419
+ }
420
+ return {
421
+ enabled: data.enabled,
422
+ frequency: data.frequency,
423
+ sendingDay: data.sending_day,
424
+ sendingHour: data.sending_hour
425
+ };
426
+ };
427
+ const unmarshalProjectSettings = (data) => {
428
+ if (!isJSONObject(data)) {
429
+ throw new TypeError(
430
+ `Unmarshalling the type 'ProjectSettings' failed as data isn't a dictionary.`
431
+ );
432
+ }
433
+ return {
434
+ periodicReport: data.periodic_report ? unmarshalProjectSettingsPeriodicReport(data.periodic_report) : void 0
435
+ };
436
+ };
437
+ const unmarshalStatistics = (data) => {
438
+ if (!isJSONObject(data)) {
439
+ throw new TypeError(
440
+ `Unmarshalling the type 'Statistics' failed as data isn't a dictionary.`
441
+ );
442
+ }
443
+ return {
444
+ canceledCount: data.canceled_count,
445
+ failedCount: data.failed_count,
446
+ newCount: data.new_count,
447
+ sendingCount: data.sending_count,
448
+ sentCount: data.sent_count,
449
+ totalCount: data.total_count
450
+ };
451
+ };
452
+ const marshalBulkCreateBlocklistsRequest = (request, defaults) => ({
453
+ domain_id: request.domainId,
454
+ emails: request.emails,
455
+ reason: request.reason,
456
+ type: request.type
457
+ });
458
+ const marshalCreateDomainRequest = (request, defaults) => ({
459
+ accept_tos: request.acceptTos,
460
+ autoconfig: request.autoconfig,
461
+ domain_name: request.domainName,
462
+ project_id: request.projectId ?? defaults.defaultProjectId
463
+ });
464
+ const marshalCreateEmailRequestAddress = (request, defaults) => ({
465
+ email: request.email,
466
+ name: request.name
467
+ });
468
+ const marshalCreateEmailRequestAttachment = (request, defaults) => ({
469
+ content: request.content,
470
+ name: request.name,
471
+ type: request.type
472
+ });
473
+ const marshalCreateEmailRequestHeader = (request, defaults) => ({
474
+ key: request.key,
475
+ value: request.value
476
+ });
477
+ const marshalCreateEmailRequest = (request, defaults) => ({
478
+ additional_headers: request.additionalHeaders !== void 0 ? request.additionalHeaders.map(
479
+ (elt) => marshalCreateEmailRequestHeader(elt)
480
+ ) : void 0,
481
+ attachments: request.attachments !== void 0 ? request.attachments.map(
482
+ (elt) => marshalCreateEmailRequestAttachment(elt)
483
+ ) : void 0,
484
+ bcc: request.bcc !== void 0 ? request.bcc.map((elt) => marshalCreateEmailRequestAddress(elt)) : void 0,
485
+ cc: request.cc !== void 0 ? request.cc.map((elt) => marshalCreateEmailRequestAddress(elt)) : void 0,
486
+ from: marshalCreateEmailRequestAddress(request.from),
487
+ html: request.html,
488
+ project_id: request.projectId ?? defaults.defaultProjectId,
489
+ send_before: request.sendBefore,
490
+ subject: request.subject,
491
+ text: request.text,
492
+ to: request.to !== void 0 ? request.to.map((elt) => marshalCreateEmailRequestAddress(elt)) : void 0
493
+ });
494
+ const marshalCreateWebhookRequest = (request, defaults) => ({
495
+ domain_id: request.domainId,
496
+ event_types: request.eventTypes !== void 0 ? request.eventTypes : void 0,
497
+ name: request.name,
498
+ project_id: request.projectId ?? defaults.defaultProjectId,
499
+ sns_arn: request.snsArn
500
+ });
501
+ const marshalUpdateDomainRequest = (request, defaults) => ({
502
+ autoconfig: request.autoconfig
503
+ });
504
+ const marshalUpdateOfferSubscriptionRequest = (request, defaults) => ({
505
+ name: request.name,
506
+ project_id: request.projectId ?? defaults.defaultProjectId
507
+ });
508
+ const marshalUpdateProjectSettingsRequestUpdatePeriodicReport = (request, defaults) => ({
509
+ enabled: request.enabled,
510
+ frequency: request.frequency,
511
+ sending_day: request.sendingDay,
512
+ sending_hour: request.sendingHour
513
+ });
514
+ const marshalUpdateProjectSettingsRequest = (request, defaults) => ({
515
+ periodic_report: request.periodicReport !== void 0 ? marshalUpdateProjectSettingsRequestUpdatePeriodicReport(
516
+ request.periodicReport
517
+ ) : void 0
518
+ });
519
+ const marshalUpdateWebhookRequest = (request, defaults) => ({
520
+ event_types: request.eventTypes !== void 0 ? request.eventTypes : void 0,
521
+ name: request.name,
522
+ sns_arn: request.snsArn
523
+ });
524
+ export {
525
+ marshalBulkCreateBlocklistsRequest,
526
+ marshalCreateDomainRequest,
527
+ marshalCreateEmailRequest,
528
+ marshalCreateWebhookRequest,
529
+ marshalUpdateDomainRequest,
530
+ marshalUpdateOfferSubscriptionRequest,
531
+ marshalUpdateProjectSettingsRequest,
532
+ marshalUpdateWebhookRequest,
533
+ unmarshalBulkCreateBlocklistsResponse,
534
+ unmarshalCreateEmailResponse,
535
+ unmarshalDomain,
536
+ unmarshalDomainLastStatus,
537
+ unmarshalEmail,
538
+ unmarshalListBlocklistsResponse,
539
+ unmarshalListDomainsResponse,
540
+ unmarshalListEmailsResponse,
541
+ unmarshalListOfferSubscriptionsResponse,
542
+ unmarshalListOffersResponse,
543
+ unmarshalListPoolsResponse,
544
+ unmarshalListWebhookEventsResponse,
545
+ unmarshalListWebhooksResponse,
546
+ unmarshalOfferSubscription,
547
+ unmarshalProjectConsumption,
548
+ unmarshalProjectSettings,
549
+ unmarshalStatistics,
550
+ unmarshalWebhook
551
+ };