import {z} from 'zod' export type GetApiApiCustomersMeResellOffersArgs = {status?: ('ACTIVE' | 'SOLD' | 'CANCELED') | undefined, top?: number | undefined, skip?: number | undefined}; export type GetApiApiCustomersMeResellOffersOptions = {baseUrl?: string | undefined, customerJwt?: string | undefined, fetch?: typeof fetch | undefined}; export const publicResellOfferInfoResource = z.object({_id: z.string(), customerId: z.string(), status: z.union([z.boolean(), z.number(), z.object({}), z.enum(["ACTIVE", "SOLD", "CANCELED"])]), eventId: z.string(), payoutTarget: z.union([z.object({type: z.literal("cpm"), cpmId: z.string()}), z.object({type: z.literal("customer_balance")})]).optional(), updatedAt: z.string(), createdAt: z.string(), items: z.array(z.object({ticketId: z.string(), ticketTypeId: z.string(), categoryRef: z.string(), price: z.number(), resellFee: z.number(), seatingInfo: z.array(z.object({_id: z.string().optional(), _type: z.union([z.literal(6), z.literal(7)]), categoryId: z.string().optional(), statusId: z.string(), name: z.string().nullable().optional(), seatType: z.enum(["handicapped", "limitedView", "foldable"]).nullable().optional(), sectionName: z.string().nullable().optional(), groupName: z.string().nullable().optional(), rowName: z.string().nullable().optional(), seatName: z.string().nullable().optional(), gate: z.string().nullable().optional()})).optional(), ticket: z.object({_id: z.string(), categoryName: z.string().optional(), ticketName: z.string(), seatingInfo: z.object({_id: z.string().optional(), _type: z.union([z.literal(6), z.literal(7)]), categoryId: z.string().optional(), statusId: z.string(), name: z.string().nullable().optional(), seatType: z.enum(["handicapped", "limitedView", "foldable"]).nullable().optional(), sectionName: z.string().nullable().optional(), groupName: z.string().nullable().optional(), rowName: z.string().nullable().optional(), seatName: z.string().nullable().optional(), gate: z.string().nullable().optional()}).optional(), type: z.enum(["SINGLE", "MULTI"]).optional()}).optional()})).optional()}); export const gETCustomersGetResellOffersOfCustomer200Response = z.object({docs: z.array(publicResellOfferInfoResource).optional(), total: z.number().int().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 }; /** * Get Resell Offers of Customer * * GET /api/customers/me/resell-offers */ export const getApiApiCustomersMeResellOffers = async (args: GetApiApiCustomersMeResellOffersArgs, options?: GetApiApiCustomersMeResellOffersOptions) => { const {baseUrl = "https://vivenu.com", fetch: fetchFn = fetch, customerJwt} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.status != null) query.append("status", String(args.status)) if (args.top != null) query.append("top", String(args.top)) if (args.skip != null) query.append("skip", String(args.skip)) if (customerJwt !== undefined) headers.set('authorization', `Bearer ${customerJwt}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/customers/me/resell-offers${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(gETCustomersGetResellOffersOfCustomer200Response, await res.json()) };