export type MarkSeenRequest = {spotlightId: string}; export type CreateApiApiSpotlightSeenArgs = {'x-user-id'?: (string | null) | undefined, body: MarkSeenRequest}; export type CreateApiApiSpotlightSeenOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Mark Seen * * POST /api/spotlight/seen */ export const createApiApiSpotlightSeen = async (args: CreateApiApiSpotlightSeenArgs, options: CreateApiApiSpotlightSeenOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['x-user-id'] != null) headers.set("x-user-id", String(args['x-user-id'])) if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/spotlight/seen${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 };