/* * 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 { BatchShipmentPaginatedList, BatchShipmentPaginatedList$inboundSchema, } from "./batchshipmentpaginatedlist.js"; import { LabelFileTypeEnum, LabelFileTypeEnum$inboundSchema, } from "./labelfiletypeenum.js"; /** * An object containing the following counts:
`creation_succeeded`
`creation_failed`
`purchase_succeeded`
`purchase_failed` */ export type ObjectResults = { creationFailed: number; creationSucceeded: number; purchaseFailed: number; purchaseSucceeded: number; }; /** * Batches that are `VALIDATING` are being created and validated
* * @remarks * `VALID` batches can be purchased
* `INVALID` batches cannot be purchased, `INVALID` BatchShipments must be removed
* Batches that are in the `PURCHASING` state are being purchased
* `PURCHASED` batches are finished purchasing. */ export const BatchStatus = { Validating: "VALIDATING", Valid: "VALID", Invalid: "INVALID", Purchasing: "PURCHASING", Purchased: "PURCHASED", } as const; /** * Batches that are `VALIDATING` are being created and validated
* * @remarks * `VALID` batches can be purchased
* `INVALID` batches cannot be purchased, `INVALID` BatchShipments must be removed
* Batches that are in the `PURCHASING` state are being purchased
* `PURCHASED` batches are finished purchasing. */ export type BatchStatus = ClosedEnum; export type Batch = { /** * ID of the Carrier Account object to use as the default for all shipments in this Batch. * * @remarks * The carrier account can be changed on a per-shipment basis by changing the carrier_account in the * corresponding BatchShipment object. */ defaultCarrierAccount: string; /** * Token of the service level to use as the default for all shipments in this Batch. * * @remarks * The servicelevel can be changed on a per-shipment basis by changing the servicelevel_token in the * corresponding BatchShipment object. Servicelevel tokens can be found here. */ defaultServicelevelToken: string; /** * Print format of the label. If empty, will use the default format set from * * @remarks * the Shippo dashboard. */ labelFiletype?: LabelFileTypeEnum | undefined; /** * A string of up to 100 characters that can be filled with any additional information you want to attach to the object. */ metadata?: string | undefined; batchShipments: BatchShipmentPaginatedList; /** * An array of URLs each pointing to a merged file of 100 labels each */ labelUrl: Array; /** * Date and time of Batch creation */ objectCreated: string; /** * Unique identifier of the given Batch object */ objectId: string; /** * Username of the user who created the Batch object. */ objectOwner: string; /** * An object containing the following counts:
`creation_succeeded`
`creation_failed`
`purchase_succeeded`
`purchase_failed` */ objectResults: ObjectResults; /** * Date and time of last update to the Batch */ objectUpdated: string; /** * Batches that are `VALIDATING` are being created and validated
* * @remarks * `VALID` batches can be purchased
* `INVALID` batches cannot be purchased, `INVALID` BatchShipments must be removed
* Batches that are in the `PURCHASING` state are being purchased
* `PURCHASED` batches are finished purchasing. */ status: BatchStatus; test?: boolean | undefined; }; /** @internal */ export const ObjectResults$inboundSchema: z.ZodMiniType< ObjectResults, unknown > = z.pipe( z.object({ creation_failed: z.int(), creation_succeeded: z.int(), purchase_failed: z.int(), purchase_succeeded: z.int(), }), z.transform((v) => { return remap$(v, { "creation_failed": "creationFailed", "creation_succeeded": "creationSucceeded", "purchase_failed": "purchaseFailed", "purchase_succeeded": "purchaseSucceeded", }); }), ); export function objectResultsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ObjectResults$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ObjectResults' from JSON`, ); } /** @internal */ export const BatchStatus$inboundSchema: z.ZodMiniEnum = z .enum(BatchStatus); /** @internal */ export const Batch$inboundSchema: z.ZodMiniType = z.pipe( z.object({ default_carrier_account: z.string(), default_servicelevel_token: z.string(), label_filetype: z.optional(LabelFileTypeEnum$inboundSchema), metadata: z.optional(z.string()), batch_shipments: BatchShipmentPaginatedList$inboundSchema, label_url: z.array(z.string()), object_created: z.string(), object_id: z.string(), object_owner: z.string(), object_results: z.lazy(() => ObjectResults$inboundSchema), object_updated: z.string(), status: BatchStatus$inboundSchema, test: z.optional(z.boolean()), }), z.transform((v) => { return remap$(v, { "default_carrier_account": "defaultCarrierAccount", "default_servicelevel_token": "defaultServicelevelToken", "label_filetype": "labelFiletype", "batch_shipments": "batchShipments", "label_url": "labelUrl", "object_created": "objectCreated", "object_id": "objectId", "object_owner": "objectOwner", "object_results": "objectResults", "object_updated": "objectUpdated", }); }), ); export function batchFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Batch$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Batch' from JSON`, ); }