export type CreateApiV1OrgsOrgIdIntegrationsArgs = {org_id: string, template_id: string, body: Record}; export type CreateApiV1OrgsOrgIdIntegrationsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Saves the new integration endpoints in org-settings. * * POST /v1/orgs/{org_id}/integrations */ export const createApiV1OrgsOrgIdIntegrations = async (args: CreateApiV1OrgsOrgIdIntegrationsArgs, options?: CreateApiV1OrgsOrgIdIntegrationsOptions) => { const {baseUrl = "https://api.edgedelta.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.template_id != null) query.append("template_id", String(args.template_id)) if (ApiKeyAuth !== undefined) headers.set("X-ED-API-Token", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/orgs/${encodeURIComponent(String(args.org_id))}/integrations${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };