/* * 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 { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { WeightUnitEnum, WeightUnitEnum$inboundSchema, WeightUnitEnum$outboundSchema, } from "./weightunitenum.js"; export type LineItem = { /** * Currency of the total_price amount. */ currency?: string | undefined; /** * Country the item was manufactured in. In the Shippo dashboard, this value will be used ot pre-fill the customs declaration when creating a label for this order. */ manufactureCountry?: string | undefined; /** * The date and time this item needs to be delivered by, i.e. by when the carrier delivers it to the buyer. * * @remarks * This value is used by some platforms such as eBay to measure a seller's shipping time and performance. * It will be displayed in the Shippo dashboard. */ maxDeliveryTime?: Date | undefined; /** * The date and time this item needs to be fulfilled by, i.e. by when the shipping label needs to be * * @remarks * created and handed over to the carrier. This value is used by some platforms such as eBay to measure * a seller's handling time and performance. It will be displayed in the Shippo dashboard. */ maxShipTime?: Date | undefined; /** * The quantity of this item in this order. */ quantity?: number | undefined; /** * The stock keeping unit value of this item. */ sku?: string | undefined; /** * Title of the line item. */ title?: string | undefined; /** * Total price paid by the buyer for this item (or these items, if quantity > 1). */ totalPrice?: string | undefined; /** * A variant is a specific variation of an item (e.g. `size M` or `color blue`). * * @remarks * Variants might be exposed as a separate resource in the future too. * Currently the variant title is a free text field describing the variant. */ variantTitle?: string | undefined; /** * Total weight of this/these item(s). Instead of specifying the weight of all items, * * @remarks * you can also set the total_weight value of the order object. */ weight?: string | undefined; /** * The unit used for weight. */ weightUnit?: WeightUnitEnum | undefined; /** * Unique identifier of the line item object. */ objectId?: string | undefined; }; /** @internal */ export const LineItem$inboundSchema: z.ZodMiniType = z.pipe( z.object({ currency: z.optional(z.string()), manufacture_country: z.optional(z.string()), max_delivery_time: z.optional( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), max_ship_time: z.optional( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), quantity: z.optional(z.int()), sku: z.optional(z.string()), title: z.optional(z.string()), total_price: z.optional(z.string()), variant_title: z.optional(z.string()), weight: z.optional(z.string()), weight_unit: z.optional(WeightUnitEnum$inboundSchema), object_id: z.optional(z.string()), }), z.transform((v) => { return remap$(v, { "manufacture_country": "manufactureCountry", "max_delivery_time": "maxDeliveryTime", "max_ship_time": "maxShipTime", "total_price": "totalPrice", "variant_title": "variantTitle", "weight_unit": "weightUnit", "object_id": "objectId", }); }), ); /** @internal */ export type LineItem$Outbound = { currency?: string | undefined; manufacture_country?: string | undefined; max_delivery_time?: string | undefined; max_ship_time?: string | undefined; quantity?: number | undefined; sku?: string | undefined; title?: string | undefined; total_price?: string | undefined; variant_title?: string | undefined; weight?: string | undefined; weight_unit?: string | undefined; object_id?: string | undefined; }; /** @internal */ export const LineItem$outboundSchema: z.ZodMiniType< LineItem$Outbound, LineItem > = z.pipe( z.object({ currency: z.optional(z.string()), manufactureCountry: z.optional(z.string()), maxDeliveryTime: z.optional( z.pipe(z.date(), z.transform(v => v.toISOString())), ), maxShipTime: z.optional( z.pipe(z.date(), z.transform(v => v.toISOString())), ), quantity: z.optional(z.int()), sku: z.optional(z.string()), title: z.optional(z.string()), totalPrice: z.optional(z.string()), variantTitle: z.optional(z.string()), weight: z.optional(z.string()), weightUnit: z.optional(WeightUnitEnum$outboundSchema), objectId: z.optional(z.string()), }), z.transform((v) => { return remap$(v, { manufactureCountry: "manufacture_country", maxDeliveryTime: "max_delivery_time", maxShipTime: "max_ship_time", totalPrice: "total_price", variantTitle: "variant_title", weightUnit: "weight_unit", objectId: "object_id", }); }), ); export function lineItemToJSON(lineItem: LineItem): string { return JSON.stringify(LineItem$outboundSchema.parse(lineItem)); } export function lineItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LineItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LineItem' from JSON`, ); }