/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Location, Location$inboundSchema } from "./location.js"; /** * Indicates the status of the pickup. */ export const PickupStatus = { Pending: "PENDING", Confirmed: "CONFIRMED", Error: "ERROR", Cancelled: "CANCELLED", } as const; /** * Indicates the status of the pickup. */ export type PickupStatus = ClosedEnum; export type Pickup = { /** * The object ID of your USPS or DHL Express carrier account. * * @remarks * You can retrieve this from your Rate requests or our Carrier Accounts endpoint. */ carrierAccount: string; /** * Location where the parcel(s) will be picked up. */ location: Location; /** * A string of up to 100 characters that can be filled with any additional information you * * @remarks * want to attach to the object. */ metadata?: string | undefined; /** * The latest that you requested your parcels to be available for pickup. * * @remarks * Expressed in the timezone specified in the response. */ requestedEndTime: Date; /** * The earliest that you requested your parcels to be ready for pickup. * * @remarks * Expressed in the timezone specified in the response. */ requestedStartTime: Date; /** * The transaction(s) object ID(s) for the parcel(s) that need to be picked up. */ transactions: Array; /** * Date and time of Pickup creation. */ objectCreated?: Date | undefined; /** * Unique identifier of the given Pickup object. */ objectId?: string | undefined; /** * Date and time of last Pickup update. */ objectUpdated?: Date | undefined; /** * The earliest that your parcels will be ready for pickup, confirmed by the carrier. * * @remarks * Expressed in the timezone specified in the response. */ confirmedStartTime?: string | undefined; /** * The latest that your parcels will be available for pickup, confirmed by the carrier. * * @remarks * Expressed in the timezone specified in the response. */ confirmedEndTime?: string | undefined; /** * The latest time to cancel a pickup. Expressed in the timezone specified in the response. * * @remarks * To cancel a pickup, you will need to contact the carrier directly. * The ability to cancel a pickup through Shippo may be released in future iterations. */ cancelByTime?: string | undefined; /** * Indicates the status of the pickup. */ status?: PickupStatus | undefined; /** * Pickup's confirmation code returned by the carrier. * * @remarks * To edit or cancel a pickup, you will need to contact USPS or DHL Express directly and provide your `confirmation_code`. */ confirmationCode?: string | undefined; /** * The pickup time windows will be in the time zone specified here, not UTC. */ timezone?: string | undefined; /** * An array containing strings of any messages generated during validation. */ messages?: Array | undefined; /** * Indicates whether the object has been created in test mode. */ isTest?: boolean | undefined; }; /** @internal */ export const PickupStatus$inboundSchema: z.ZodMiniEnum = z .enum(PickupStatus); /** @internal */ export const Pickup$inboundSchema: z.ZodMiniType = z.pipe( z.object({ carrier_account: z.string(), location: Location$inboundSchema, metadata: z.optional(z.string()), requested_end_time: z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), ), requested_start_time: z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), ), transactions: z.array(z.string()), object_created: z.optional( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), object_id: z.optional(z.string()), object_updated: z.optional( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), confirmed_start_time: z.optional(z.string()), confirmed_end_time: z.optional(z.string()), cancel_by_time: z.optional(z.string()), status: z.optional(PickupStatus$inboundSchema), confirmation_code: z.optional(z.string()), timezone: z.optional(z.string()), messages: z.optional(z.array(z.string())), is_test: z.optional(z.boolean()), }), z.transform((v) => { return remap$(v, { "carrier_account": "carrierAccount", "requested_end_time": "requestedEndTime", "requested_start_time": "requestedStartTime", "object_created": "objectCreated", "object_id": "objectId", "object_updated": "objectUpdated", "confirmed_start_time": "confirmedStartTime", "confirmed_end_time": "confirmedEndTime", "cancel_by_time": "cancelByTime", "confirmation_code": "confirmationCode", "is_test": "isTest", }); }), ); export function pickupFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Pickup$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Pickup' from JSON`, ); }