/* * 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"; import { Currency, Currency$inboundSchema } from "./currency.js"; import { EcommerceAddress, EcommerceAddress$inboundSchema, } from "./ecommerceaddress.js"; import { EcommerceDiscount, EcommerceDiscount$inboundSchema, } from "./ecommercediscount.js"; import { EcommerceOrderLineItem, EcommerceOrderLineItem$inboundSchema, } from "./ecommerceorderlineitem.js"; import { EcommerceOrderRefund, EcommerceOrderRefund$inboundSchema, } from "./ecommerceorderrefund.js"; import { EcommerceOrderStatus, EcommerceOrderStatus$inboundSchema, } from "./ecommerceorderstatus.js"; import { LinkedEcommerceCustomer, LinkedEcommerceCustomer$inboundSchema, } from "./linkedecommercecustomer.js"; import { TrackingItem, TrackingItem$inboundSchema } from "./trackingitem.js"; /** * Current payment status of the order. */ export const EcommerceOrderPaymentStatus = { Pending: "pending", Authorized: "authorized", Paid: "paid", Partial: "partial", Refunded: "refunded", Voided: "voided", Unknown: "unknown", PartiallyRefunded: "partially_refunded", } as const; /** * Current payment status of the order. */ export type EcommerceOrderPaymentStatus = OpenEnum< typeof EcommerceOrderPaymentStatus >; /** * Current fulfillment status of the order. */ export const FulfillmentStatus = { Pending: "pending", Shipped: "shipped", Partial: "partial", Delivered: "delivered", Cancelled: "cancelled", Returned: "returned", Unknown: "unknown", } as const; /** * Current fulfillment status of the order. */ export type FulfillmentStatus = OpenEnum; export type EcommerceOrder = { /** * A unique identifier for an object. */ id: string; /** * Order number, if any. */ orderNumber?: string | null | undefined; /** * Indicates the associated currency for an amount of money. Values correspond to [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217). */ currency?: Currency | null | undefined; discounts?: Array | undefined; /** * Sub-total amount, normally before tax. */ subTotal?: string | null | undefined; /** * Shipping cost, if any. */ shippingCost?: string | null | undefined; /** * Coupon discount, if any. */ couponDiscount?: string | null | undefined; /** * Total discount, if any. */ totalDiscount?: string | null | undefined; /** * Total tax, if any. */ totalTax?: string | null | undefined; /** * Total amount due. */ totalAmount?: string | null | undefined; /** * Refunded amount, if any. */ refundedAmount?: string | null | undefined; /** * Indicates whether the order's monetary amounts are inclusive of tax. */ taxInclusive?: boolean | null | undefined; /** * Current status of the order. */ status?: EcommerceOrderStatus | null | undefined; /** * Current payment status of the order. */ paymentStatus?: EcommerceOrderPaymentStatus | null | undefined; /** * Current fulfillment status of the order. */ fulfillmentStatus?: FulfillmentStatus | null | undefined; /** * Payment method used for this order. */ paymentMethod?: string | null | undefined; /** * The customer this entity is linked to. */ customer?: LinkedEcommerceCustomer | undefined; /** * An object representing a shipping or billing address. */ billingAddress?: EcommerceAddress | undefined; /** * An object representing a shipping or billing address. */ shippingAddress?: EcommerceAddress | undefined; tracking?: Array | undefined; lineItems?: Array | undefined; /** * Note for the order. */ note?: string | null | undefined; refunds?: 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 EcommerceOrderPaymentStatus$inboundSchema: z.ZodType< EcommerceOrderPaymentStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(EcommerceOrderPaymentStatus) ); /** @internal */ export const FulfillmentStatus$inboundSchema: z.ZodType< FulfillmentStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(FulfillmentStatus) ); /** @internal */ export const EcommerceOrder$inboundSchema: z.ZodType< EcommerceOrder, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), order_number: z.nullable(types.string()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), discounts: types.optional(z.array(EcommerceDiscount$inboundSchema)), sub_total: z.nullable(types.string()).optional(), shipping_cost: z.nullable(types.string()).optional(), coupon_discount: z.nullable(types.string()).optional(), total_discount: z.nullable(types.string()).optional(), total_tax: z.nullable(types.string()).optional(), total_amount: z.nullable(types.string()).optional(), refunded_amount: z.nullable(types.string()).optional(), tax_inclusive: z.nullable(types.boolean()).optional(), status: z.nullable(EcommerceOrderStatus$inboundSchema).optional(), payment_status: z.nullable(EcommerceOrderPaymentStatus$inboundSchema) .optional(), fulfillment_status: z.nullable(FulfillmentStatus$inboundSchema).optional(), payment_method: z.nullable(types.string()).optional(), customer: types.optional(LinkedEcommerceCustomer$inboundSchema), billing_address: types.optional(EcommerceAddress$inboundSchema), shipping_address: types.optional(EcommerceAddress$inboundSchema), tracking: types.optional(z.array(TrackingItem$inboundSchema)), line_items: types.optional(z.array(EcommerceOrderLineItem$inboundSchema)), note: z.nullable(types.string()).optional(), refunds: types.optional(z.array(EcommerceOrderRefund$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, { "order_number": "orderNumber", "sub_total": "subTotal", "shipping_cost": "shippingCost", "coupon_discount": "couponDiscount", "total_discount": "totalDiscount", "total_tax": "totalTax", "total_amount": "totalAmount", "refunded_amount": "refundedAmount", "tax_inclusive": "taxInclusive", "payment_status": "paymentStatus", "fulfillment_status": "fulfillmentStatus", "payment_method": "paymentMethod", "billing_address": "billingAddress", "shipping_address": "shippingAddress", "line_items": "lineItems", "custom_mappings": "customMappings", "created_at": "createdAt", "updated_at": "updatedAt", }); }) ); export function ecommerceOrderFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EcommerceOrder$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EcommerceOrder' from JSON`, ); }