| 45 | } |
| 46 | |
| 47 | create( |
| 48 | key: IntegrationTaskKey, |
| 49 | payload: Parameters<Resend["batch"]["create"]>[0], |
| 50 | options?: Parameters<Resend["batch"]["create"]>[1] |
| 51 | ): Promise<CreateEmailResult> { |
| 52 | return this.runTask( |
| 53 | key, |
| 54 | async (client, task) => { |
| 55 | const { error, data } = await client.batch.create(payload, options); |
| 56 | |
| 57 | if (error) { |
| 58 | throw error; |
| 59 | } |
| 60 | |
| 61 | if (!data) { |
| 62 | throw new Error("No data returned from Resend"); |
| 63 | } |
| 64 | |
| 65 | return data; |
| 66 | }, |
| 67 | { |
| 68 | name: "Create Batch Email", |
| 69 | params: payload, |
| 70 | properties: [ |
| 71 | { |
| 72 | label: "Count", |
| 73 | text: String(payload.length), |
| 74 | }, |
| 75 | ], |
| 76 | retry: retry.standardBackoff, |
| 77 | }, |
| 78 | handleResendError |
| 79 | ); |
| 80 | } |
| 81 | } |