diff --git a/package.json b/package.json index 21a0f03e..5117f19e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "resend", - "version": "3.6.0-canary.0", + "version": "3.6.0-canary.2", "description": "Node.js library for the Resend API", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/src/emails/emails.ts b/src/emails/emails.ts index 831f9b1c..057b0a4b 100644 --- a/src/emails/emails.ts +++ b/src/emails/emails.ts @@ -15,6 +15,11 @@ import type { GetEmailResponse, GetEmailResponseSuccess, } from './interfaces/get-email-options.interface'; +import type { + UpdateEmailOptions, + UpdateEmailResponse, + UpdateEmailResponseSuccess, +} from './interfaces/update-email-options.interface'; export class Emails { constructor(private readonly resend: Resend) {} @@ -52,6 +57,16 @@ export class Emails { return data; } + async update(payload: UpdateEmailOptions): Promise { + const data = await this.resend.patch( + `/emails/${payload.id}`, + { + scheduled_at: payload.scheduledAt, + }, + ); + return data; + } + async cancel(id: string): Promise { const data = await this.resend.post( `/emails/${id}/cancel`, diff --git a/src/emails/interfaces/create-email-options.interface.ts b/src/emails/interfaces/create-email-options.interface.ts index 97fe8ba5..05e7641e 100644 --- a/src/emails/interfaces/create-email-options.interface.ts +++ b/src/emails/interfaces/create-email-options.interface.ts @@ -85,7 +85,7 @@ interface CreateEmailBaseOptions { * * @link https://resend.com/docs/api-reference/emails/send-email#body-parameters */ - scheduled_at: string; + scheduledAt: string; } export type CreateEmailOptions = RequireAtLeastOne & diff --git a/src/emails/interfaces/update-email-options.interface.ts b/src/emails/interfaces/update-email-options.interface.ts new file mode 100644 index 00000000..653c2a12 --- /dev/null +++ b/src/emails/interfaces/update-email-options.interface.ts @@ -0,0 +1,16 @@ +import type { ErrorResponse } from '../../interfaces'; + +export interface UpdateEmailOptions { + id: string; + scheduledAt: string; +} + +export interface UpdateEmailResponseSuccess { + id: string; + object: 'email'; +} + +export interface UpdateEmailResponse { + data: UpdateEmailResponseSuccess | null; + error: ErrorResponse | null; +}