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
43 changes: 43 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
marshalCreateEmailRequest,
marshalCreateWebhookRequest,
marshalUpdateDomainRequest,
marshalUpdateProjectSettingsRequest,
marshalUpdateWebhookRequest,
unmarshalCreateEmailResponse,
unmarshalDomain,
Expand All @@ -26,6 +27,7 @@ import {
unmarshalListEmailsResponse,
unmarshalListWebhookEventsResponse,
unmarshalListWebhooksResponse,
unmarshalProjectSettings,
unmarshalStatistics,
unmarshalWebhook,
} from './marshalling.gen'
Expand All @@ -43,6 +45,7 @@ import type {
GetDomainLastStatusRequest,
GetDomainRequest,
GetEmailRequest,
GetProjectSettingsRequest,
GetStatisticsRequest,
GetWebhookRequest,
ListDomainsRequest,
Expand All @@ -53,9 +56,11 @@ import type {
ListWebhookEventsResponse,
ListWebhooksRequest,
ListWebhooksResponse,
ProjectSettings,
RevokeDomainRequest,
Statistics,
UpdateDomainRequest,
UpdateProjectSettingsRequest,
UpdateWebhookRequest,
Webhook,
} from './types.gen'
Expand Down Expand Up @@ -511,4 +516,42 @@ export class API extends ParentAPI {
*/
listWebhookEvents = (request: Readonly<ListWebhookEventsRequest>) =>
enrichForPagination('webhookEvents', this.pageOfListWebhookEvents, request)

/**
* List project settings. Retrieve the project settings including periodic
* reports.
*
* @param request - The request {@link GetProjectSettingsRequest}
* @returns A Promise of ProjectSettings
*/
getProjectSettings = (request: Readonly<GetProjectSettingsRequest> = {}) =>
this.client.fetch<ProjectSettings>(
{
method: 'GET',
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/project/${validatePathParam('projectId', request.projectId ?? this.client.settings.defaultProjectId)}/settings`,
},
unmarshalProjectSettings,
)

/**
* Update project settings. Update the project settings including periodic
* reports.
*
* @param request - The request {@link UpdateProjectSettingsRequest}
* @returns A Promise of ProjectSettings
*/
updateProjectSettings = (
request: Readonly<UpdateProjectSettingsRequest> = {},
) =>
this.client.fetch<ProjectSettings>(
{
body: JSON.stringify(
marshalUpdateProjectSettingsRequest(request, this.client.settings),
),
headers: jsonContentHeaders,
method: 'PATCH',
path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/project/${validatePathParam('projectId', request.projectId ?? this.client.settings.defaultProjectId)}/settings`,
},
unmarshalProjectSettings,
)
}
6 changes: 6 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type {
GetDomainLastStatusRequest,
GetDomainRequest,
GetEmailRequest,
GetProjectSettingsRequest,
GetStatisticsRequest,
GetWebhookRequest,
ListDomainsRequest,
Expand All @@ -46,9 +47,14 @@ export type {
ListWebhooksRequest,
ListWebhooksRequestOrderBy,
ListWebhooksResponse,
ProjectSettings,
ProjectSettingsPeriodicReport,
ProjectSettingsPeriodicReportFrequency,
RevokeDomainRequest,
Statistics,
UpdateDomainRequest,
UpdateProjectSettingsRequest,
UpdateProjectSettingsRequestUpdatePeriodicReport,
UpdateWebhookRequest,
Webhook,
WebhookEvent,
Expand Down
58 changes: 58 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ import type {
ListEmailsResponse,
ListWebhookEventsResponse,
ListWebhooksResponse,
ProjectSettings,
ProjectSettingsPeriodicReport,
Statistics,
UpdateDomainRequest,
UpdateProjectSettingsRequest,
UpdateProjectSettingsRequestUpdatePeriodicReport,
UpdateWebhookRequest,
Webhook,
WebhookEvent,
Expand Down Expand Up @@ -354,6 +358,37 @@ export const unmarshalListWebhooksResponse = (
} as ListWebhooksResponse
}

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

return {
enabled: data.enabled,
frequency: data.frequency,
sendingDay: data.sending_day,
sendingHour: data.sending_hour,
} as ProjectSettingsPeriodicReport
}

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

return {
periodicReport: data.periodic_report
? unmarshalProjectSettingsPeriodicReport(data.periodic_report)
: undefined,
} as ProjectSettings
}

export const unmarshalStatistics = (data: unknown): Statistics => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -461,6 +496,29 @@ export const marshalUpdateDomainRequest = (
autoconfig: request.autoconfig,
})

