export type CreateApiSessionsIdCompleteArgs = {id: string}; export type CreateApiSessionsIdCompleteOptions = {baseUrl: string, OAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Complete a session * * POST /sessions/{id}/complete * * Also accepts auth: SessionSecret */ export const createApiSessionsIdComplete = async (args: CreateApiSessionsIdCompleteArgs, options: CreateApiSessionsIdCompleteOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (OAuth !== undefined) headers.set('authorization', `Bearer ${OAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/sessions/${encodeURIComponent(String(args.id))}/complete${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 undefined };