Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ import {
EMAIL_TRANSIENT_STATUSES,
} from './content.gen'
import {
marshalBulkCreateBlocklistsRequest,
marshalCreateDomainRequest,
marshalCreateEmailRequest,
marshalCreateWebhookRequest,
marshalUpdateDomainRequest,
marshalUpdateProjectSettingsRequest,
marshalUpdateWebhookRequest,
unmarshalBulkCreateBlocklistsResponse,
unmarshalCreateEmailResponse,
unmarshalDomain,
unmarshalDomainLastStatus,
unmarshalEmail,
unmarshalListBlocklistsResponse,
unmarshalListDomainsResponse,
unmarshalListEmailsResponse,
unmarshalListWebhookEventsResponse,
Expand All @@ -32,12 +35,15 @@ import {
unmarshalWebhook,
} from './marshalling.gen'
import type {
BulkCreateBlocklistsRequest,
BulkCreateBlocklistsResponse,
CancelEmailRequest,
CheckDomainRequest,
CreateDomainRequest,
CreateEmailRequest,
CreateEmailResponse,
CreateWebhookRequest,
DeleteBlocklistRequest,
DeleteWebhookRequest,
Domain,
DomainLastStatus,
Expand All @@ -48,6 +54,8 @@ import type {
GetProjectSettingsRequest,
GetStatisticsRequest,
GetWebhookRequest,
ListBlocklistsRequest,
ListBlocklistsResponse,
ListDomainsRequest,
ListDomainsResponse,
ListEmailsRequest,
Expand Down Expand Up @@ -554,4 +562,66 @@ export class API extends ParentAPI {
},
unmarshalProjectSettings,
)

protected pageOfListBlocklists = (request: Readonly<ListBlocklistsRequest>) =>
this.client.fetch<ListBlocklistsResponse>(
{
method: 'GET',
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/blocklists`,
urlParams: urlParams(
['custom', request.custom],
['domain_id', request.domainId],
['email', request.email],
['order_by', request.orderBy],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
['type', request.type],
),
},
unmarshalListBlocklistsResponse,
)

/**
* List blocklists. Retrieve the list of blocklists.
*
* @param request - The request {@link ListBlocklistsRequest}
* @returns A Promise of ListBlocklistsResponse
*/
listBlocklists = (request: Readonly<ListBlocklistsRequest>) =>
enrichForPagination('blocklists', this.pageOfListBlocklists, request)

/**
* Bulk create blocklists. Create multiple blocklists in a specific Project or
* Organization using the `region` parameter.
*
* @param request - The request {@link BulkCreateBlocklistsRequest}
* @returns A Promise of BulkCreateBlocklistsResponse
*/
bulkCreateBlocklists = (request: Readonly<BulkCreateBlocklistsRequest>) =>
this.client.fetch<BulkCreateBlocklistsResponse>(
{
body: JSON.stringify(
marshalBulkCreateBlocklistsRequest(request, this.client.settings),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/blocklists`,
},
unmarshalBulkCreateBlocklistsResponse,
)

/**
* Delete a blocklist. You must specify the blocklist you want to delete by
* the `region` and `blocklist_id`.
*
* @param request - The request {@link DeleteBlocklistRequest}
*/
deleteBlocklist = (request: Readonly<DeleteBlocklistRequest>) =>
this.client.fetch<void>({
method: 'DELETE',
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/blocklists/${validatePathParam('blocklistId', request.blocklistId)}`,
})
}
8 changes: 8 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
export { API } from './api.gen'
export * from './content.gen'
export type {
Blocklist,
BlocklistType,
BulkCreateBlocklistsRequest,
BulkCreateBlocklistsResponse,
CancelEmailRequest,
CheckDomainRequest,
CreateDomainRequest,
Expand All @@ -12,6 +16,7 @@ export type {
CreateEmailRequestHeader,
CreateEmailResponse,
CreateWebhookRequest,
DeleteBlocklistRequest,
DeleteWebhookRequest,
Domain,
DomainLastStatus,
Expand All @@ -38,6 +43,9 @@ export type {
GetProjectSettingsRequest,
GetStatisticsRequest,
GetWebhookRequest,
ListBlocklistsRequest,
ListBlocklistsRequestOrderBy,
ListBlocklistsResponse,
ListDomainsRequest,
ListDomainsResponse,
ListEmailsRequest,
Expand Down
63 changes: 63 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
} from '../../../bridge'
import type { DefaultValues } from '../../../bridge'
import type {
Blocklist,
BulkCreateBlocklistsRequest,
BulkCreateBlocklistsResponse,
CreateDomainRequest,
CreateEmailRequest,
CreateEmailRequestAddress,
Expand All @@ -26,6 +29,7 @@ import type {
DomainStatistics,
Email,
EmailTry,
ListBlocklistsResponse,
ListDomainsResponse,
ListEmailsResponse,
ListWebhookEventsResponse,
Expand Down Expand Up @@ -190,6 +194,40 @@ export const unmarshalWebhook = (data: unknown): Webhook => {
} as Webhook
}

const unmarshalBlocklist = (data: unknown): Blocklist => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'Blocklist' failed as data isn't a dictionary.`,
)
}

return {
createdAt: unmarshalDate(data.created_at),
custom: data.custom,
domainId: data.domain_id,
email: data.email,
endsAt: unmarshalDate(data.ends_at),
id: data.id,
reason: data.reason,
type: data.type,
updatedAt: unmarshalDate(data.updated_at),
} as Blocklist
}

export const unmarshalBulkCreateBlocklistsResponse = (
data: unknown,
): BulkCreateBlocklistsResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'BulkCreateBlocklistsResponse' failed as data isn't a dictionary.`,
)
}

