/*
* 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 {
AddressCreateRequest,
AddressCreateRequest$Outbound,
AddressCreateRequest$outboundSchema,
} from "./addresscreaterequest.js";
import {
CustomsDeclarationCreateRequest,
CustomsDeclarationCreateRequest$Outbound,
CustomsDeclarationCreateRequest$outboundSchema,
} from "./customsdeclarationcreaterequest.js";
import {
ParcelCreateFromTemplateRequest,
ParcelCreateFromTemplateRequest$Outbound,
ParcelCreateFromTemplateRequest$outboundSchema,
} from "./parcelcreatefromtemplaterequest.js";
import {
ParcelCreateRequest,
ParcelCreateRequest$Outbound,
ParcelCreateRequest$outboundSchema,
} from "./parcelcreaterequest.js";
import {
ShipmentExtra,
ShipmentExtra$Outbound,
ShipmentExtra$outboundSchema,
} from "./shipmentextra.js";
export type AddressFrom = AddressCreateRequest | string;
export type AddressReturn = AddressCreateRequest | string;
export type AddressTo = AddressCreateRequest | string;
export type ShipmentCreateRequestCustomsDeclaration =
| CustomsDeclarationCreateRequest
| string;
export type Parcels =
| ParcelCreateRequest
| ParcelCreateFromTemplateRequest
| string;
export type ShipmentCreateRequest = {
/**
* An object holding optional extra services to be requested.
*/
extra?: ShipmentExtra | 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;
/**
* Date the shipment will be tendered to the carrier. Must be in the format `2014-01-18T00:35:03.463Z`.
*
* @remarks
* Defaults to current date and time if no value is provided. Please note that some carriers require this value to
* be in the future, on a working day, or similar.
*/
shipmentDate?: string | undefined;
addressFrom: AddressCreateRequest | string;
addressReturn?: AddressCreateRequest | string | undefined;
addressTo: AddressCreateRequest | string;
customsDeclaration?: CustomsDeclarationCreateRequest | string | undefined;
async?: boolean | undefined;
/**
* List of Carrier Accounts `object_id`s used to filter
*
* @remarks
* the returned rates. If set, only rates from these carriers will be returned.
*/
carrierAccounts?: Array | undefined;
parcels: Array<
ParcelCreateRequest | ParcelCreateFromTemplateRequest | string
>;
};
/** @internal */
export type AddressFrom$Outbound = AddressCreateRequest$Outbound | string;
/** @internal */
export const AddressFrom$outboundSchema: z.ZodMiniType<
AddressFrom$Outbound,
AddressFrom
> = z.union([AddressCreateRequest$outboundSchema, z.string()]);
export function addressFromToJSON(addressFrom: AddressFrom): string {
return JSON.stringify(AddressFrom$outboundSchema.parse(addressFrom));
}
/** @internal */
export type AddressReturn$Outbound = AddressCreateRequest$Outbound | string;
/** @internal */
export const AddressReturn$outboundSchema: z.ZodMiniType<
AddressReturn$Outbound,
AddressReturn
> = z.union([AddressCreateRequest$outboundSchema, z.string()]);
export function addressReturnToJSON(addressReturn: AddressReturn): string {
return JSON.stringify(AddressReturn$outboundSchema.parse(addressReturn));
}
/** @internal */
export type AddressTo$Outbound = AddressCreateRequest$Outbound | string;
/** @internal */
export const AddressTo$outboundSchema: z.ZodMiniType<
AddressTo$Outbound,
AddressTo
> = z.union([AddressCreateRequest$outboundSchema, z.string()]);
export function addressToToJSON(addressTo: AddressTo): string {
return JSON.stringify(AddressTo$outboundSchema.parse(addressTo));
}
/** @internal */
export type ShipmentCreateRequestCustomsDeclaration$Outbound =
| CustomsDeclarationCreateRequest$Outbound
| string;
/** @internal */
export const ShipmentCreateRequestCustomsDeclaration$outboundSchema:
z.ZodMiniType<
ShipmentCreateRequestCustomsDeclaration$Outbound,
ShipmentCreateRequestCustomsDeclaration
> = z.union([CustomsDeclarationCreateRequest$outboundSchema, z.string()]);
export function shipmentCreateRequestCustomsDeclarationToJSON(
shipmentCreateRequestCustomsDeclaration:
ShipmentCreateRequestCustomsDeclaration,
): string {
return JSON.stringify(
ShipmentCreateRequestCustomsDeclaration$outboundSchema.parse(
shipmentCreateRequestCustomsDeclaration,
),
);
}
/** @internal */
export type Parcels$Outbound =
| ParcelCreateRequest$Outbound
| ParcelCreateFromTemplateRequest$Outbound
| string;
/** @internal */
export const Parcels$outboundSchema: z.ZodMiniType =
z.union([
ParcelCreateRequest$outboundSchema,
ParcelCreateFromTemplateRequest$outboundSchema,
z.string(),
]);
export function parcelsToJSON(parcels: Parcels): string {
return JSON.stringify(Parcels$outboundSchema.parse(parcels));
}
/** @internal */
export type ShipmentCreateRequest$Outbound = {
extra?: ShipmentExtra$Outbound | undefined;
metadata?: string | undefined;
shipment_date?: string | undefined;
address_from: AddressCreateRequest$Outbound | string;
address_return?: AddressCreateRequest$Outbound | string | undefined;
address_to: AddressCreateRequest$Outbound | string;
customs_declaration?:
| CustomsDeclarationCreateRequest$Outbound
| string
| undefined;
async?: boolean | undefined;
carrier_accounts?: Array | undefined;
parcels: Array<
| ParcelCreateRequest$Outbound
| ParcelCreateFromTemplateRequest$Outbound
| string
>;
};
/** @internal */
export const ShipmentCreateRequest$outboundSchema: z.ZodMiniType<
ShipmentCreateRequest$Outbound,
ShipmentCreateRequest
> = z.pipe(
z.object({
extra: z.optional(ShipmentExtra$outboundSchema),
metadata: z.optional(z.string()),
shipmentDate: z.optional(z.string()),
addressFrom: z.union([AddressCreateRequest$outboundSchema, z.string()]),
addressReturn: z.optional(
z.union([AddressCreateRequest$outboundSchema, z.string()]),
),
addressTo: z.union([AddressCreateRequest$outboundSchema, z.string()]),
customsDeclaration: z.optional(
z.union([CustomsDeclarationCreateRequest$outboundSchema, z.string()]),
),
async: z.optional(z.boolean()),
carrierAccounts: z.optional(z.array(z.string())),
parcels: z.array(
z.union([
ParcelCreateRequest$outboundSchema,
ParcelCreateFromTemplateRequest$outboundSchema,
z.string(),
]),
),
}),
z.transform((v) => {
return remap$(v, {
shipmentDate: "shipment_date",
addressFrom: "address_from",
addressReturn: "address_return",
addressTo: "address_to",
customsDeclaration: "customs_declaration",
carrierAccounts: "carrier_accounts",
});
}),
);
export function shipmentCreateRequestToJSON(
shipmentCreateRequest: ShipmentCreateRequest,
): string {
return JSON.stringify(
ShipmentCreateRequest$outboundSchema.parse(shipmentCreateRequest),
);
}