/*
* 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";
/**
* Secured funds include money orders, certified cheques and others (see
*
* @remarks
* UPS for details).
* If no payment_method inputted the value defaults to "ANY".)
*/
export const PaymentMethod = {
SecuredFunds: "SECURED_FUNDS",
Cash: "CASH",
Any: "ANY",
} as const;
/**
* Secured funds include money orders, certified cheques and others (see
*
* @remarks
* UPS for details).
* If no payment_method inputted the value defaults to "ANY".)
*/
export type PaymentMethod = ClosedEnum;
/**
* Specify collection on delivery details (UPS only).
*/
export type Cod = {
/**
* Amount to be collected.
*/
amount?: string | undefined;
/**
* Currency for the amount to be collected. Currently only USD is supported for UPS.
*/
currency?: string | undefined;
/**
* Secured funds include money orders, certified cheques and others (see
*
* @remarks
* UPS for details).
* If no payment_method inputted the value defaults to "ANY".)
*/
paymentMethod?: PaymentMethod | undefined;
};
/** @internal */
export const PaymentMethod$inboundSchema: z.ZodMiniEnum =
z.enum(PaymentMethod);
/** @internal */
export const PaymentMethod$outboundSchema: z.ZodMiniEnum =
PaymentMethod$inboundSchema;
/** @internal */
export const Cod$inboundSchema: z.ZodMiniType = z.pipe(
z.object({
amount: z.optional(z.string()),
currency: z.optional(z.string()),
payment_method: z.optional(PaymentMethod$inboundSchema),
}),
z.transform((v) => {
return remap$(v, {
"payment_method": "paymentMethod",
});
}),
);
/** @internal */
export type Cod$Outbound = {
amount?: string | undefined;
currency?: string | undefined;
payment_method?: string | undefined;
};
/** @internal */
export const Cod$outboundSchema: z.ZodMiniType = z.pipe(
z.object({
amount: z.optional(z.string()),
currency: z.optional(z.string()),
paymentMethod: z.optional(PaymentMethod$outboundSchema),
}),
z.transform((v) => {
return remap$(v, {
paymentMethod: "payment_method",
});
}),
);
export function codToJSON(cod: Cod): string {
return JSON.stringify(Cod$outboundSchema.parse(cod));
}
export function codFromJSON(
jsonString: string,
): SafeParseResult {
return safeParse(
jsonString,
(x) => Cod$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Cod' from JSON`,
);
}