Skip to content

Commit 72bfef4

Browse files
authored
feat(tem): improve listEmails endpoint (#666)
1 parent 517ee40 commit 72bfef4

File tree

4 files changed

+64
-19
lines changed

4 files changed

+64
-19
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ export class API extends ParentAPI {
125125
urlParams: urlParams(
126126
['domain_id', request.domainId],
127127
['mail_from', request.mailFrom],
128+
['mail_rcpt', request.mailRcpt],
128129
['mail_to', request.mailTo],
129130
['message_id', request.messageId],
131+
['order_by', request.orderBy ?? 'created_at_desc'],
130132
['page', request.page],
131133
[
132134
'page_size',
@@ -144,7 +146,15 @@ export class API extends ParentAPI {
144146

145147
/**
146148
* List emails. Retrieve the list of emails sent from a specific domain or for
147-
* a specific Project or Organization. You must specify the `region`.
149+
* a specific Project or Organization. You must specify the `region`. You can
150+
* filter your emails in ascending or descending order using:
151+
*
152+
* - Created_at
153+
* - Updated_at
154+
* - Status
155+
* - Mail_from
156+
* - Mail_rcpt
157+
* - Subject
148158
*
149159
* @param request - The request {@link ListEmailsRequest}
150160
* @returns A Promise of ListEmailsResponse

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type {
2323
ListDomainsRequest,
2424
ListDomainsResponse,
2525
ListEmailsRequest,
26+
ListEmailsRequestOrderBy,
2627
ListEmailsResponse,
2728
RevokeDomainRequest,
2829
Statistics,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const unmarshalEmail = (data: unknown) => {
9090
id: data.id,
9191
lastTries: unmarshalArrayOfObject(data.last_tries, unmarshalEmailTry),
9292
mailFrom: data.mail_from,
93+
mailRcpt: data.mail_rcpt,
9394
messageId: data.message_id,
9495
projectId: data.project_id,
9596
rcptTo: data.rcpt_to,

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

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ export type EmailStatus =
2121
| 'failed'
2222
| 'canceled'
2323

24+
export type ListEmailsRequestOrderBy =
25+
| 'created_at_desc'
26+
| 'created_at_asc'
27+
| 'updated_at_desc'
28+
| 'updated_at_asc'
29+
| 'status_desc'
30+
| 'status_asc'
31+
| 'mail_from_desc'
32+
| 'mail_from_asc'
33+
| 'mail_rcpt_desc'
34+
| 'mail_rcpt_asc'
35+
| 'subject_desc'
36+
| 'subject_asc'
37+
2438
/** Create email request. address. */
2539
export interface CreateEmailRequestAddress {
2640
/** Email address. */
@@ -93,8 +107,10 @@ export interface Email {
93107
projectId: string
94108
/** Email address of the sender. */
95109
mailFrom: string
110+
/** @deprecated (Deprecated) Email address of the recipient. */
111+
rcptTo?: string
96112
/** Email address of the recipient. */
97-
rcptTo: string
113+
mailRcpt: string
98114
/** Type of recipient. */
99115
rcptType: EmailRcptType
100116
/** Subject of the email. */
@@ -140,7 +156,7 @@ export interface ListDomainsResponse {
140156

141157
/** List emails response. */
142158
export interface ListEmailsResponse {
143-
/** Count of all emails matching the requested criteria. */
159+
/** Number of emails matching the requested criteria. */
144160
totalCount: number
145161
/** Single page of emails matching the requested criteria. */
146162
emails: Email[]
@@ -223,24 +239,41 @@ export type ListEmailsRequest = {
223239
region?: Region
224240
page?: number
225241
pageSize?: number
226-
/** ID of the Project in which to list the emails (optional). */
242+
/** (Optional) ID of the Project in which to list the emails. */
227243
projectId?: string
228-
/** ID of the domain for which to list the emails (optional). */
244+
/** (Optional) ID of the domain for which to list the emails. */
229245
domainId?: string
230-
/** ID of the message for which to list the emails (optional). */
246+
/** (Optional) ID of the message for which to list the emails. */
231247
messageId?: string
232-
/** Subject of the email. */
233-
subject?: string
234-
/** List emails created after this date (optional). */
248+
/** (Optional) List emails created after this date. */
235249
since?: Date
236-
/** List emails created before this date (optional). */
250+
/** (Optional) List emails created before this date. */
237251
until?: Date
238-
/** List emails sent with this `mail_from` sender's address (optional). */
252+
/** (Optional) List emails sent with this sender's email address. */
239253
mailFrom?: string
240-
/** List emails sent with this `mail_to` recipient's address (optional). */
254+
/**
255+
* @deprecated (Deprecated) List emails sent to this recipient's email
256+
* address.
257+
*/
241258
mailTo?: string
242-
/** List emails having any of this status (optional). */
259+
/** (Optional) List emails sent to this recipient's email address. */
260+
mailRcpt?: string
261+
/** (Optional) List emails with any of these statuses. */
243262
statuses?: EmailStatus[]
263+
/** (Optional) List emails with this subject. */
264+
subject?: string
265+
/**
266+
* (Optional) List emails corresponding to specific criteria. You can filter
267+
* your emails in ascending or descending order using:
268+
*
269+
* - Created_at
270+
* - Updated_at
271+
* - Status
272+
* - Mail_from
273+
* - Mail_rcpt
274+
* - Subject.
275+
*/
276+
orderBy?: ListEmailsRequestOrderBy
244277
}
245278

246279
export type GetStatisticsRequest = {
@@ -249,18 +282,18 @@ export type GetStatisticsRequest = {
249282
* config.
250283
*/
251284
region?: Region
252-
/** Number of emails for this Project (optional). */
285+
/** (Optional) Number of emails for this Project. */
253286
projectId?: string
254287
/**
255-
* Number of emails sent from this domain (must be coherent with the
256-
* `project_id` and the `organization_id`) (optional).
288+
* (Optional) Number of emails sent from this domain (must be coherent with
289+
* the `project_id` and the `organization_id`).
257290
*/
258291
domainId?: string
259-
/** Number of emails created after this date (optional). */
292+
/** (Optional) Number of emails created after this date. */
260293
since?: Date
261-
/** Number of emails created before this date (optional). */
294+
/** (Optional) Number of emails created before this date. */
262295
until?: Date
263-
/** Number of emails sent with this `mail_from` sender's address (optional). */
296+
/** (Optional) Number of emails sent with this sender's email address. */
264297
mailFrom?: string
265298
}
266299

0 commit comments

Comments
 (0)