//native
type Xero = {
token: string
}
/**
* Creates a new file association
* By passing in the appropriate options, you can create a new folder
*/
export async function main(
auth: Xero,
FileId: string,
xero_tenant_id: string,
Idempotency_Key: string,
body: {
SendWithObject?: false | true
Name?: string
Size?: number
FileId?: string
ObjectId?: string
ObjectGroup?:
| 'Account'
| 'BankTransaction'
| 'Contact'
| 'CreditNote'
| 'Invoice'
| 'Item'
| 'ManualJournal'
| 'Overpayment'
| 'Payment'
| 'Prepayment'
| 'Quote'
| 'Receipt'
ObjectType?:
| 'Account'
| 'Contact'
| 'Prepayment'
| 'Receipt'
| 'Unknown'
| 'Accpay'
| 'AccPayCredit'
| 'AccPayPayment'
| 'AccRec'
| 'AccRecCredit'
| 'AccRecPayment'
| 'Adjustment'
| 'ApCreditPayment'
| 'ApOverPayment'
| 'ApOverPaymentPayment'
| 'ApOverPaymentSourcePayment'
| 'ApPrepayment'
| 'ApPrepaymentPayment'
| 'ApPrepaymentSourcePayment'
| 'ArCreditPayment'
| 'ArOverPayment'
| 'ArOverpaymentPayment'
| 'ArOverpaymentSourcePayment'
| 'ArPrepayment'
| 'ArPrepaymentPayment'
| 'ArPrepaymentSourcePayment'
| 'CashPaid'
| 'CashRec'
| 'ExpPayment'
| 'ManJournal'
| 'PurchaseOrder'
| 'Transfer'
| 'Business'
| 'Employee'
| 'Person'
| 'User'
| 'Org'
| 'FixedAsset'
| 'PayRun'
| 'PriceListItem'
| 'Bank'
| 'Current'
| 'Equity'
| 'Expense'
| 'Fixed'
| 'Liability'
| 'Revenue'
| 'Sales'
| 'Overheads'
| 'Depreciatn'
| 'OtherIncome'
| 'DirectCosts'
| 'Currliab'
| 'Termliab'
| 'NonCurrent'
| 'SalesQuote'
}
) {
const url = new URL(`https://api.xero.com/files.xro/1.0//Files/${FileId}/Associations`)
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 515 days ago