//native
type Xero = {
token: string;
};
/**
* adds a fixed asset type
* Adds an fixed asset type to the system
*/
export async function main(
auth: Xero,
xero_tenant_id: string,
Idempotency_Key: string,
body: {
assetTypeId?: string;
assetTypeName: string;
fixedAssetAccountId?: string;
depreciationExpenseAccountId?: string;
accumulatedDepreciationAccountId?: string;
bookDepreciationSetting: {
depreciationMethod?:
| "NoDepreciation"
| "StraightLine"
| "DiminishingValue100"
| "DiminishingValue150"
| "DiminishingValue200"
| "FullDepreciation";
averagingMethod?: "FullMonth" | "ActualDays";
depreciationRate?: number;
effectiveLifeYears?: number;
depreciationCalculationMethod?: "Rate" | "Life" | "None";
depreciableObjectId?: string;
depreciableObjectType?: string;
bookEffectiveDateOfChangeId?: string;
};
locks?: number;
},
) {
const url = new URL(`https://api.xero.com/assets.xro/1.0/AssetTypes`);
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