//native
type Xero = {
token: string
}
/**
* Update a file
* Updates file properties of a single file
*/
export async function main(
auth: Xero,
FileId: string,
xero_tenant_id: string,
Idempotency_Key: string,
body: {
Name?: string
MimeType?: string
Size?: number
CreatedDateUtc?: string
UpdatedDateUtc?: string
User?: {
Id: string
Name?: string
FirstName?: string
LastName?: string
FullName?: string
}
Id?: string
FolderId?: string
}
) {
const url = new URL(`https://api.xero.com/files.xro/1.0//Files/${FileId}`)
const response = await fetch(url, {
method: 'PUT',
headers: {
Accept: 'application/json',
'xero-tenant-id': xero_tenant_id,
'Idempotency-Key': Idempotency_Key,
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
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 515 days ago