Skip to content

Commit

Permalink
feat(tem): improve listEmails endpoint (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored May 17, 2023
1 parent 517ee40 commit 72bfef4
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 19 deletions.
12 changes: 11 additions & 1 deletion packages/clients/src/api/tem/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ export class API extends ParentAPI {
urlParams: urlParams(
['domain_id', request.domainId],
['mail_from', request.mailFrom],
['mail_rcpt', request.mailRcpt],
['mail_to', request.mailTo],
['message_id', request.messageId],
['order_by', request.orderBy ?? 'created_at_desc'],
['page', request.page],
[
'page_size',
Expand All @@ -144,7 +146,15 @@ export class API extends ParentAPI {

/**
* List emails. Retrieve the list of emails sent from a specific domain or for
* a specific Project or Organization. You must specify the `region`.
* a specific Project or Organization. You must specify the `region`. You can
* filter your emails in ascending or descending order using:
*
* - Created_at
* - Updated_at
* - Status
* - Mail_from
* - Mail_rcpt
* - Subject
*
* @param request - The request {@link ListEmailsRequest}
* @returns A Promise of ListEmailsResponse
Expand Down
1 change: 1 addition & 0 deletions packages/clients/src/api/tem/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type {
ListDomainsRequest,
ListDomainsResponse,
ListEmailsRequest,
ListEmailsRequestOrderBy,
ListEmailsResponse,
RevokeDomainRequest,
Statistics,
Expand Down
1 change: 1 addition & 0 deletions packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const unmarshalEmail = (data: unknown) => {
id: data.id,
lastTries: unmarshalArrayOfObject(data.last_tries, unmarshalEmailTry),
mailFrom: data.mail_from,
mailRcpt: data.mail_rcpt,
messageId: data.message_id,
projectId: data.project_id,
rcptTo: data.rcpt_to,
Expand Down
69 changes: 51 additions & 18 deletions packages/clients/src/api/tem/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ export type EmailStatus =
| 'failed'
| 'canceled'

export type ListEmailsRequestOrderBy =
| 'created_at_desc'
| 'created_at_asc'
| 'updated_at_desc'
| 'updated_at_asc'
| 'status_desc'
| 'status_asc'
| 'mail_from_desc'
| 'mail_from_asc'
| 'mail_rcpt_desc'
| 'mail_rcpt_asc'
| 'subject_desc'
| 'subject_asc'

/** Create email request. address. */
export interface CreateEmailRequestAddress {
/** Email address. */
Expand Down Expand Up @@ -93,8 +107,10 @@ export interface Email {
projectId: string
/** Email address of the sender. */
mailFrom: string
/** @deprecated (Deprecated) Email address of the recipient. */
rcptTo?: string
/** Email address of the recipient. */
rcptTo: string
mailRcpt: string
/** Type of recipient. */
rcptType: EmailRcptType
/** Subject of the email. */
Expand Down Expand Up @@ -140,7 +156,7 @@ export interface ListDomainsResponse {

/** List emails response. */
export interface ListEmailsResponse {
/** Count of all emails matching the requested criteria. */
/** Number of emails matching the requested criteria. */
totalCount: number
/** Single page of emails matching the requested criteria. */
emails: Email[]
Expand Down Expand Up @@ -223,24 +239,41 @@ export type ListEmailsRequest = {
region?: Region
page?: number
pageSize?: number
/** ID of the Project in which to list the emails (optional). */
/** (Optional) ID of the Project in which to list the emails. */
projectId?: string
/** ID of the domain for which to list the emails (optional). */
/** (Optional) ID of the domain for which to list the emails. */
domainId?: string
/** ID of the message for which to list the emails (optional). */
/** (Optional) ID of the message for which to list the emails. */
messageId?: string
/** Subject of the email. */
subject?: string
/** List emails created after this date (optional). */
/** (Optional) List emails created after this date. */
since?: Date
/** List emails created before this date (optional). */
/** (Optional) List emails created before this date. */
until?: Date
/** List emails sent with this `mail_from` sender's address (optional). */
/** (Optional) List emails sent with this sender's email address. */
mailFrom?: string
/** List emails sent with this `mail_to` recipient's address (optional). */
/**
* @deprecated (Deprecated) List emails sent to this recipient's email
* address.
*/
mailTo?: string
/** List emails having any of this status (optional). */
/** (Optional) List emails sent to this recipient's email address. */
mailRcpt?: string
/** (Optional) List emails with any of these statuses. */
statuses?: EmailStatus[]
/** (Optional) List emails with this subject. */
subject?: string
/**
* (Optional) List emails corresponding to specific criteria. You can filter
* your emails in ascending or descending order using:
*
* - Created_at
* - Updated_at
* - Status
* - Mail_from
* - Mail_rcpt
* - Subject.
*/
orderBy?: ListEmailsRequestOrderBy
}

export type GetStatisticsRequest = {
Expand All @@ -249,18 +282,18 @@ export type GetStatisticsRequest = {
* config.
*/
region?: Region
/** Number of emails for this Project (optional). */
/** (Optional) Number of emails for this Project. */
projectId?: string
/**
* Number of emails sent from this domain (must be coherent with the
* `project_id` and the `organization_id`) (optional).
* (Optional) Number of emails sent from this domain (must be coherent with
* the `project_id` and the `organization_id`).
*/
domainId?: string
/** Number of emails created after this date (optional). */
/** (Optional) Number of emails created after this date. */
since?: Date
/** Number of emails created before this date (optional). */
/** (Optional) Number of emails created before this date. */
until?: Date
/** Number of emails sent with this `mail_from` sender's address (optional). */
/** (Optional) Number of emails sent with this sender's email address. */
mailFrom?: string
}

Expand Down

0 comments on commit 72bfef4

Please sign in to comment.