| 53 | } |
| 54 | |
| 55 | create( |
| 56 | key: IntegrationTaskKey, |
| 57 | payload: Parameters<Resend["emails"]["create"]>[0], |
| 58 | options?: Parameters<Resend["emails"]["create"]>[1] |
| 59 | ): Promise<CreateEmailResult> { |
| 60 | return this.runTask( |
| 61 | key, |
| 62 | async (client, task) => { |
| 63 | const { error, data } = await client.emails.create(payload, options); |
| 64 | |
| 65 | if (error) { |
| 66 | throw error; |
| 67 | } |
| 68 | |
| 69 | if (!data) { |
| 70 | throw new Error("No data returned from Resend"); |
| 71 | } |
| 72 | |
| 73 | return data; |
| 74 | }, |
| 75 | { |
| 76 | name: "Create Email", |
| 77 | params: payload, |
| 78 | properties: [ |
| 79 | { |
| 80 | label: "From", |
| 81 | text: payload.from, |
| 82 | }, |
| 83 | { |
| 84 | label: "To", |
| 85 | text: Array.isArray(payload.to) ? payload.to.join(", ") : payload.to, |
| 86 | }, |
| 87 | ...(payload.subject ? [{ label: "Subject", text: payload.subject }] : []), |
| 88 | ], |
| 89 | retry: retry.standardBackoff, |
| 90 | }, |
| 91 | handleResendError |
| 92 | ); |
| 93 | } |
| 94 | |
| 95 | get(key: IntegrationTaskKey, payload: string): Promise<GetEmailResult> { |
| 96 | return this.runTask( |