/* * 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 { CarrierParcelTemplate, CarrierParcelTemplate$inboundSchema, } from "./carrierparceltemplate.js"; import { DistanceUnitEnum, DistanceUnitEnum$inboundSchema, } from "./distanceunitenum.js"; import { WeightUnitEnum, WeightUnitEnum$inboundSchema, } from "./weightunitenum.js"; export type UserParcelTemplate = { /** * The measure unit used for length, width and height. */ distanceUnit?: DistanceUnitEnum | undefined; /** * The height of the package, in units specified by the `distance_unit` attribute. Required, but if using a preset carrier template then this field must be empty. */ height?: string | undefined; /** * The length of the package, in units specified by the `distance_unit` attribute. Required, but if using a preset carrier template then this field must be empty. */ length?: string | undefined; /** * The name of the User Parcel Template */ name?: string | undefined; /** * The weight of the package, in units specified by the weight_unit attribute. */ weight?: string | undefined; /** * The unit used for weight. */ weightUnit?: WeightUnitEnum | undefined; /** * The width of the package, in units specified by the `distance_unit` attribute. Required, but if using a preset carrier template then this field must be empty. */ width?: string | undefined; /** * Date and time of User Parcel Template creation */ objectCreated?: Date | undefined; /** * Unique identifier of the given User Parcel Template object */ objectId?: string | undefined; /** * Username of the user who created the User Parcel Template object */ objectOwner?: string | undefined; /** * Date and time of last update on User Parcel Template */ objectUpdated?: Date | undefined; template?: CarrierParcelTemplate | undefined; }; /** @internal */ export const UserParcelTemplate$inboundSchema: z.ZodMiniType< UserParcelTemplate, unknown > = z.pipe( z.object({ distance_unit: z.optional(DistanceUnitEnum$inboundSchema), height: z.optional(z.string()), length: z.optional(z.string()), name: z.optional(z.string()), weight: z.optional(z.string()), weight_unit: z.optional(WeightUnitEnum$inboundSchema), width: z.optional(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_owner: z.optional(z.string()), object_updated: z.optional( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), template: z.optional(CarrierParcelTemplate$inboundSchema), }), z.transform((v) => { return remap$(v, { "distance_unit": "distanceUnit", "weight_unit": "weightUnit", "object_created": "objectCreated", "object_id": "objectId", "object_owner": "objectOwner", "object_updated": "objectUpdated", }); }), ); export function userParcelTemplateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UserParcelTemplate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UserParcelTemplate' from JSON`, ); }