export type CreateApiOcapiV1MembersAuthenticationCookieArgs = {'Connect-Region-Code'?: string | undefined, body: BodyInit}; export type CreateApiOcapiV1MembersAuthenticationCookieOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Authenticates a member and returns an HTTP-only authentication cookie * * POST /ocapi/v1/members/authentication-cookie */ export const createApiOcapiV1MembersAuthenticationCookie = async (args: CreateApiOcapiV1MembersAuthenticationCookieArgs, options: CreateApiOcapiV1MembersAuthenticationCookieOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['Connect-Region-Code'] != null) headers.set("Connect-Region-Code", String(args['Connect-Region-Code'])) const url = `${baseUrl.replace(/\/+$/, '')}/ocapi/v1/members/authentication-cookie${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };