/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The current status of the product (active or archived). */ export const ProductStatus = { Active: "active", Archived: "archived", } as const; /** * The current status of the product (active or archived). */ export type ProductStatus = OpenEnum; /** * The tax applicability of the product: `taxable` (the product is taxed), `shipping` (only the shipping is taxed, the product itself is exempt) or `none` (neither is taxed). */ export const TaxStatus = { Taxable: "taxable", Shipping: "shipping", None: "none", } as const; /** * The tax applicability of the product: `taxable` (the product is taxed), `shipping` (only the shipping is taxed, the product itself is exempt) or `none` (neither is taxed). */ export type TaxStatus = OpenEnum; export type Images = { /** * A unique identifier for an object. */ id?: string | null | undefined; /** * The URL of an image of the product. */ url?: string | null | undefined; }; export type EcommerceProductOptions = { /** * A unique identifier for the option of the product. */ id?: string | null | undefined; /** * The name of the option for the product. */ name?: string | null | undefined; values?: Array | undefined; }; export type EcommerceProductVariantsOptions = { /** * A unique identifier for the option of the variant. */ id?: string | null | undefined; /** * The name of the option for the variant. */ name?: string | null | undefined; /** * The value of the option for the variant. */ value?: string | null | undefined; }; export type EcommerceProductImages = { /** * A unique identifier for an object. */ id?: string | null | undefined; /** * The URL of an image of the variant. */ url?: string | null | undefined; }; export type Variants = { /** * A unique identifier for the variant of the product. */ id?: string | null | undefined; /** * The name for the variant, used for displaying to customers. */ name?: string | null | undefined; /** * The price of the variant. */ price?: string | null | undefined; /** * The stock keeping unit of the variant. */ sku?: string | null | undefined; /** * The quantity of the variant in stock. */ inventoryQuantity?: string | null | undefined; /** * The weight of the variant. */ weight?: string | null | undefined; /** * The unit of measurement for the weight of the variant. */ weightUnit?: string | null | undefined; options?: Array | undefined; images?: Array | undefined; }; export type EcommerceProductCategories = { /** * A unique identifier for an object. */ id?: string | null | undefined; /** * The name of the category. */ name?: string | null | undefined; }; export type EcommerceProduct = { /** * A unique identifier for an object. */ id: string; /** * The name of the product as it should be displayed to customers. */ name?: string | null | undefined; /** * A detailed description of the product. */ description?: string | null | undefined; /** * The current status of the product (active or archived). */ status?: ProductStatus | null | undefined; /** * The tax applicability of the product: `taxable` (the product is taxed), `shipping` (only the shipping is taxed, the product itself is exempt) or `none` (neither is taxed). */ taxStatus?: TaxStatus | null | undefined; /** * The price of the product. */ price?: string | null | undefined; /** * The stock keeping unit of the product. */ sku?: string | null | undefined; /** * The quantity of the product in stock. */ inventoryQuantity?: string | null | undefined; /** * An array of image URLs for the product. */ images?: Array | null | undefined; /** * The weight of the product. */ weight?: string | null | undefined; /** * The unit of measurement for the weight of the product. */ weightUnit?: string | null | undefined; /** * An array of options for the product. */ options?: Array | undefined; variants?: Array | undefined; /** * An array of tags for the product, used for organization and searching. */ tags?: Array | undefined; /** * An array of categories for the product, used for organization and searching. */ categories?: Array | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; }; /** @internal */ export const ProductStatus$inboundSchema: z.ZodType< ProductStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(ProductStatus)); /** @internal */ export const TaxStatus$inboundSchema: z.ZodType< TaxStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(TaxStatus)); /** @internal */ export const Images$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), url: z.nullable(types.string()).optional(), }) ); export function imagesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Images$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Images' from JSON`, ); } /** @internal */ export const EcommerceProductOptions$inboundSchema: z.ZodType< EcommerceProductOptions, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), name: z.nullable(types.string()).optional(), values: types.optional(z.array(types.nullable(types.string()))), }) ); export function ecommerceProductOptionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EcommerceProductOptions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EcommerceProductOptions' from JSON`, ); } /** @internal */ export const EcommerceProductVariantsOptions$inboundSchema: z.ZodType< EcommerceProductVariantsOptions, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), name: z.nullable(types.string()).optional(), value: z.nullable(types.string()).optional(), }) ); export function ecommerceProductVariantsOptionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EcommerceProductVariantsOptions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EcommerceProductVariantsOptions' from JSON`, ); } /** @internal */ export const EcommerceProductImages$inboundSchema: z.ZodType< EcommerceProductImages, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), url: z.nullable(types.string()).optional(), }) ); export function ecommerceProductImagesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EcommerceProductImages$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EcommerceProductImages' from JSON`, ); } /** @internal */ export const Variants$inboundSchema: z.ZodType< Variants, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), name: z.nullable(types.string()).optional(), price: z.nullable(types.string()).optional(), sku: z.nullable(types.string()).optional(), inventory_quantity: z.nullable(types.string()).optional(), weight: z.nullable(types.string()).optional(), weight_unit: z.nullable(types.string()).optional(), options: types.optional( z.array(z.lazy(() => EcommerceProductVariantsOptions$inboundSchema)), ), images: types.optional( z.array(z.lazy(() => EcommerceProductImages$inboundSchema)), ), }).transform((v) => { return remap$(v, { "inventory_quantity": "inventoryQuantity", "weight_unit": "weightUnit", }); }) ); export function variantsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Variants$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Variants' from JSON`, ); } /** @internal */ export const EcommerceProductCategories$inboundSchema: z.ZodType< EcommerceProductCategories, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), name: z.nullable(types.string()).optional(), }) ); export function ecommerceProductCategoriesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EcommerceProductCategories$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EcommerceProductCategories' from JSON`, ); } /** @internal */ export const EcommerceProduct$inboundSchema: z.ZodType< EcommerceProduct, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), name: z.nullable(types.string()).optional(), description: z.nullable(types.string()).optional(), status: z.nullable(ProductStatus$inboundSchema).optional(), tax_status: z.nullable(TaxStatus$inboundSchema).optional(), price: z.nullable(types.string()).optional(), sku: z.nullable(types.string()).optional(), inventory_quantity: z.nullable(types.string()).optional(), images: z.nullable(z.array(z.lazy(() => Images$inboundSchema))).optional(), weight: z.nullable(types.string()).optional(), weight_unit: z.nullable(types.string()).optional(), options: types.optional( z.array(z.lazy(() => EcommerceProductOptions$inboundSchema)), ), variants: types.optional(z.array(z.lazy(() => Variants$inboundSchema))), tags: types.optional(z.array(types.nullable(types.string()))), categories: types.optional( z.array(z.lazy(() => EcommerceProductCategories$inboundSchema)), ), custom_mappings: z.nullable(z.record(z.any())).optional(), created_at: z.nullable(types.date()).optional(), updated_at: z.nullable(types.date()).optional(), }).transform((v) => { return remap$(v, { "tax_status": "taxStatus", "inventory_quantity": "inventoryQuantity", "weight_unit": "weightUnit", "custom_mappings": "customMappings", "created_at": "createdAt", "updated_at": "updatedAt", }); }) ); export function ecommerceProductFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EcommerceProduct$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EcommerceProduct' from JSON`, ); }