Edits history of script submission #10481 for ' Updates a superfund (xero)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Xero = {
    	token: string
    }
    /**
     * Updates a superfund
     * Update properties on a single Superfund
     */
    export async function main(
    	auth: Xero,
    	SuperFundID: string,
    	Xero_Tenant_Id: string,
    	Idempotency_Key: string,
    	body: {
    		SuperFundID?: string
    		Type: 'REGULATED' | 'SMSF'
    		Name?: string
    		ABN?: string
    		BSB?: string
    		AccountNumber?: string
    		AccountName?: string
    		ElectronicServiceAddress?: string
    		EmployerNumber?: string
    		SPIN?: string
    		USI?: string
    		UpdatedDateUTC?: string
    		ValidationErrors?: { Message?: string }[]
    	}[]
    ) {
    	const url = new URL(`https://api.xero.com/payroll.xro/1.0/Superfunds/${SuperFundID}`)
    
    	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