Edits history of script submission #15212 for ' Update the visible accounts on sync flow (codat)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Codat = {
    	encodedKey: string
    }
    /**
     * Update the visible accounts on sync flow
     * To enable update of accounts visible preferences set on Sync Flow.
     */
    export async function main(auth: Codat, platformKey: string, body: { visibleAccounts?: string[] }) {
    	const url = new URL(
    		`https://api.codat.io/sync/commerce/config/ui/accounts/platform/${platformKey}`
    	)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: `Basic ${auth.encodedKey}`
    		},
    		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 235 days ago