import {z} from 'zod' export type QPilotCoreModelsWeightUnitType = 'Pound' | 'Ounce' | 'Kilogram' | 'Gram'; export type QPilotCoreModelsDiscountType = 'None' | 'ReduceSubtotalByPercentage' | 'ReduceSubtotalByAmount' | 'ReduceShippingByPercentage' | 'ReduceShippingByAmount' | 'SetShippingToAmount' | 'ReduceProductPriceByPercentage' | 'ReduceProductPriceByAmount'; export type QPilotCoreModelsLengthUnitType = 'Inch' | 'Foot' | 'Yard' | 'Milimeter' | 'Centimeter' | 'Meter'; export type QPilotCoreModelsAvailability = 'Undefined' | 'InStock' | 'OutOfStock' | 'Preorder'; export type QPilotCoreModelsProductValidationErrorCode = 1 | 2 | 3 | 4; export type QPilotCoreModelsProduct = {id?: number | undefined, siteId?: number | undefined, parentProductId?: (number | null) | undefined, externalId?: (string | null) | undefined, type?: (string | null) | undefined, sku?: (string | null) | undefined, gtin?: (string | null) | undefined, mpn?: (string | null) | undefined, title: string, description?: (string | null) | undefined, price: number, salePrice?: (number | null) | undefined, length?: (string | null) | undefined, width?: (string | null) | undefined, weightUnitType?: QPilotCoreModelsWeightUnitType | undefined, lengthUnitType?: QPilotCoreModelsLengthUnitType | undefined, height?: (string | null) | undefined, weight?: (string | null) | undefined, shippingClass?: (string | null) | undefined, taxClass?: (string | null) | undefined, imageUrl?: (string | null) | undefined, imageThumbUrl?: (string | null) | undefined, addToScheduledOrder?: boolean | undefined, processScheduledOrder?: boolean | undefined, availability?: QPilotCoreModelsAvailability | undefined, stock?: (number | null) | undefined, createdUtc?: string | undefined, updatedUtc?: string | undefined, lifetimeValue?: number | undefined, active?: boolean | undefined, valid?: boolean | undefined, validationErrorCode?: QPilotCoreModelsProductValidationErrorCode | undefined, backordersAllowed?: (boolean | null) | undefined, metadata?: ({[key: string]: unknown} | null) | undefined}; export type QPilotCoreModelsEmailsEmailTemplatesStyleSettings = {logoBackgroundColor?: (string | null) | undefined, bannerBackgroundColor?: (string | null) | undefined, bannerFontColor?: (string | null) | undefined, scheduledOrderTableColor?: (string | null) | undefined, scheduledOrderFontColor?: (string | null) | undefined, contentTableColor?: (string | null) | undefined, bodyContainerBackgroundColor?: (string | null) | undefined, contentBackgroundColor?: (string | null) | undefined, contentFontColor?: (string | null) | undefined, customStyles?: (string | null) | undefined}; export type QPilotCoreModelsEmailsResourceStyleSettings = {fontFamilyName?: (string | null) | undefined, fontSize?: (string | null) | undefined, fontColor?: (string | null) | undefined, textClass?: (string | null) | undefined, backgroundColor?: (string | null) | undefined, borderColor?: (string | null) | undefined, borderWidthPixels?: (string | null) | undefined, containerClass?: (string | null) | undefined, mainClass?: (string | null) | undefined, customCss?: (string | null) | undefined}; export type QPilotCoreModelsEmailsSiteThemingSettings = {emailSettings?: QPilotCoreModelsEmailsEmailTemplatesStyleSettings | undefined, resourcesStylesSettings?: ({[key: string]: QPilotCoreModelsEmailsResourceStyleSettings} | null) | undefined, notificationsComponentGeneralInformationAreaEnabled?: boolean | undefined}; export type QPilotCoreModelsSitesCustomerPortalStyleSettings = {largeDisplayBreakpoint?: (string | null) | undefined, primaryColor?: (string | null) | undefined, onPrimaryColor?: (string | null) | undefined, surfaceColor?: (string | null) | undefined, onSurfaceColor?: (string | null) | undefined, errorColor?: (string | null) | undefined, onErrorColor?: (string | null) | undefined, customStyles?: (string | null) | undefined, onDiscountBarColor?: (string | null) | undefined, discountBarColor?: (string | null) | undefined, buttonBorderThicknessPx?: number | undefined, buttonBorderRadiusPx?: number | undefined, buttonBorderColor?: (string | null) | undefined, selectedButtonBackgroundColor?: (string | null) | undefined, selectedButtonTextColor?: (string | null) | undefined, unselectedButtonTextColor?: (string | null) | undefined, maxImageWidthPx?: number | undefined, maxImageHeightPx?: number | undefined}; export type QPilotCoreModelsSitesComponentItem = {order?: number | undefined, label?: (string | null) | undefined, identifier?: (string | null) | undefined, enabled?: boolean | undefined}; export type QPilotCoreModelsSitesUnifiedComponentOrderItem = {identifier?: (string | null) | undefined, label?: (string | null) | undefined, order?: number | undefined, enabled?: boolean | undefined, isCustom?: boolean | undefined}; export type QPilotCoreModelsSitesCustomComponentContent = {id?: (string | null) | undefined, name?: (string | null) | undefined, htmlContent?: (string | null) | undefined, cssContent?: (string | null) | undefined, enabled?: boolean | undefined, order?: number | undefined, createdAt?: (string | null) | undefined, updatedAt?: (string | null) | undefined}; export type QPilotCoreModelsSitesDetailedSummaryComponentConfig = {customCss?: (string | null) | undefined, components?: (Array | null) | undefined, unifiedOrder?: (Array | null) | undefined, customComponents?: (Array | null) | undefined}; export type QPilotCoreModelsSitesSnoozeOption = {duration?: number | undefined, durationType?: (string | null) | undefined, isDefault?: boolean | undefined, enabled?: boolean | undefined, order?: number | undefined}; export type QPilotCoreModelsSitesSiteCustomerPortalSettings = {styles?: QPilotCoreModelsSitesCustomerPortalStyleSettings | undefined, detailedSummaryComponentConfig?: QPilotCoreModelsSitesDetailedSummaryComponentConfig | undefined, allowCustomerSnooze?: boolean | undefined, snoozeOptions?: (Array | null) | undefined}; export type QPilotCoreModelsTimeUnitType = 'Minutes' | 'Hours' | 'Days'; export type QPilotCoreModelsUserRole = 'None' | 'Merchant' | 'Administrator'; export type QPilotCoreModelsSubscriptionStatus = 'None' | 'Trial' | 'Active' | 'Inactive'; export type QPilotCoreModelsSubscriptionTierType = 0 | 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256; export type QPilotCoreModelsUsersUserVerificationStatus = 'Unknown' | 'Verified' | 'Unverified' | 'PendingVerification'; export type QPilotCoreModelsUsersUser = {id?: number | undefined, email: string, password: string, role?: QPilotCoreModelsUserRole | undefined, subscriptionId?: (string | null) | undefined, subscriptionStatus?: QPilotCoreModelsSubscriptionStatus | undefined, subscriptionPaymentMethodDescription?: (string | null) | undefined, subscriptionNextBillingDate?: (string | null) | undefined, subscriptionUpdatedUtc?: (string | null) | undefined, createdUtc?: string | undefined, updatedUtc?: string | undefined, activeTier?: QPilotCoreModelsSubscriptionTierType | undefined, chargifyProductHandle?: (string | null) | undefined, phoneNumber?: (string | null) | undefined, firstLogin?: number | undefined, accountOwnerEmail?: (string | null) | undefined, emailVerificationStatus?: QPilotCoreModelsUsersUserVerificationStatus | undefined}; export type QPilotCoreModelsIntegrationCategory = 0 | 1 | 2 | 3 | 4 | 5; export type QPilotCoreModelsSitesSiteIntegration = {siteId?: number | undefined, integrationId?: number | undefined, outboundApiKey1?: (string | null) | undefined, outboundApiKey2?: (string | null) | undefined, inboundApiKeyString?: (string | null) | undefined, inboundApiKey?: (string | null) | undefined, createdUtc?: string | undefined, updatedUtc?: string | undefined, testMode?: boolean | undefined, enabled?: boolean | undefined}; export type QPilotCoreModelsIntegration = {id?: number | undefined, name: string, subtitle?: (string | null) | undefined, subtitle2?: (string | null) | undefined, header?: (string | null) | undefined, description: string, category?: QPilotCoreModelsIntegrationCategory | undefined, code: string, url: string, pluginUrl?: (string | null) | undefined, supportUrl?: (string | null) | undefined, accountKeysUrl?: (string | null) | undefined, logoPath: string, transparentLogoPath?: (string | null) | undefined, slideImage1Path?: (string | null) | undefined, slideImage2Path?: (string | null) | undefined, slideImage3Path?: (string | null) | undefined, color?: (string | null) | undefined, skipChargify?: boolean | undefined, siteIntegrations?: (Array | null) | undefined}; export type QPilotCoreModelsSecretKey = {id?: number | undefined, userId?: number | undefined, user?: QPilotCoreModelsUsersUser | undefined, key?: (string | null) | undefined, integrationId?: number | undefined, integration?: QPilotCoreModelsIntegration | undefined, integrationType: string, description: string, createdUtc?: string | undefined, updatedUtc?: string | undefined}; export type QPilotCoreModelsSubscriptionTiersTier = {id?: number | undefined, name?: (string | null) | undefined, handle?: (string | null) | undefined, createdUtc?: string | undefined, updatedUtc?: string | undefined, policies?: (Array | null) | undefined, usageOnCreating?: boolean | undefined, usageOnProcessing?: boolean | undefined}; export type QPilotCoreModelsSubscriptionTiersPolicyType = 0 | 1 | 2; export type QPilotCoreModelsSubscriptionTiersPolicy = {id?: number | undefined, slug?: (string | null) | undefined, tierId?: number | undefined, tier?: QPilotCoreModelsSubscriptionTiersTier | undefined, siteId?: (number | null) | undefined, site?: QPilotCoreModelsSitesSite | undefined, defaultPolicyId?: (number | null) | undefined, defaultPolicy?: QPilotCoreModelsSubscriptionTiersPolicy | undefined, pageId?: (number | null) | undefined, type?: QPilotCoreModelsSubscriptionTiersPolicyType | undefined, name?: (string | null) | undefined, description?: (string | null) | undefined, value?: (string | null) | undefined, active?: boolean | undefined, createdUtc?: string | undefined, updatedUtc?: string | undefined}; export type QPilotCoreModelsLogExpiration = {id?: number | undefined, sites?: QPilotCoreModelsSitesSite | undefined, codLogToClean?: (string | null) | undefined, expirationDates?: number | undefined}; export type QPilotCoreModelsFrequencyType = 'Days' | 'Weeks' | 'Months' | 'DayOfTheWeek' | 'DayOfTheMonth'; export type QPilotCoreModelsFrequencyTypeValues = {frequencyType?: QPilotCoreModelsFrequencyType | undefined, displayName?: (string | null) | undefined, value?: number | undefined}; export type QPilotCoreModelsSitesSite = {id?: number | undefined, userId?: number | undefined, url: string, baseUrlWebHook?: (string | null) | undefined, logoUrl?: (string | null) | undefined, scheduledOrdersClientPageUrl?: (string | null) | undefined, name: string, email: string, zipCode?: (string | null) | undefined, createdUtc?: string | undefined, updatedUtc?: string | undefined, isProduction?: boolean | undefined, orderProcessingStartTime?: (unknown | null) | undefined, orderProcessingEndTime?: (unknown | null) | undefined, orderProcessingOffset?: (number | null) | undefined, utcOffset?: (number | null) | undefined, lockDurationDays?: (number | null) | undefined, isShowingNotes?: boolean | undefined, isShowCoupons?: boolean | undefined, isStackedButtons?: boolean | undefined, isDisplayScheduledOrderId?: boolean | undefined, allowRetryScheduledOrder?: boolean | undefined, showProductTitleOnImages?: boolean | undefined, enableProductCarouselAutoSlide?: boolean | undefined, noScheduleOrdersBody?: (string | null) | undefined, noScheduleOrdersLink?: (string | null) | undefined, isProcessingPaused?: boolean | undefined, lastProcessingPausedUtc?: (string | null) | undefined, failedConnectAttempts?: number | undefined, defaultWeightUnitType?: QPilotCoreModelsWeightUnitType | undefined, defaultLengthUnitType?: QPilotCoreModelsLengthUnitType | undefined, themingSettings?: QPilotCoreModelsEmailsSiteThemingSettings | undefined, themingSettingsJson?: (string | null) | undefined, customerPortalSettings?: QPilotCoreModelsSitesSiteCustomerPortalSettings | undefined, customerPortalSettingsJson?: (string | null) | undefined, repeatProcessingAllowedWindow?: (number | null) | undefined, repeatProcessingAllowedWindowUnitType?: QPilotCoreModelsTimeUnitType | undefined, metadata?: ({[key: string]: unknown} | null) | undefined, metadataJson?: (string | null) | undefined, phoneNumber?: (string | null) | undefined, revenueSummaryEmailAddresses?: (string | null) | undefined, enableRevenueSummaryEmail?: boolean | undefined, productEventLogsExpirationHours?: number | undefined, emailDeliveryEventExpirationHours?: number | undefined, paymentMethodsPageUrl?: (string | null) | undefined, processingVersion?: number | undefined, baseUrl?: (string | null) | undefined, createOrderEndpoint?: (string | null) | undefined, orderProcessedEndpoint?: (string | null) | undefined, failOrderEndpoint?: (string | null) | undefined, updateProductAvailabilityEndpoint?: (string | null) | undefined, healthCheckPostEndpoint?: (string | null) | undefined, healthCheckPutEndpoint?: (string | null) | undefined, secretKeyId?: (number | null) | undefined, secretKey?: QPilotCoreModelsSecretKey | undefined, policies?: (Array | null) | undefined, fallbackToQpilotShippingWhenNextimeFails?: boolean | undefined, logExpirations?: (Array | null) | undefined, active?: boolean | undefined, currencyIso?: (string | null) | undefined, sortProductsAlphabetically?: boolean | undefined, hideOutOfStockProducts?: boolean | undefined, manageAllowedFrequencies?: boolean | undefined, allowedFrequencies?: (Array | null) | undefined}; export type QPilotCoreModelsProductGroup = {productGroupId?: number | undefined, name: string, createdUtc?: string | undefined, updatedUtc?: (string | null) | undefined, siteId?: number | undefined, site?: QPilotCoreModelsSitesSite | undefined}; export type QPilotCoreModelsCouponInvalidationCode = 'Expired' | 'SiteLimitExceeded' | 'ScheduledOrderLimitExceeded' | 'CustomerLimitExceeded' | 'GeographyNotMet' | 'TotalsNotMet' | 'UnitsNotMet' | 'MinWeightNotMet' | 'MaxWeightNotMet' | 'ScheduledOrderCyclesNotMet' | 'CustomerInclusionList' | 'CustomerExclusionList' | 'NonStackable' | 'ManuallyRemoved' | 'MaxAssignmentsReached' | 'MapRemoved' | 'ProductNotPresent' | 'SubtotalDiscountTypeMixed' | 'ItemHasSalePrice'; export type QPilotCoreModelsCustomerCouponUsage = {couponId?: number | undefined, customerId?: number | undefined, lifetimeDiscount?: number | undefined, updatedUtc?: string | undefined, cycles?: number | undefined, assignments?: number | undefined, valid?: boolean | undefined, couponInvalidationCode?: QPilotCoreModelsCouponInvalidationCode | undefined}; export type QPilotCoreModelsCoupon = {id?: number | undefined, siteId?: number | undefined, code: string, name?: (string | null) | undefined, country?: (string | null) | undefined, postcode?: (string | null) | undefined, state?: (string | null) | undefined, city?: (string | null) | undefined, minUnits?: (number | null) | undefined, maxUnits?: (number | null) | undefined, minWeight?: (number | null) | undefined, maxWeight?: (number | null) | undefined, weightUnitType?: QPilotCoreModelsWeightUnitType | undefined, cycles?: number | undefined, maxCyclesPerSite?: (number | null) | undefined, minSubtotal?: (number | null) | undefined, maxSubtotal?: (number | null) | undefined, maxCyclesPerCustomer?: (number | null) | undefined, assignments?: number | undefined, maxAssignmentsPerCustomer?: (number | null) | undefined, maxAssignmentsPerSite?: (number | null) | undefined, minScheduledOrderCycles?: (number | null) | undefined, maxScheduledOrderCycles?: (number | null) | undefined, maxCyclesPerScheduledOrder?: (number | null) | undefined, maxDiscountPerCustomer?: (number | null) | undefined, lifetimeValue?: number | undefined, amount?: number | undefined, discountType?: QPilotCoreModelsDiscountType | undefined, maxPercentageDiscount?: (number | null) | undefined, expirationDate?: (string | null) | undefined, applyExpirationDateToExisting?: boolean | undefined, isStackable?: boolean | undefined, productId?: (number | null) | undefined, product?: QPilotCoreModelsProduct | undefined, productGroupId?: (number | null) | undefined, productGroup?: QPilotCoreModelsProductGroup | undefined, productDiscountNotAppliesWhenItHasSalePrice?: boolean | undefined, subtotalDiscountAppliesToRegularPrice?: boolean | undefined, createdUtc?: string | undefined, updatedUtc?: string | undefined, customerCouponUsages?: (Array | null) | undefined, includeCustomerEmails?: (string | null) | undefined, excludeCustomerEmails?: (string | null) | undefined, active?: boolean | undefined, valid?: boolean | undefined, couponInvalidationCode?: QPilotCoreModelsCouponInvalidationCode | undefined}; export type CreateApiSitesSiteIdCouponsArgs = {siteId: number, body: QPilotCoreModelsCoupon}; export type CreateApiSitesSiteIdCouponsOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const qPilotCoreModelsWeightUnitType = z.enum(["Pound", "Ounce", "Kilogram", "Gram"]); export const qPilotCoreModelsDiscountType = z.enum(["None", "ReduceSubtotalByPercentage", "ReduceSubtotalByAmount", "ReduceShippingByPercentage", "ReduceShippingByAmount", "SetShippingToAmount", "ReduceProductPriceByPercentage", "ReduceProductPriceByAmount"]); export const qPilotCoreModelsLengthUnitType = z.enum(["Inch", "Foot", "Yard", "Milimeter", "Centimeter", "Meter"]); export const qPilotCoreModelsProductAvailability = z.enum(["None", "AddToScheduledOrder", "ProcessScheduledOrder"]); export const qPilotCoreModelsAvailability = z.enum(["Undefined", "InStock", "OutOfStock", "Preorder"]); export const qPilotCoreModelsProductValidationErrorCode = z.union([z.literal(1), z.literal(2), z.literal(3), z.literal(4)]); export const qPilotCoreModelsDtoLegacyLegacyProductDto = z.object({id: z.number().int().optional(), siteId: z.number().int().optional(), parentProductId: z.number().int().nullable().optional(), externalId: z.string().max(16), type: z.string().max(20), sku: z.string().max(50).nullable().optional(), title: z.string().max(200), description: z.string().nullable().optional(), price: z.number().optional(), salePrice: z.number().nullable().optional(), length: z.string().max(10).nullable().optional(), width: z.string().max(10).nullable().optional(), height: z.string().max(10).nullable().optional(), weight: z.string().max(10).nullable().optional(), weightUnitType: qPilotCoreModelsWeightUnitType.optional(), lengthUnitType: qPilotCoreModelsLengthUnitType.optional(), shippingClass: z.string().max(100).nullable().optional(), taxClass: z.string().max(100).nullable().optional(), imageUrl: z.string().max(2000).nullable().optional(), imageThumbUrl: z.string().max(2000).nullable().optional(), availability: qPilotCoreModelsProductAvailability.optional(), stockLevel: qPilotCoreModelsAvailability.optional(), stock: z.number().int().nullable().optional(), createdUtc: z.string().optional(), updatedUtc: z.string().optional(), lifetimeValue: z.number().optional(), active: z.boolean().nullable().optional(), valid: z.boolean().nullable().optional(), productGroupIds: z.array(z.number().int()).nullable().optional(), validationErrorCode: qPilotCoreModelsProductValidationErrorCode.optional(), backordersAllowed: z.boolean().nullable().optional(), metadata: z.record(z.string(), z.unknown()).nullable().optional(), syncOnUpdate: z.boolean().optional(), quantityLabel: z.string().nullable().optional()}); export const qPilotCoreModelsCouponInvalidationCode = z.enum(["Expired", "SiteLimitExceeded", "ScheduledOrderLimitExceeded", "CustomerLimitExceeded", "GeographyNotMet", "TotalsNotMet", "UnitsNotMet", "MinWeightNotMet", "MaxWeightNotMet", "ScheduledOrderCyclesNotMet", "CustomerInclusionList", "CustomerExclusionList", "NonStackable", "ManuallyRemoved", "MaxAssignmentsReached", "MapRemoved", "ProductNotPresent", "SubtotalDiscountTypeMixed", "ItemHasSalePrice"]); export const qPilotCoreModelsDtoEntitiesProductGroupProductsDto = z.object({id: z.string().min(1), title: z.string().nullable().optional()}); export const qPilotCoreModelsDtoEntitiesProductGroupDto = z.object({productGroupId: z.number().int().nullable().optional(), name: z.string().min(1), createdUtc: z.string().nullable().optional(), updatedUtc: z.string().nullable().optional(), siteId: z.number().int().optional(), products: z.array(qPilotCoreModelsDtoEntitiesProductGroupProductsDto).nullable().optional()}); export const qPilotCoreModelsDtoLegacyLegacyCouponDto = z.object({id: z.number().int().optional(), siteId: z.number().int().optional(), code: z.string().nullable().optional(), name: z.string().nullable().optional(), country: z.string().nullable().optional(), postcode: z.string().nullable().optional(), state: z.string().nullable().optional(), city: z.string().nullable().optional(), minUnits: z.number().int().nullable().optional(), maxUnits: z.number().int().nullable().optional(), minWeight: z.number().nullable().optional(), maxWeight: z.number().nullable().optional(), weightUnitType: qPilotCoreModelsWeightUnitType.optional(), cycles: z.number().int().optional(), maxCyclesPerSite: z.number().int().nullable().optional(), minSubtotal: z.number().nullable().optional(), maxSubtotal: z.number().nullable().optional(), maxCyclesPerCustomer: z.number().int().nullable().optional(), assignments: z.number().int().nullable().optional(), maxAssignmentsPerCustomer: z.number().int().nullable().optional(), maxAssignmentsPerSite: z.number().int().nullable().optional(), minScheduledOrderCycles: z.number().int().nullable().optional(), maxScheduledOrderCycles: z.number().int().nullable().optional(), maxCyclesPerScheduledOrder: z.number().int().nullable().optional(), maxDiscountPerCustomer: z.number().nullable().optional(), lifetimeValue: z.number().optional(), amount: z.number().optional(), discountType: qPilotCoreModelsDiscountType.optional(), maxPercentageDiscount: z.number().nullable().optional(), expirationDate: z.string().nullable().optional(), applyExpirationDateToExisting: z.boolean().optional(), isStackable: z.boolean().optional(), productId: z.number().int().nullable().optional(), product: qPilotCoreModelsDtoLegacyLegacyProductDto.optional(), productDiscountNotAppliesWhenItHasSalePrice: z.boolean().optional(), subtotalDiscountAppliesToRegularPrice: z.boolean().optional(), createdUtc: z.string().optional(), updatedUtc: z.string().optional(), includeCustomerEmails: z.string().nullable().optional(), excludeCustomerEmails: z.string().nullable().optional(), active: z.boolean().optional(), valid: z.boolean().optional(), couponInvalidationCode: qPilotCoreModelsCouponInvalidationCode.optional(), productGroupId: z.number().int().nullable().optional(), productGroup: qPilotCoreModelsDtoEntitiesProductGroupDto.optional(), productsExternalIds: z.array(z.string()).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 Coupon * * POST /Sites/{siteId}/Coupons */ export const createApiSitesSiteIdCoupons = async (args: CreateApiSitesSiteIdCouponsArgs, options?: CreateApiSitesSiteIdCouponsOptions) => { 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))}/Coupons${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(qPilotCoreModelsDtoLegacyLegacyCouponDto, await res.json()) };