//native
/**
* Upload required immigration document
* Endpoint to upload the required immigration document for a case
**Token scopes**: `worker:write`
*/
export async function main(auth: RT.Deel, body: Body) {
const url = new URL(`https://api.letsdeel.com/rest/v2/immigration/workers/documents`)
const formData = new FormData()
for (const [k, v] of Object.entries(body)) {
if (v !== undefined && v !== '') {
formData.append(k, String(v))
}
}
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: 'Bearer ' + auth.apiKey
},
body: formData
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
export interface Body {
/**
* Details of immigration document requirement upload
*/
data: {
/**
* Immigration right to work document. More than 1 document can be uploaded at the same time (e.g.: front and back)
*/
file: string
/**
* The id of the right to work case.
*/
case_id: string
/**
* The hris profile oid (public id) of the worker.
*/
worker_id: string
/**
* The id of the document_request_id. Keep in mind that document requests change, so if a previous document was rejected, a new document request will be created for the new document. You can get the latest one by calling the required-documents endpoint.
*/
document_request_id: string
[k: string]: unknown
}
[k: string]: unknown
}
Submitted by hugo697 235 days ago