//native
type Intercom = {
apiVersion: string
token: string
}
/**
* Download content data export
* When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234.
Your exported message data will be streamed continuously back down to you in a gzipped CSV format.
> 📘 Octet header required
>
> You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint.
*/
export async function main(auth: Intercom, job_identifier: string) {
const url = new URL(`https://api.intercom.io/download/content/data/${job_identifier}`)
const response = await fetch(url, {
method: 'GET',
headers: {
'Intercom-Version': auth.apiVersion,
Authorization: 'Bearer ' + auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 536 days ago