Edits history of script submission #15028 for ' Get configuration (codat)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Codat = {
    	encodedKey: string
    }
    /**
     * Get configuration
     * The *Get configuration* endpoint returns supplemental data configuration previously created for each integration and data type combination.
    
    [Supplemental data](https://docs.codat.io/using-the-api/supplemental-data/overview) is additional data you can include in Codat's standard data types.
     */
    export async function main(
    	auth: Codat,
    	platformKey: string,
    	dataType:
    		| 'chartOfAccounts'
    		| 'bills'
    		| 'company'
    		| 'creditNotes'
    		| 'customers'
    		| 'invoices'
    		| 'items'
    		| 'journalEntries'
    		| 'suppliers'
    		| 'taxRates'
    		| 'commerce-companyInfo'
    		| 'commerce-customers'
    		| 'commerce-disputes'
    		| 'commerce-locations'
    		| 'commerce-orders'
    		| 'commerce-payments'
    		| 'commerce-paymentMethods'
    		| 'commerce-products'
    		| 'commerce-productCategories'
    		| 'commerce-taxComponents'
    		| 'commerce-transactions'
    ) {
    	const url = new URL(
    		`https://api.codat.io/integrations/${platformKey}/dataTypes/${dataType}/supplementalDataConfig`
    	)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: `Basic ${auth.encodedKey}`
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago