import {z} from 'zod' export type OrderAddressDto = {firstName: string, lastName: string, email: string, phoneNumber: string, phoneExtension?: (number | null) | undefined, apartment?: (string | null) | undefined, street: string, city: string, zipCode: string}; export type ParticipantDto = {id?: (unknown | null) | undefined, activityOccurrenceId?: (unknown | null) | undefined, activityRegistrationId?: (unknown | null) | undefined, firstName?: string | undefined, lastName?: string | undefined, emailAddress?: string | undefined, allergies?: (string | null) | undefined, reducedMobility?: boolean | undefined, memberNumber?: (string | null) | undefined, companyName?: (string | null) | undefined, organizationName?: (string | null) | undefined}; export type UpdateActivityRegistrationRequest = {activityOccurrenceId?: unknown | undefined, chapter: string, billingAddress?: OrderAddressDto | undefined, participants: Array, successUrl?: string | undefined, cancelUrl?: string | undefined, lang?: string | undefined}; export type UpdateApiApiActivityOccurrencesRegistrationsIdArgs = {id: unknown, body: UpdateActivityRegistrationRequest}; export type UpdateApiApiActivityOccurrencesRegistrationsIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const updateApiApiActivityOccurrencesRegistrationsIdResponse = z.string(); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * PUT /api/activity-occurrences/registrations/{id} */ export const updateApiApiActivityOccurrencesRegistrationsId = async (args: UpdateApiApiActivityOccurrencesRegistrationsIdArgs, options?: UpdateApiApiActivityOccurrencesRegistrationsIdOptions) => { const {baseUrl = "https://api.rgcq.org", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/activity-occurrences/registrations/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 validateResponse(updateApiApiActivityOccurrencesRegistrationsIdResponse, await res.json()) };