export type SweepstakesResults = {id: string, type: 'SweepstakesResults', attributes: {customer: {idType?: ('ID' | 'PhoneNumber') | undefined, id: string}}}; export type CreateApiApiV1SweepstakesSweepstakesIdResultsArgs = {sweepstakesId: string, 'Client-ID': string, Authorization: string, body: {data: SweepstakesResults}}; export type CreateApiApiV1SweepstakesSweepstakesIdResultsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add Sweepstakes Results * * POST /api/v1/sweepstakes/{sweepstakesId}/results */ export const createApiApiV1SweepstakesSweepstakesIdResults = async (args: CreateApiApiV1SweepstakesSweepstakesIdResultsArgs, options?: CreateApiApiV1SweepstakesSweepstakesIdResultsOptions) => { const {baseUrl = "https://merchant-api.accruesavings.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/vnd.api+json") if (args['Client-ID'] != null) headers.set("Client-ID", String(args['Client-ID'])) if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/sweepstakes/${encodeURIComponent(String(args.sweepstakesId))}/results${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 };