1 | |
2 | type Intercom = { |
3 | apiVersion: string |
4 | token: string |
5 | } |
6 | |
7 | * Cancel content data export |
8 | * You can cancel your job |
9 | */ |
10 | export async function main(auth: Intercom, job_identifier: string) { |
11 | const url = new URL(`https://api.intercom.io/export/cancel/${job_identifier}`) |
12 |
|
13 | const response = await fetch(url, { |
14 | method: 'POST', |
15 | headers: { |
16 | 'Intercom-Version': auth.apiVersion, |
17 | Authorization: 'Bearer ' + auth.token |
18 | }, |
19 | body: undefined |
20 | }) |
21 | if (!response.ok) { |
22 | const text = await response.text() |
23 | throw new Error(`${response.status} ${text}`) |
24 | } |
25 | return await response.json() |
26 | } |
27 |
|