export type IntegrationProvider = 'bitbucket' | 'github_app' | 'gitlab' | 'slack'; export type DeleteApiApiV3UserIntegrationsProviderArgs = {provider: IntegrationProvider}; export type DeleteApiApiV3UserIntegrationsProviderOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Disconnect an integration from the authenticated user * * DELETE /api/v3/user/integrations/{provider} */ export const deleteApiApiV3UserIntegrationsProvider = async (args: DeleteApiApiV3UserIntegrationsProviderArgs, options?: DeleteApiApiV3UserIntegrationsProviderOptions) => { const {baseUrl = "https://codemagic.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apiKey !== undefined) headers.set("x-auth-token", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/user/integrations/${encodeURIComponent(String(args.provider))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };