Edits history of script submission #14978 for ' Delete source account (codat)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Codat = {
    	encodedKey: string
    }
    /**
     * Delete source account
     * The _Delete source account_ endpoint enables you to remove a source account.
    
    Removing a source account will also remove any mapping between the source bank feed bank accounts and the target bankfeed bank account.
    
     */
    export async function main(
    	auth: Codat,
    	companyId: string,
    	connectionId: string,
    	accountId: string
    ) {
    	const url = new URL(
    		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/connectionInfo/bankFeedAccounts/${accountId}`
    	)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		headers: {
    			Authorization: `Basic ${auth.encodedKey}`
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 235 days ago