| 79 | } |
| 80 | |
| 81 | runTask<T, TResult extends Json<T> | void>( |
| 82 | key: IntegrationTaskKey, |
| 83 | callback: (client: TypeformSDK, task: IOTask, io: IO) => Promise<TResult>, |
| 84 | options?: RunTaskOptions, |
| 85 | errorCallback?: RunTaskErrorCallback |
| 86 | ): Promise<TResult> { |
| 87 | if (!this._io) throw new Error("No IO"); |
| 88 | if (!this._connectionKey) throw new Error("No connection key"); |
| 89 | return this._io.runTask( |
| 90 | key, |
| 91 | (task, io) => { |
| 92 | if (!this._client) throw new Error("No client"); |
| 93 | return callback(this._client, task, io); |
| 94 | }, |
| 95 | { |
| 96 | icon: "typeform", |
| 97 | retry: retry.standardBackoff, |
| 98 | ...(options ?? {}), |
| 99 | connectionKey: this._connectionKey, |
| 100 | }, |
| 101 | errorCallback |
| 102 | ); |
| 103 | } |
| 104 | |
| 105 | get forms() { |
| 106 | return new Forms(this.runTask.bind(this)); |