Skip to content

Commit 670225d

Browse files
authored
feat(tem): change domain statistics (#268)
1 parent 24ce7cd commit 670225d

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

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

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,42 @@ import type {
1313
CreateEmailRequestAttachment,
1414
CreateEmailResponse,
1515
Domain,
16+
DomainStatistics,
1617
Email,
1718
EmailTry,
1819
ListDomainsResponse,
1920
ListEmailsResponse,
2021
Statistics,
2122
} from './types.gen'
2223

23-
const unmarshalEmailTry = (data: unknown) => {
24+
const unmarshalDomainStatistics = (data: unknown) => {
2425
if (!isJSONObject(data)) {
2526
throw new TypeError(
26-
`Unmarshalling the type 'EmailTry' failed as data isn't a dictionary.`,
27+
`Unmarshalling the type 'DomainStatistics' failed as data isn't a dictionary.`,
2728
)
2829
}
2930

3031
return {
31-
code: data.code,
32-
message: data.message,
33-
rank: data.rank,
34-
triedAt: unmarshalDate(data.tried_at),
35-
} as EmailTry
32+
canceledCount: data.canceled_count,
33+
failedCount: data.failed_count,
34+
sentCount: data.sent_count,
35+
totalCount: data.total_count,
36+
} as DomainStatistics
3637
}
3738

38-
export const unmarshalStatistics = (data: unknown) => {
39+
const unmarshalEmailTry = (data: unknown) => {
3940
if (!isJSONObject(data)) {
4041
throw new TypeError(
41-
`Unmarshalling the type 'Statistics' failed as data isn't a dictionary.`,
42+
`Unmarshalling the type 'EmailTry' failed as data isn't a dictionary.`,
4243
)
4344
}
4445

4546
return {
46-
canceledCount: data.canceled_count,
47-
failedCount: data.failed_count,
48-
newCount: data.new_count,
49-
sendingCount: data.sending_count,
50-
sentCount: data.sent_count,
51-
totalCount: data.total_count,
52-
} as Statistics
47+
code: data.code,
48+
message: data.message,
49+
rank: data.rank,
50+
triedAt: unmarshalDate(data.tried_at),
51+
} as EmailTry
5352
}
5453

5554
export const unmarshalDomain = (data: unknown) => {
@@ -73,7 +72,7 @@ export const unmarshalDomain = (data: unknown) => {
7372
revokedAt: unmarshalDate(data.revoked_at),
7473
spfConfig: data.spf_config,
7574
statistics: data.statistics
76-
? unmarshalStatistics(data.statistics)
75+
? unmarshalDomainStatistics(data.statistics)
7776
: undefined,
7877
status: data.status,
7978
} as Domain
@@ -140,6 +139,23 @@ export const unmarshalListEmailsResponse = (data: unknown) => {
140139
} as ListEmailsResponse
141140
}
142141

142+
export const unmarshalStatistics = (data: unknown) => {
143+
if (!isJSONObject(data)) {
144+
throw new TypeError(
145+
`Unmarshalling the type 'Statistics' failed as data isn't a dictionary.`,
146+
)
147+
}
148+
149+
return {
150+
canceledCount: data.canceled_count,
151+
failedCount: data.failed_count,
152+
newCount: data.new_count,
153+
sendingCount: data.sending_count,
154+
sentCount: data.sent_count,
155+
totalCount: data.total_count,
156+
} as Statistics
157+
}
158+
143159
const marshalCreateEmailRequestAddress = (
144160
request: CreateEmailRequestAddress,
145161
defaults: DefaultValues,

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,17 @@ export interface Domain {
7575
/** DKIM public key, as should be recorded in the DNS zone */
7676
dkimConfig: string
7777
/** Domain's statistics */
78-
statistics?: Statistics
78+
statistics?: DomainStatistics
7979
region: Region
8080
}
8181

82+
export interface DomainStatistics {
83+
totalCount: number
84+
sentCount: number
85+
failedCount: number
86+
canceledCount: number
87+
}
88+
8289
/** Email */
8390
export interface Email {
8491
/** Technical ID of the email */

0 commit comments

Comments
 (0)