return {
blocklists: unmarshalArrayOfObject(data.blocklists, unmarshalBlocklist),
} as BulkCreateBlocklistsResponse
}

export const unmarshalCreateEmailResponse = (
data: unknown,
): CreateEmailResponse => {
Expand Down Expand Up @@ -293,6 +331,21 @@ export const unmarshalDomainLastStatus = (data: unknown): DomainLastStatus => {
} as DomainLastStatus
}

export const unmarshalListBlocklistsResponse = (
data: unknown,
): ListBlocklistsResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ListBlocklistsResponse' failed as data isn't a dictionary.`,
)
}

return {
blocklists: unmarshalArrayOfObject(data.blocklists, unmarshalBlocklist),
totalCount: data.total_count,
} as ListBlocklistsResponse
}

export const unmarshalListDomainsResponse = (
data: unknown,
): ListDomainsResponse => {
Expand Down Expand Up @@ -426,6 +479,16 @@ export const unmarshalStatistics = (data: unknown): Statistics => {
} as Statistics
}

export const marshalBulkCreateBlocklistsRequest = (
request: BulkCreateBlocklistsRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
domain_id: request.domainId,
emails: request.emails,
reason: request.reason,
type: request.type,
})

export const marshalCreateDomainRequest = (
request: CreateDomainRequest,
defaults: DefaultValues,
Expand Down
98 changes: 98 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// If you have any remark or suggestion do not hesitate to open an issue.
import type { Region } from '../../../bridge'

export type BlocklistType =
| 'unknown_type'
| 'mailbox_full'
| 'mailbox_not_found'

export type DomainLastStatusAutoconfigStateReason =
| 'unknown_reason'
| 'permission_denied'
Expand Down Expand Up @@ -50,6 +55,12 @@ export type EmailStatus =
| 'failed'
| 'canceled'

export type ListBlocklistsRequestOrderBy =
| 'created_at_desc'
| 'created_at_asc'
| 'ends_at_desc'
| 'ends_at_asc'

export type ListEmailsRequestOrderBy =
| 'created_at_desc'
| 'created_at_asc'
Expand Down Expand Up @@ -146,6 +157,30 @@ export interface DomainStatistics {
canceledCount: number
}

export interface Blocklist {
/** ID of the blocklist. */
id: string
/** Domain ID linked to the blocklist. */
domainId: string
/** Date and time of the blocklist creation. */
createdAt?: Date
/** Date and time of the blocklist's last update. */
updatedAt?: Date
/** Date and time when the blocklist ends. Empty if the blocklist has no end. */
endsAt?: Date
/** Email blocked by the blocklist. */
email: string
/** Type of block for this email. */
type: BlocklistType
/** Reason to block this email. */
reason: string
/**
* True if this blocklist was created manually. False for an automatic
* Transactional Email blocklist.
*/
custom: boolean
}

export interface CreateEmailRequestAddress {
/** Email address. */
email: string
Expand Down Expand Up @@ -358,6 +393,27 @@ export interface UpdateProjectSettingsRequestUpdatePeriodicReport {
sendingDay?: number
}

export type BulkCreateBlocklistsRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** Domain ID linked to the blocklist. */
domainId: string
/** Email blocked by the blocklist. */
emails?: string[]
/** Type of blocklist. */
type?: BlocklistType
/** Reason to block the email. */
reason?: string
}

export interface BulkCreateBlocklistsResponse {
/** List of blocklist created. */
blocklists: Blocklist[]
}

export type CancelEmailRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down Expand Up @@ -447,6 +503,16 @@ export type CreateWebhookRequest = {
snsArn: string
}

export type DeleteBlocklistRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** ID of the blocklist to delete. */
blocklistId: string
}

export type DeleteWebhookRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down Expand Up @@ -543,6 +609,38 @@ export type GetWebhookRequest = {
webhookId: string
}

export type ListBlocklistsRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** (Optional) List blocklist corresponding to specific criteria. */
orderBy?: ListBlocklistsRequestOrderBy
/** (Optional) Requested page number. Value must be greater or equal to 1. */
page?: number
/** (Optional) Requested page size. Value must be between 1 and 100. */
pageSize?: number
/** (Optional) Filter by a domain ID. */
domainId: string
/** (Optional) Filter by an email address. */
email?: string
/** (Optional) Filter by a blocklist type. */
type?: BlocklistType
/**
* (Optional) Filter by custom blocklist (true) or automatic Transactional
* Email blocklist (false).
*/
custom?: boolean
}

export interface ListBlocklistsResponse {
/** Number of blocklists matching the requested criteria. */
totalCount: number
/** Single page of blocklists matching the requested criteria. */
blocklists: Blocklist[]
}

export type ListDomainsRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down
Loading
Loading