//native
type Xero = {
token: string
}
/**
* Creates a new folder
* By passing in the appropriate properties, you can create a new folder
*/
export async function main(
auth: Xero,
xero_tenant_id: string,
Idempotency_Key: string,
body: {
Name?: string
FileCount?: number
Email?: string
IsInbox?: false | true
Id?: string
}
) {
const url = new URL(`https://api.xero.com/files.xro/1.0//Folders`)
const response = await fetch(url, {
method: 'POST',
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 448 days ago