/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { EcommerceDiscount, EcommerceDiscount$inboundSchema, } from "./ecommercediscount.js"; export type Options = { /** * A unique identifier for the option. */ id?: string | null | undefined; /** * The name of the option. */ name?: string | null | undefined; /** * The value of the option. */ value?: string | null | undefined; }; /** * A single line item of an ecommerce order, representing a product or variant with associated options, quantity, and pricing information. */ export type EcommerceOrderLineItem = { /** * A unique identifier for an object. */ id?: string | null | undefined; /** * A unique identifier for the product associated with the line item. */ productId?: string | null | undefined; /** * A unique identifier for the variant of the product associated with the line item, if applicable. */ variantId?: string | null | undefined; /** * The SKU of the product or variant associated with the line item. */ sku?: string | null | undefined; /** * The name of the product or variant associated with the line item. */ name?: string | null | undefined; /** * The description of the product or variant associated with the line item. */ description?: string | null | undefined; options?: Array | undefined; /** * The quantity of the product or variant associated with the line item. */ quantity: string | null; /** * The unit price of the product or variant associated with the line item. */ unitPrice?: string | null | undefined; /** * The tax rate applied to the product or variant associated with the line item. */ taxRate?: string | null | undefined; /** * The total tax amount applied to the product or variant associated with the line item. */ taxAmount?: string | null | undefined; /** * Whether the line item has been refunded. */ isRefunded?: boolean | null | undefined; /** * The amount of the line item that has been refunded. */ refundedAmount?: string | null | undefined; /** * The quantity of the line item that has been refunded. */ refundedQuantity?: string | null | undefined; /** * The sub total for the product(s) or variant associated with the line item, excluding taxes and discounts. */ subTotal?: string | null | undefined; /** * The total amount for the product(s) or variant associated with the line item, including taxes and discounts. */ totalAmount?: string | null | undefined; discounts?: Array | undefined; }; /** @internal */ export const Options$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), name: z.nullable(types.string()).optional(), value: z.nullable(types.string()).optional(), }) ); export function optionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Options$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Options' from JSON`, ); } /** @internal */ export const EcommerceOrderLineItem$inboundSchema: z.ZodType< EcommerceOrderLineItem, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), product_id: z.nullable(types.string()).optional(), variant_id: z.nullable(types.string()).optional(), sku: z.nullable(types.string()).optional(), name: z.nullable(types.string()).optional(), description: z.nullable(types.string()).optional(), options: types.optional(z.array(z.lazy(() => Options$inboundSchema))), quantity: types.nullable(types.string()), unit_price: z.nullable(types.string()).optional(), tax_rate: z.nullable(types.string()).optional(), tax_amount: z.nullable(types.string()).optional(), is_refunded: z.nullable(types.boolean()).optional(), refunded_amount: z.nullable(types.string()).optional(), refunded_quantity: z.nullable(types.string()).optional(), sub_total: z.nullable(types.string()).optional(), total_amount: z.nullable(types.string()).optional(), discounts: types.optional(z.array(EcommerceDiscount$inboundSchema)), }).transform((v) => { return remap$(v, { "product_id": "productId", "variant_id": "variantId", "unit_price": "unitPrice", "tax_rate": "taxRate", "tax_amount": "taxAmount", "is_refunded": "isRefunded", "refunded_amount": "refundedAmount", "refunded_quantity": "refundedQuantity", "sub_total": "subTotal", "total_amount": "totalAmount", }); }) ); export function ecommerceOrderLineItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EcommerceOrderLineItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EcommerceOrderLineItem' from JSON`, ); }