Skip to content

Commit ff41388

Browse files
committed
feat: update generated APIs
1 parent a7748ad commit ff41388

File tree

5 files changed

+255
-0
lines changed

5 files changed

+255
-0
lines changed

packages/clients/src/api/tem/v1alpha1/api.gen.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ import {
1313
EMAIL_TRANSIENT_STATUSES,
1414
} from './content.gen'
1515
import {
16+
marshalBulkCreateBlocklistsRequest,
1617
marshalCreateDomainRequest,
1718
marshalCreateEmailRequest,
1819
marshalCreateWebhookRequest,
1920
marshalUpdateDomainRequest,
2021
marshalUpdateProjectSettingsRequest,
2122
marshalUpdateWebhookRequest,
23+
unmarshalBulkCreateBlocklistsResponse,
2224
unmarshalCreateEmailResponse,
2325
unmarshalDomain,
2426
unmarshalDomainLastStatus,
2527
unmarshalEmail,
28+
unmarshalListBlocklistsResponse,
2629
unmarshalListDomainsResponse,
2730
unmarshalListEmailsResponse,
2831
unmarshalListWebhookEventsResponse,
@@ -32,12 +35,15 @@ import {
3235
unmarshalWebhook,
3336
} from './marshalling.gen'
3437
import type {
38+
BulkCreateBlocklistsRequest,
39+
BulkCreateBlocklistsResponse,
3540
CancelEmailRequest,
3641
CheckDomainRequest,
3742
CreateDomainRequest,
3843
CreateEmailRequest,
3944
CreateEmailResponse,
4045
CreateWebhookRequest,
46+
DeleteBlocklistRequest,
4147
DeleteWebhookRequest,
4248
Domain,
4349
DomainLastStatus,
@@ -48,6 +54,8 @@ import type {
4854
GetProjectSettingsRequest,
4955
GetStatisticsRequest,
5056
GetWebhookRequest,
57+
ListBlocklistsRequest,
58+
ListBlocklistsResponse,
5159
ListDomainsRequest,
5260
ListDomainsResponse,
5361
ListEmailsRequest,
@@ -554,4 +562,66 @@ export class API extends ParentAPI {
554562
},
555563
unmarshalProjectSettings,
556564
)
565+
566+
protected pageOfListBlocklists = (request: Readonly<ListBlocklistsRequest>) =>
567+
this.client.fetch<ListBlocklistsResponse>(
568+
{
569+
method: 'GET',
570+
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/blocklists`,
571+
urlParams: urlParams(
572+
['custom', request.custom],
573+
['domain_id', request.domainId],
574+
['email', request.email],
575+
['order_by', request.orderBy],
576+
['page', request.page],
577+
[
578+
'page_size',
579+
request.pageSize ?? this.client.settings.defaultPageSize,
580+
],
581+
['type', request.type],
582+
),
583+
},
584+
unmarshalListBlocklistsResponse,
585+
)
586+
587+
/**
588+
* List blocklists. Retrieve the list of blocklists.
589+
*
590+
* @param request - The request {@link ListBlocklistsRequest}
591+
* @returns A Promise of ListBlocklistsResponse
592+
*/
593+
listBlocklists = (request: Readonly<ListBlocklistsRequest>) =>
594+
enrichForPagination('blocklists', this.pageOfListBlocklists, request)
595+
596+
/**
597+
* Bulk create blocklists. Create multiple blocklists in a specific Project or
598+
* Organization using the `region` parameter.
599+
*
600+
* @param request - The request {@link BulkCreateBlocklistsRequest}
601+
* @returns A Promise of BulkCreateBlocklistsResponse
602+
*/
603+
bulkCreateBlocklists = (request: Readonly<BulkCreateBlocklistsRequest>) =>
604+
this.client.fetch<BulkCreateBlocklistsResponse>(
605+
{
606+
body: JSON.stringify(
607+
marshalBulkCreateBlocklistsRequest(request, this.client.settings),
608+
),
609+
headers: jsonContentHeaders,
610+
method: 'POST',
611+
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/blocklists`,
612+
},
613+
unmarshalBulkCreateBlocklistsResponse,
614+
)
615+
616+
/**
617+
* Delete a blocklist. You must specify the blocklist you want to delete by
618+
* the `region` and `blocklist_id`.
619+
*
620+
* @param request - The request {@link DeleteBlocklistRequest}
621+
*/
622+
deleteBlocklist = (request: Readonly<DeleteBlocklistRequest>) =>
623+
this.client.fetch<void>({
624+
method: 'DELETE',
625+
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/blocklists/${validatePathParam('blocklistId', request.blocklistId)}`,
626+
})
557627
}

packages/clients/src/api/tem/v1alpha1/index.gen.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
export { API } from './api.gen'
44
export * from './content.gen'
55
export type {
6+
Blocklist,
7+
BlocklistType,
8+
BulkCreateBlocklistsRequest,
9+
BulkCreateBlocklistsResponse,
610
CancelEmailRequest,
711
CheckDomainRequest,
812
CreateDomainRequest,
@@ -12,6 +16,7 @@ export type {
1216
CreateEmailRequestHeader,
1317
CreateEmailResponse,
1418
CreateWebhookRequest,
19+
DeleteBlocklistRequest,
1520
DeleteWebhookRequest,
1621
Domain,
1722
DomainLastStatus,
@@ -38,6 +43,9 @@ export type {
3843
GetProjectSettingsRequest,
3944
GetStatisticsRequest,
4045
GetWebhookRequest,
46+
ListBlocklistsRequest,
47+
ListBlocklistsRequestOrderBy,
48+
ListBlocklistsResponse,
4149
ListDomainsRequest,
4250
ListDomainsResponse,
4351
ListEmailsRequest,

packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import {
77
} from '../../../bridge'
88
import type { DefaultValues } from '../../../bridge'
99
import type {
10+
Blocklist,
11+
BulkCreateBlocklistsRequest,
12+
BulkCreateBlocklistsResponse,
1013
CreateDomainRequest,
1114
CreateEmailRequest,
1215
CreateEmailRequestAddress,
@@ -26,6 +29,7 @@ import type {
2629
DomainStatistics,
2730
Email,
2831
EmailTry,
32+
ListBlocklistsResponse,
2933
ListDomainsResponse,
3034
ListEmailsResponse,
3135
ListWebhookEventsResponse,
@@ -190,6 +194,40 @@ export const unmarshalWebhook = (data: unknown): Webhook => {
190194
} as Webhook
191195
}
192196

197+
const unmarshalBlocklist = (data: unknown): Blocklist => {
198+
if (!isJSONObject(data)) {
199+
throw new TypeError(
200+
`Unmarshalling the type 'Blocklist' failed as data isn't a dictionary.`,
201+
)
202+
}
203+
204+
return {
205+
createdAt: unmarshalDate(data.created_at),
206+
custom: data.custom,
207+
domainId: data.domain_id,
208+
email: data.email,
209+
endsAt: unmarshalDate(data.ends_at),
210+
id: data.id,
211+
reason: data.reason,
212+
type: data.type,
213+
updatedAt: unmarshalDate(data.updated_at),
214+
} as Blocklist
215+
}
216+
217+
export const unmarshalBulkCreateBlocklistsResponse = (
218+
data: unknown,
219+
): BulkCreateBlocklistsResponse => {
220+
if (!isJSONObject(data)) {
221+
throw new TypeError(
222+
`Unmarshalling the type 'BulkCreateBlocklistsResponse' failed as data isn't a dictionary.`,
223+
)
224+
}
225+
226+
return {
227+
blocklists: unmarshalArrayOfObject(data.blocklists, unmarshalBlocklist),
228+
} as BulkCreateBlocklistsResponse
229+
}
230+
193231
export const unmarshalCreateEmailResponse = (
194232
data: unknown,
195233
): CreateEmailResponse => {
@@ -293,6 +331,21 @@ export const unmarshalDomainLastStatus = (data: unknown): DomainLastStatus => {
293331
} as DomainLastStatus
294332
}
295333

334+
export const unmarshalListBlocklistsResponse = (
335+
data: unknown,
336+
): ListBlocklistsResponse => {
337+
if (!isJSONObject(data)) {
338+
throw new TypeError(
339+
`Unmarshalling the type 'ListBlocklistsResponse' failed as data isn't a dictionary.`,
340+
)
341+
}
342+
343+
return {
344+
blocklists: unmarshalArrayOfObject(data.blocklists, unmarshalBlocklist),
345+
totalCount: data.total_count,
346+
} as ListBlocklistsResponse
347+
}
348+
296349
export const unmarshalListDomainsResponse = (
297350
data: unknown,
298351
): ListDomainsResponse => {
@@ -426,6 +479,16 @@ export const unmarshalStatistics = (data: unknown): Statistics => {
426479
} as Statistics
427480
}
428481

482+
export const marshalBulkCreateBlocklistsRequest = (
483+
request: BulkCreateBlocklistsRequest,
484+
defaults: DefaultValues,
485+
): Record<string, unknown> => ({
486+
domain_id: request.domainId,
487+
emails: request.emails,
488+
reason: request.reason,
489+
type: request.type,
490+
})
491+
429492
export const marshalCreateDomainRequest = (
430493
request: CreateDomainRequest,
431494
defaults: DefaultValues,

packages/clients/src/api/tem/v1alpha1/types.gen.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
// If you have any remark or suggestion do not hesitate to open an issue.
33
import type { Region } from '../../../bridge'
44

5+
export type BlocklistType =
6+
| 'unknown_type'
7+
| 'mailbox_full'
8+
| 'mailbox_not_found'
9+
510
export type DomainLastStatusAutoconfigStateReason =
611
| 'unknown_reason'
712
| 'permission_denied'
@@ -50,6 +55,12 @@ export type EmailStatus =
5055
| 'failed'
5156
| 'canceled'
5257

58+
export type ListBlocklistsRequestOrderBy =
59+
| 'created_at_desc'
60+
| 'created_at_asc'
61+
| 'ends_at_desc'
62+
| 'ends_at_asc'
63+
5364
export type ListEmailsRequestOrderBy =
5465
| 'created_at_desc'
5566
| 'created_at_asc'
@@ -146,6 +157,30 @@ export interface DomainStatistics {
146157
canceledCount: number
147158
}
148159

160+
export interface Blocklist {
161+
/** ID of the blocklist. */
162+
id: string
163+
/** Domain ID linked to the blocklist. */
164+
domainId: string
165+
/** Date and time of the blocklist creation. */
166+
createdAt?: Date
167+
/** Date and time of the blocklist's last update. */
168+
updatedAt?: Date
169+
/** Date and time when the blocklist ends. Empty if the blocklist has no end. */
170+
endsAt?: Date
171+
/** Email blocked by the blocklist. */
172+
email: string
173+
/** Type of block for this email. */
174+
type: BlocklistType
175+
/** Reason to block this email. */
176+
reason: string
177+
/**
178+
* True if this blocklist was created manually. False for an automatic
179+
* Transactional Email blocklist.
180+
*/
181+
custom: boolean
182+
}
183+
149184
export interface CreateEmailRequestAddress {
150185
/** Email address. */
151186
email: string
@@ -358,6 +393,27 @@ export interface UpdateProjectSettingsRequestUpdatePeriodicReport {
358393
sendingDay?: number
359394
}
360395

396+
export type BulkCreateBlocklistsRequest = {
397+
/**
398+
* Region to target. If none is passed will use default region from the
399+
* config.
400+
*/
401+
region?: Region
402+
/** Domain ID linked to the blocklist. */
403+
domainId: string
404+
/** Email blocked by the blocklist. */
405+
emails?: string[]
406+
/** Type of blocklist. */
407+
type?: BlocklistType
408+
/** Reason to block the email. */
409+
reason?: string
410+
}
411+
412+
export interface BulkCreateBlocklistsResponse {
413+
/** List of blocklist created. */
414+
blocklists: Blocklist[]
415+
}
416+
361417
export type CancelEmailRequest = {
362418
/**
363419
* Region to target. If none is passed will use default region from the
@@ -447,6 +503,16 @@ export type CreateWebhookRequest = {
447503
snsArn: string
448504
}
449505

506+
export type DeleteBlocklistRequest = {
507+
/**
508+
* Region to target. If none is passed will use default region from the
509+
* config.
510+
*/
511+
region?: Region
512+
/** ID of the blocklist to delete. */
513+
blocklistId: string
514+
}
515+
450516
export type DeleteWebhookRequest = {
451517
/**
452518
* Region to target. If none is passed will use default region from the
@@ -543,6 +609,38 @@ export type GetWebhookRequest = {
543609
webhookId: string
544610
}
545611

612+
export type ListBlocklistsRequest = {
613+
/**
614+
* Region to target. If none is passed will use default region from the
615+
* config.
616+
*/
617+
region?: Region
618+
/** (Optional) List blocklist corresponding to specific criteria. */
619+
orderBy?: ListBlocklistsRequestOrderBy
620+
/** (Optional) Requested page number. Value must be greater or equal to 1. */
621+
page?: number
622+
/** (Optional) Requested page size. Value must be between 1 and 100. */
623+
pageSize?: number
624+
/** (Optional) Filter by a domain ID. */
625+
domainId: string
626+
/** (Optional) Filter by an email address. */
627+
email?: string
628+
/** (Optional) Filter by a blocklist type. */
629+
type?: BlocklistType
630+
/**
631+
* (Optional) Filter by custom blocklist (true) or automatic Transactional
632+
* Email blocklist (false).
633+
*/
634+
custom?: boolean
635+
}
636+
637+
export interface ListBlocklistsResponse {
638+
/** Number of blocklists matching the requested criteria. */
639+
totalCount: number
640+
/** Single page of blocklists matching the requested criteria. */
641+
blocklists: Blocklist[]
642+
}
643+
546644
export type ListDomainsRequest = {
547645
/**
548646
* Region to target. If none is passed will use default region from the

0 commit comments

Comments
 (0)