Edits history of script submission #15103 for ' Get supplier attachment (codat)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Codat = {
    	encodedKey: string
    }
    /**
     * Get supplier attachment
     * The *Get supplier attachment* endpoint returns a specific attachment for a given `supplierId` and `attachmentId`.
    
    [Suppliers](https://docs.codat.io/lending-api#/schemas/Supplier) are people or organizations that provide something, such as a product or service.
    
     */
    export async function main(
    	auth: Codat,
    	companyId: string,
    	connectionId: string,
    	supplierId: string,
    	attachmentId: string
    ) {
    	const url = new URL(
    		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/suppliers/${supplierId}/attachments/${attachmentId}`
    	)
    
    	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