export type GetApiV1FacebookCallbackArgs = {code?: string | undefined, state?: string | undefined, error?: string | undefined}; export type GetApiV1FacebookCallbackOptions = {baseUrl: string, ApiKey?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /v1/facebook/callback */ export const getApiV1FacebookCallback = async (args: GetApiV1FacebookCallbackArgs, options: GetApiV1FacebookCallbackOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.code != null) query.append("code", String(args.code)) if (args.state != null) query.append("state", String(args.state)) if (args.error != null) query.append("error", String(args.error)) if (ApiKey !== undefined) headers.set("X-Api-Key", ApiKey) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/facebook/callback${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };