export type CreateApiSalesforceWebhookEventOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /salesforce/webhook/event */ export const createApiSalesforceWebhookEvent = async (options?: CreateApiSalesforceWebhookEventOptions) => { const {baseUrl = "http://api.attention.tech", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/xml;charset=UTF-8") const url = `${baseUrl.replace(/\/+$/, '')}/salesforce/webhook/event${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };