| 102 | } |
| 103 | |
| 104 | runTask<T, TResult extends Json<T> | void>( |
| 105 | key: IntegrationTaskKey, |
| 106 | callback: (client: ResendClient, task: IOTask, io: IO) => Promise<TResult>, |
| 107 | options?: RunTaskOptions, |
| 108 | errorCallback?: RunTaskErrorCallback |
| 109 | ): Promise<TResult> { |
| 110 | if (!this._io) throw new Error("No IO"); |
| 111 | if (!this._connectionKey) throw new Error("No connection key"); |
| 112 | |
| 113 | return this._io.runTask( |
| 114 | key, |
| 115 | (task, io) => { |
| 116 | if (!this._client) throw new Error("No client"); |
| 117 | return callback(this._client, task, io); |
| 118 | }, |
| 119 | { icon: "resend", ...(options ?? {}), connectionKey: this._connectionKey }, |
| 120 | errorCallback |
| 121 | ); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Access the Resend Emails API |