const marshalUpdateProjectSettingsRequestUpdatePeriodicReport = (
request: UpdateProjectSettingsRequestUpdatePeriodicReport,
defaults: DefaultValues,
): Record<string, unknown> => ({
enabled: request.enabled,
frequency: request.frequency,
sending_day: request.sendingDay,
sending_hour: request.sendingHour,
})

export const marshalUpdateProjectSettingsRequest = (
request: UpdateProjectSettingsRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
periodic_report:
request.periodicReport !== undefined
? marshalUpdateProjectSettingsRequestUpdatePeriodicReport(
request.periodicReport,
defaults,
)
: undefined,
})

export const marshalUpdateWebhookRequest = (
request: UpdateWebhookRequest,
defaults: DefaultValues,
Expand Down
61 changes: 61 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ export type ListWebhookEventsRequestOrderBy =

export type ListWebhooksRequestOrderBy = 'created_at_desc' | 'created_at_asc'

export type ProjectSettingsPeriodicReportFrequency =
| 'unknown_frequency'
| 'monthly'
| 'weekly'
| 'daily'

export type WebhookEventStatus =
| 'unknown_status'
| 'sending'
Expand Down Expand Up @@ -308,6 +314,34 @@ export interface Webhook {
updatedAt?: Date
}

export interface ProjectSettingsPeriodicReport {
/** Enable or disable periodic report notifications. */
enabled: boolean
/** At which frequency you receive periodic report notifications. */
frequency: ProjectSettingsPeriodicReportFrequency
/** At which hour you receive periodic report notifications. */
sendingHour: number
/**
* On which day you receive periodic report notifications (1-7 weekly, 1-28
* monthly).
*/
sendingDay: number
}

export interface UpdateProjectSettingsRequestUpdatePeriodicReport {
/** (Optional) Enable or disable periodic report notifications. */
enabled?: boolean
/** (Optional) At which frequency you receive periodic report notifications. */
frequency?: ProjectSettingsPeriodicReportFrequency
/** (Optional) At which hour you receive periodic report notifications. */
sendingHour?: number
/**
* (Optional) On which day you receive periodic report notifications (1-7
* weekly, 1-28 monthly).
*/
sendingDay?: number
}

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

export type GetProjectSettingsRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** ID of the project. */
projectId?: string
}

export type GetStatisticsRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down Expand Up @@ -613,6 +657,11 @@ export interface ListWebhooksResponse {
webhooks: Webhook[]
}

export interface ProjectSettings {
/** Information about your periodic report. */
periodicReport?: ProjectSettingsPeriodicReport
}

export type RevokeDomainRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down Expand Up @@ -668,6 +717,18 @@ export type UpdateDomainRequest = {
autoconfig?: boolean
}

export type UpdateProjectSettingsRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** ID of the project. */
projectId?: string
/** Periodic report update details - all fields are optional. */
periodicReport?: UpdateProjectSettingsRequestUpdatePeriodicReport
}

export type UpdateWebhookRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down
11 changes: 11 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/validation-rules.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ export const ListWebhooksRequest = {
},
}

export const UpdateProjectSettingsRequestUpdatePeriodicReport = {
sendingDay: {
greaterThanOrEqual: 1,
lessThanOrEqual: 28,
},
sendingHour: {
greaterThanOrEqual: 0,
lessThanOrEqual: 23,
},
}

export const UpdateWebhookRequest = {
name: {
maxLength: 127,
Expand Down