import {z} from 'zod' export type QPilotCoreModelsPaymentMethodType = 'Stripe' | 'AuthorizeNet' | 'Test' | 'PayPal' | 'Braintree' | 'CyberSource' | 'Undefined' | 'Other' | 'Nmi' | 'PayaV1' | 'TrustCommerce' | 'Square' | 'Sage' | 'CyberSourceV2' | 'Checkout' | 'PaypalV2' | 'Shopify' | 'PayPalV3' | 'Airwallex'; export type QPilotCoreModelsGatewayPaymentType = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32; export type QPilotCoreModelsDtoRequestsPostPutPaymentMethodDto = {customerId: string, type?: QPilotCoreModelsPaymentMethodType | undefined, gatewayCustomerId?: (string | null) | undefined, gatewayPaymentId?: (string | null) | undefined, description: string, expiration?: (string | null) | undefined, lastFourDigits?: (string | null) | undefined, billingFirstName?: (string | null) | undefined, billingLastName?: (string | null) | undefined, billingStreet1?: (string | null) | undefined, billingStreet2?: (string | null) | undefined, billingCity?: (string | null) | undefined, billingState?: (string | null) | undefined, billingPostcode?: (string | null) | undefined, billingCountry?: (string | null) | undefined, billingCompany?: (string | null) | undefined, isDefault?: (boolean | null) | undefined, gatewayPaymentType?: QPilotCoreModelsGatewayPaymentType | undefined}; export type QPilotCoreModelsDtoRequestsPostPutCustomerDto = {id: string, customerId?: number | undefined, siteId?: number | undefined, email: string, firstName?: (string | null) | undefined, lastName?: (string | null) | undefined, shippingFirstName?: (string | null) | undefined, shippingLastName?: (string | null) | undefined, shippingStreet1?: (string | null) | undefined, shippingStreet2?: (string | null) | undefined, shippingCity?: (string | null) | undefined, shippingState?: (string | null) | undefined, shippingPostcode?: (string | null) | undefined, shippingCountry?: (string | null) | undefined, billingFirstName?: (string | null) | undefined, billingLastName?: (string | null) | undefined, billingStreet1?: (string | null) | undefined, billingStreet2?: (string | null) | undefined, billingCity?: (string | null) | undefined, billingState?: (string | null) | undefined, billingPostcode?: (string | null) | undefined, billingCountry?: (string | null) | undefined, phoneNumber?: (string | null) | undefined, company?: (string | null) | undefined, shippingCompany?: (string | null) | undefined, billingCompany?: (string | null) | undefined, paymentMethods?: (Array | null) | undefined, lifetimeValue?: number | undefined, createdUtc?: string | undefined, updatedUtc?: string | undefined, metadata?: ({[key: string]: unknown} | null) | undefined}; export type CreateApiSitesSiteIdCustomersArgs = {siteId: number, body: QPilotCoreModelsDtoRequestsPostPutCustomerDto}; export type CreateApiSitesSiteIdCustomersOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const qPilotCoreModelsPaymentMethodStatus = z.enum(["Active", "Expired", "Revoked", "Invalid"]); export const qPilotCoreModelsPaymentMethodType = z.enum(["Stripe", "AuthorizeNet", "Test", "PayPal", "Braintree", "CyberSource", "Undefined", "Other", "Nmi", "PayaV1", "TrustCommerce", "Square", "Sage", "CyberSourceV2", "Checkout", "PaypalV2", "Shopify", "PayPalV3", "Airwallex"]); export const qPilotCoreModelsGatewayPaymentType = z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(5), z.literal(6), z.literal(7), z.literal(8), z.literal(9), z.literal(10), z.literal(11), z.literal(12), z.literal(13), z.literal(14), z.literal(15), z.literal(16), z.literal(17), z.literal(18), z.literal(19), z.literal(20), z.literal(21), z.literal(22), z.literal(23), z.literal(24), z.literal(25), z.literal(26), z.literal(27), z.literal(28), z.literal(29), z.literal(30), z.literal(31), z.literal(32)]); export const qPilotCoreModelsDtoEntitiesPaymentMethodDto = z.object({id: z.number().int().optional(), status: qPilotCoreModelsPaymentMethodStatus.optional(), createdUtc: z.string().optional(), updatedUtc: z.string().optional(), expirationDate: z.string().nullable().optional(), customerId: z.string().min(1), type: qPilotCoreModelsPaymentMethodType.optional(), gatewayCustomerId: z.string().nullable().optional(), gatewayPaymentId: z.string().nullable().optional(), description: z.string().min(1), expiration: z.string().nullable().optional(), lastFourDigits: z.string().nullable().optional(), billingFirstName: z.string().max(256).nullable().optional(), billingLastName: z.string().max(256).nullable().optional(), billingStreet1: z.string().max(256).nullable().optional(), billingStreet2: z.string().max(256).nullable().optional(), billingCity: z.string().max(256).nullable().optional(), billingState: z.string().max(256).nullable().optional(), billingPostcode: z.string().max(20).nullable().optional(), billingCountry: z.string().max(2).nullable().optional(), billingCompany: z.string().max(255).nullable().optional(), isDefault: z.boolean().nullable().optional(), gatewayPaymentType: qPilotCoreModelsGatewayPaymentType.optional()}); export const qPilotCoreModelsDtoEntitiesCustomerDto = z.object({created: z.string().nullable().optional(), isShowingNotes: z.boolean().nullable().optional(), isShowCoupons: z.boolean().nullable().optional(), isProcessingPaused: z.boolean().nullable().optional(), paymentMethods: z.array(qPilotCoreModelsDtoEntitiesPaymentMethodDto).nullable().optional(), id: z.string().max(16), customerId: z.number().int().optional(), siteId: z.number().int().optional(), email: z.string().max(255), firstName: z.string().max(255).nullable().optional(), lastName: z.string().max(255).nullable().optional(), shippingFirstName: z.string().max(255).nullable().optional(), shippingLastName: z.string().max(255).nullable().optional(), shippingStreet1: z.string().max(255).nullable().optional(), shippingStreet2: z.string().max(255).nullable().optional(), shippingCity: z.string().max(255).nullable().optional(), shippingState: z.string().max(255).nullable().optional(), shippingPostcode: z.string().max(20).nullable().optional(), shippingCountry: z.string().max(2).nullable().optional(), billingFirstName: z.string().max(255).nullable().optional(), billingLastName: z.string().max(255).nullable().optional(), billingStreet1: z.string().max(255).nullable().optional(), billingStreet2: z.string().max(60).nullable().optional(), billingCity: z.string().max(255).nullable().optional(), billingState: z.string().max(255).nullable().optional(), billingPostcode: z.string().max(20).nullable().optional(), billingCountry: z.string().max(2).nullable().optional(), phoneNumber: z.string().max(30).nullable().optional(), company: z.string().max(255).nullable().optional(), shippingCompany: z.string().max(255).nullable().optional(), billingCompany: z.string().max(255).nullable().optional(), lifetimeValue: z.number().optional(), createdUtc: z.string().optional(), updatedUtc: z.string().optional(), metadata: z.record(z.string(), z.unknown()).nullable().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 }; /** * Create Customer * * POST /Sites/{siteId}/Customers */ export const createApiSitesSiteIdCustomers = async (args: CreateApiSitesSiteIdCustomersArgs, options?: CreateApiSitesSiteIdCustomersOptions) => { const {baseUrl = "https://api.qpilot.cloud", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/Sites/${encodeURIComponent(String(args.siteId))}/Customers${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 validateResponse(qPilotCoreModelsDtoEntitiesCustomerDto, await res.json()) };