| 10 | constructor(private runTask: ResendRunTask) {} |
| 11 | |
| 12 | send( |
| 13 | key: IntegrationTaskKey, |
| 14 | payload: Parameters<Resend["batch"]["send"]>[0], |
| 15 | options?: Parameters<Resend["batch"]["send"]>[1] |
| 16 | ): Promise<SendEmailResult> { |
| 17 | return this.runTask( |
| 18 | key, |
| 19 | async (client, task) => { |
| 20 | const { error, data } = await client.batch.send(payload, options); |
| 21 | |
| 22 | if (error) { |
| 23 | throw error; |
| 24 | } |
| 25 | |
| 26 | if (!data) { |
| 27 | throw new Error("No data returned from Resend"); |
| 28 | } |
| 29 | |
| 30 | return data; |
| 31 | }, |
| 32 | { |
| 33 | name: "Send Batch Email", |
| 34 | params: payload, |
| 35 | properties: [ |
| 36 | { |
| 37 | label: "Count", |
| 38 | text: String(payload.length), |
| 39 | }, |
| 40 | ], |
| 41 | retry: retry.standardBackoff, |
| 42 | }, |
| 43 | handleResendError |
| 44 | ); |
| 45 | } |
| 46 | |
| 47 | create( |
| 48 | key: IntegrationTaskKey, |