import {z} from 'zod' export type GetApiConsumerSalesUserLocationLocationIdServicePaymentOptionsArgs = {Authorization: string, SiteId: number, locationId: string, 'request.locationId'?: number | undefined, 'request.appointmentTypeId'?: number | undefined, 'request.start'?: string | undefined, 'request.end'?: string | undefined, 'request.dependentId'?: string | undefined}; export type GetApiConsumerSalesUserLocationLocationIdServicePaymentOptionsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const mindbodyRestApiDtoModelsSaleServicePaymentOption = z.object({Name: z.string().optional(), PaymentRefNo: z.number().int().optional(), Remaining: z.number().int().optional(), Initial: z.number().int().optional(), RemainingFromAllApplied: z.number().int().optional(), ActiveDate: z.string().optional(), ExpirationDate: z.string().optional()}); 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 }; /** * Returns the current series available on account for a user * If you're checking a date range and any 1 of those dates cannot be paid for by the pricing option, the call will return "Invalid data" * * GET /Consumer/Sales/User/Location/{LocationId}/ServicePaymentOptions */ export const getApiConsumerSalesUserLocationLocationIdServicePaymentOptions = async (args: GetApiConsumerSalesUserLocationLocationIdServicePaymentOptionsArgs, options?: GetApiConsumerSalesUserLocationLocationIdServicePaymentOptionsOptions) => { const {baseUrl = "https://api.mindbodyonline.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args.SiteId != null) headers.set("SiteId", String(args.SiteId)) if (args.locationId != null) query.append("locationId", String(args.locationId)) if (args['request.locationId'] != null) query.append("request.locationId", String(args['request.locationId'])) if (args['request.appointmentTypeId'] != null) query.append("request.appointmentTypeId", String(args['request.appointmentTypeId'])) if (args['request.start'] != null) query.append("request.start", String(args['request.start'])) if (args['request.end'] != null) query.append("request.end", String(args['request.end'])) if (args['request.dependentId'] != null) query.append("request.dependentId", String(args['request.dependentId'])) const url = `${baseUrl.replace(/\/+$/, '')}/Consumer/Sales/User/Location/${encodeURIComponent(String(args.LocationId))}/ServicePaymentOptions${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(mindbodyRestApiDtoModelsSaleServicePaymentOption, await res.json()) };