/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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"; /** * Represents the tracking information associated with an ecommerce order. */ export type TrackingItem = { /** * The name or code of the carrier or shipping company that is handling the shipment. */ provider: string | null; /** * The tracking number associated with the shipment, which can be used to track the progress of the delivery. */ number: string | null; /** * The URL of the carrier's tracking page, which can be used to view detailed information about the shipment's progress. */ url?: string | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; }; /** @internal */ export const TrackingItem$inboundSchema: z.ZodType< TrackingItem, z.ZodTypeDef, unknown > = z.object({ provider: z.nullable(z.string()), number: z.nullable(z.string()), url: z.nullable(z.string()).optional(), updated_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "updated_at": "updatedAt", }); }); /** @internal */ export type TrackingItem$Outbound = { provider: string | null; number: string | null; url?: string | null | undefined; updated_at?: string | null | undefined; }; /** @internal */ export const TrackingItem$outboundSchema: z.ZodType< TrackingItem$Outbound, z.ZodTypeDef, TrackingItem > = z.object({ provider: z.nullable(z.string()), number: z.nullable(z.string()), url: z.nullable(z.string()).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), }).transform((v) => { return remap$(v, { updatedAt: "updated_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TrackingItem$ { /** @deprecated use `TrackingItem$inboundSchema` instead. */ export const inboundSchema = TrackingItem$inboundSchema; /** @deprecated use `TrackingItem$outboundSchema` instead. */ export const outboundSchema = TrackingItem$outboundSchema; /** @deprecated use `TrackingItem$Outbound` instead. */ export type Outbound = TrackingItem$Outbound; } export function trackingItemToJSON(trackingItem: TrackingItem): string { return JSON.stringify(TrackingItem$outboundSchema.parse(trackingItem)); } export function trackingItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TrackingItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TrackingItem' from JSON`, ); }