Edits history of script submission #20933 for ' Get detailed list of integrations (terra)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Get detailed list of integrations
     * Retrieve a detailed list of supported integrations, optionally filtered by the developer's enabled integrations and the requirement for SDK usage.
     */
    export async function main(auth: RT.Terra, sdk?: string | undefined) {
    	const url = new URL(`https://api.tryterra.co/v2/integrations/detailed`)
    	for (const [k, v] of [['sdk', sdk]]) {
    		if (v !== undefined && v !== '') {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			'dev-id': auth.devId,
    			'X-api-key': auth.apiKey
    		},
    		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