import {z} from 'zod' export type GetApiApiPublicResellTicketIdStatusArgs = {sellerId: string, secret: string, id: string}; export type GetApiApiPublicResellTicketIdStatusOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const gETResellOffersGetPublicTicketResellStatus200Response = z.array(z.object({eventId: z.string(), offerAble: z.boolean(), hasActiveOffer: z.boolean(), activeOffer: z.object({_id: z.string(), customerId: z.string(), sellerId: z.string(), eventId: z.string(), items: z.array(z.object({ticketId: z.string(), ticketTypeId: z.string(), ticketName: z.string().optional(), categoryRef: z.string(), 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(), price: z.number(), resellFee: z.number()})), status: z.union([z.boolean(), z.number(), z.object({}), z.enum(["ACTIVE", "SOLD", "CANCELED"])]), cpmId: z.string().optional(), payoutTarget: z.union([z.object({type: z.literal("cpm"), cpmId: z.string()}), z.object({type: z.literal("customer_balance")})]).optional(), currency: z.union([z.boolean(), z.number(), z.object({}), z.enum(["EUR", "USD", "GBP", "AUD", "CHF", "THB", "ILS", "COP", "MXN", "DKK", "NOK", "SEK", "QAR", "CAD", "ISK", "GTQ", "INR", "DOP", "SGD", "PLN", "SAR", "TTD", "ZAR", "KYD", "HKD", "CZK", "KRW", "JPY", "NZD", "AED", "MAD", "TWD", "BRL", "BWP", "NAD", "KES", "SCR", "TRY", "SZL", "LSL", "TZS", "UGX", "ZMW", "ZWG", "GHS", "NGN", "SLE", "LRD", "XOF", "XAF", "GEL", "IDR", "ARS", "CRC", "HUF", "EGP", "MYR", "VND", "PHP", "MWK"])]), history: z.array(z.object({type: z.enum(["resell.offer.created", "resell.offer.canceled", "resell.offer.expired", "resell.offer.sold"]).optional(), date: z.string().optional(), userId: z.string().nullable().optional(), data: z.object({}).optional()})).optional(), createdAt: z.string(), updatedAt: z.string()}).optional(), violations: z.enum(["SEASON_EVENT_OFFER_DISABLED", "EVENT_OFFER_DISABLED", "TICKET_OFFER_DISABLED", "NO_TRANSACTION", "TICKET_TYPE_NOT_MAPPED", "VALUE_SHARE_MISSING", "EVENT_EXCLUDED", "NO_SEATING_INFO", "TICKET_LOCKED", "TICKET_INVALID", "FEE_EXCEEDS_PRICE", "HAS_TICKET_TRANSFER", "HAS_SCANS", "HAS_ACTIVE_OFFER", "TRANSACTION_DISCOUNTED", "CART_AUTOMATION", "BUNDLE", "PAYMENT_PLAN_INCOMPLETE", "CUSTOMER_NOT_VERIFIED", "NO_PAYOUT_TARGET_AVAILABLE"]).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 public ticket resell status * * GET /api/public/resell/ticket/{id}/status */ export const getApiApiPublicResellTicketIdStatus = async (args: GetApiApiPublicResellTicketIdStatusArgs, options?: GetApiApiPublicResellTicketIdStatusOptions) => { const {baseUrl = "https://vivenu.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.sellerId != null) query.append("sellerId", String(args.sellerId)) if (args.secret != null) query.append("secret", String(args.secret)) const url = `${baseUrl.replace(/\/+$/, '')}/api/public/resell/ticket/${encodeURIComponent(String(args.id))}/status${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(gETResellOffersGetPublicTicketResellStatus200Response, await res.json()) };