Edits history of script submission #10471 for ' Updates a specific linked transactions (billable expenses) (xero)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Xero = {
    	token: string
    }
    /**
     * Updates a specific linked transactions (billable expenses)
     *
     */
    export async function main(
    	auth: Xero,
    	LinkedTransactionID: string,
    	xero_tenant_id: string,
    	Idempotency_Key: string,
    	body: {
    		LinkedTransactions?: {
    			SourceTransactionID?: string
    			SourceLineItemID?: string
    			ContactID?: string
    			TargetTransactionID?: string
    			TargetLineItemID?: string
    			LinkedTransactionID?: string
    			Status?: 'APPROVED' | 'DRAFT' | 'ONDRAFT' | 'BILLED' | 'VOIDED'
    			Type?: 'BILLABLEEXPENSE'
    			UpdatedDateUTC?: string
    			SourceTransactionTypeCode?: 'ACCPAY' | 'SPEND'
    			ValidationErrors?: { Message?: string }[]
    		}[]
    	}
    ) {
    	const url = new URL(`https://api.xero.com/api.xro/2.0/LinkedTransactions/${LinkedTransactionID}`)
    
    	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