/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { remap as remap$ } from "../../lib/primitives.js"; import { AddressCreateRequest, AddressCreateRequest$Outbound, AddressCreateRequest$outboundSchema, } from "./addresscreaterequest.js"; import { LineItemBase, LineItemBase$Outbound, LineItemBase$outboundSchema, } from "./lineitembase.js"; import { OrderStatusEnum, OrderStatusEnum$outboundSchema, } from "./orderstatusenum.js"; import { WeightUnitEnum, WeightUnitEnum$outboundSchema, } from "./weightunitenum.js"; export type OrderCreateRequest = { /** * **Required if total_price is provided**
* * @remarks * Currency of the total_price and total_tax amounts. */ currency?: string | undefined; /** * Custom buyer- or seller-provided notes about the order. */ notes?: string | undefined; /** * An alphanumeric identifier for the order used by the seller/buyer. This identifier doesn't need to be unique. */ orderNumber?: string | undefined; /** * Current state of the order. See the orders tutorial * * @remarks * for the logic of how the status is handled. */ orderStatus?: OrderStatusEnum | undefined; /** * Date and time when the order was placed. This datetime can be different from the datetime of the order object creation on Shippo. */ placedAt: string; /** * Amount paid by the buyer for shipping. This amount can be different from the price the seller will actually pay for shipping. */ shippingCost?: string | undefined; /** * **Required if shipping_cost is provided**
* * @remarks * Currency of the shipping_cost amount. */ shippingCostCurrency?: string | undefined; /** * Shipping method (carrier + service or other free text description) chosen by the buyer. * * @remarks * This value can be different from the shipping method the seller will actually choose. */ shippingMethod?: string | undefined; subtotalPrice?: string | undefined; /** * Total amount paid by the buyer for this order. */ totalPrice?: string | undefined; /** * Total tax amount paid by the buyer for this order. */ totalTax?: string | undefined; /** * Total weight of the order. */ weight?: string | undefined; /** * The unit used for weight. */ weightUnit?: WeightUnitEnum | undefined; /** * Address object of the sender / seller. Will be returned expanded by default.. */ fromAddress?: AddressCreateRequest | undefined; /** * Address object of the recipient / buyer. Will be returned expanded by default. */ toAddress: AddressCreateRequest; /** * Array of line item objects representing the items in this order. * * @remarks * All objects will be returned expanded by default. */ lineItems?: Array | undefined; }; /** @internal */ export type OrderCreateRequest$Outbound = { currency?: string | undefined; notes?: string | undefined; order_number?: string | undefined; order_status?: string | undefined; placed_at: string; shipping_cost?: string | undefined; shipping_cost_currency?: string | undefined; shipping_method?: string | undefined; subtotal_price?: string | undefined; total_price?: string | undefined; total_tax?: string | undefined; weight?: string | undefined; weight_unit?: string | undefined; from_address?: AddressCreateRequest$Outbound | undefined; to_address: AddressCreateRequest$Outbound; line_items?: Array | undefined; }; /** @internal */ export const OrderCreateRequest$outboundSchema: z.ZodMiniType< OrderCreateRequest$Outbound, OrderCreateRequest > = z.pipe( z.object({ currency: z.optional(z.string()), notes: z.optional(z.string()), orderNumber: z.optional(z.string()), orderStatus: z.optional(OrderStatusEnum$outboundSchema), placedAt: z.string(), shippingCost: z.optional(z.string()), shippingCostCurrency: z.optional(z.string()), shippingMethod: z.optional(z.string()), subtotalPrice: z.optional(z.string()), totalPrice: z.optional(z.string()), totalTax: z.optional(z.string()), weight: z.optional(z.string()), weightUnit: z.optional(WeightUnitEnum$outboundSchema), fromAddress: z.optional(AddressCreateRequest$outboundSchema), toAddress: AddressCreateRequest$outboundSchema, lineItems: z.optional(z.array(LineItemBase$outboundSchema)), }), z.transform((v) => { return remap$(v, { orderNumber: "order_number", orderStatus: "order_status", placedAt: "placed_at", shippingCost: "shipping_cost", shippingCostCurrency: "shipping_cost_currency", shippingMethod: "shipping_method", subtotalPrice: "subtotal_price", totalPrice: "total_price", totalTax: "total_tax", weightUnit: "weight_unit", fromAddress: "from_address", toAddress: "to_address", lineItems: "line_items", }); }), ); export function orderCreateRequestToJSON( orderCreateRequest: OrderCreateRequest, ): string { return JSON.stringify( OrderCreateRequest$outboundSchema.parse(orderCreateRequest), ); }