| 13 | constructor(private runTask: ResendRunTask) {} |
| 14 | |
| 15 | create( |
| 16 | key: IntegrationTaskKey, |
| 17 | payload: Parameters<Resend["contacts"]["create"]>[0], |
| 18 | options?: Parameters<Resend["contacts"]["create"]>[1] |
| 19 | ): Promise<CreateContactResult> { |
| 20 | return this.runTask( |
| 21 | key, |
| 22 | async (client, task) => { |
| 23 | const { error, data } = await client.contacts.create(payload, options); |
| 24 | |
| 25 | if (error) { |
| 26 | throw error; |
| 27 | } |
| 28 | |
| 29 | if (!data) { |
| 30 | throw new Error("No data returned from Resend"); |
| 31 | } |
| 32 | |
| 33 | return data; |
| 34 | }, |
| 35 | { |
| 36 | name: "Create Contact", |
| 37 | params: payload, |
| 38 | properties: [ |
| 39 | { |
| 40 | label: "Email", |
| 41 | text: payload.email, |
| 42 | }, |
| 43 | ...(payload.first_name && payload.last_name |
| 44 | ? [{ label: "Name", text: payload.first_name + " " + payload.last_name }] |
| 45 | : []), |
| 46 | ], |
| 47 | retry: retry.standardBackoff, |
| 48 | }, |
| 49 | handleResendError |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | get( |
| 54 | key: IntegrationTaskKey, |