//native
type Docspring = {
tokenId: string
tokenSecret: string
}
/**
* Check the status of a submission batch job
*
*/
export async function main(
auth: Docspring,
submission_batch_id: string,
include_submissions: string | undefined
) {
const url = new URL(`https://api.docspring.com/api/v1/submissions/batches/${submission_batch_id}`)
const token = btoa(auth.tokenId + ':' + auth.tokenSecret)
for (const [k, v] of [['include_submissions', include_submissions]]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Basic ${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