export type CreateGameComplaintDto = {sessionId: string, reason: string}; export type CreateApiV1GamesIdComplaintArgs = {id: string, 'x-idempotency-key': string, body: CreateGameComplaintDto}; export type CreateApiV1GamesIdComplaintOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /v1/games/{id}/complaint */ export const createApiV1GamesIdComplaint = async (args: CreateApiV1GamesIdComplaintArgs, options: CreateApiV1GamesIdComplaintOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['x-idempotency-key'] != null) headers.set("x-idempotency-key", String(args['x-idempotency-key'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/games/${encodeURIComponent(String(args.id))}/complaint${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 };