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
50 changes: 33 additions & 17 deletions packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,42 @@ import type {
CreateEmailRequestAttachment,
CreateEmailResponse,
Domain,
DomainStatistics,
Email,
EmailTry,
ListDomainsResponse,
ListEmailsResponse,
Statistics,
} from './types.gen'

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

return {
code: data.code,
message: data.message,
rank: data.rank,
triedAt: unmarshalDate(data.tried_at),
} as EmailTry
canceledCount: data.canceled_count,
failedCount: data.failed_count,
sentCount: data.sent_count,
totalCount: data.total_count,
} as DomainStatistics
}

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

return {
canceledCount: data.canceled_count,
failedCount: data.failed_count,
newCount: data.new_count,
sendingCount: data.sending_count,
sentCount: data.sent_count,
totalCount: data.total_count,
} as Statistics
code: data.code,
message: data.message,
rank: data.rank,
triedAt: unmarshalDate(data.tried_at),
} as EmailTry
}

export const unmarshalDomain = (data: unknown) => {
Expand All @@ -73,7 +72,7 @@ export const unmarshalDomain = (data: unknown) => {
revokedAt: unmarshalDate(data.revoked_at),
spfConfig: data.spf_config,
statistics: data.statistics
? unmarshalStatistics(data.statistics)
? unmarshalDomainStatistics(data.statistics)
: undefined,
status: data.status,
} as Domain
Expand Down Expand Up @@ -140,6 +139,23 @@ export const unmarshalListEmailsResponse = (data: unknown) => {
} as ListEmailsResponse
}

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

return {
canceledCount: data.canceled_count,
failedCount: data.failed_count,
newCount: data.new_count,
sendingCount: data.sending_count,
sentCount: data.sent_count,
totalCount: data.total_count,
} as Statistics
}

const marshalCreateEmailRequestAddress = (
request: CreateEmailRequestAddress,
defaults: DefaultValues,
Expand Down
9 changes: 8 additions & 1 deletion packages/clients/src/api/tem/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,17 @@ export interface Domain {
/** DKIM public key, as should be recorded in the DNS zone */
dkimConfig: string
/** Domain's statistics */
statistics?: Statistics
statistics?: DomainStatistics
region: Region
}

export interface DomainStatistics {
totalCount: number
sentCount: number
failedCount: number
canceledCount: number
}

/** Email */
export interface Email {
/** Technical ID of the email */
Expand Down