//native
type Deepl = {
apiKey: string;
baseUrl: string;
};
/**
* Check Document Status
* Retrieve the current status of a document translation process.
If the translation is still in progress, the estimated time remaining is also included in the response.
*/
export async function main(
auth: Deepl,
document_id: string,
body: { document_key: string },
) {
const url = new URL(`${auth.baseUrl}/v2/document/${document_id}`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "DeepL-Auth-Key " + auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago