/*
* 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";
export type LiveRate = {
/**
* Final Rate price, expressed in the currency used in the sender's country.
*/
amount?: string | undefined;
/**
* Final Rate price, expressed in the currency used in the recipient's country.
*/
amountLocal?: string | undefined;
/**
* Currency used in the sender's country, refers to `amount`.
*
* @remarks
* The official ISO 4217 currency codes are used, e.g. `USD` or `EUR`.
*/
currency?: string | undefined;
/**
* Currency used in the recipient's country, refers to `amount_local`.
*
* @remarks
* The official ISO 4217 currency codes are used, e.g. `USD` or "EUR".
*/
currencyLocal?: string | undefined;
/**
* The estimated days in transit of the rate that powers the shipping option, if available.
*/
estimatedDays?: number | undefined;
/**
* The name of the service group being returned
*/
title?: string | undefined;
};
/** @internal */
export const LiveRate$inboundSchema: z.ZodMiniType = z.pipe(
z.object({
amount: z.optional(z.string()),
amount_local: z.optional(z.string()),
currency: z.optional(z.string()),
currency_local: z.optional(z.string()),
estimated_days: z.optional(z.int()),
title: z.optional(z.string()),
}),
z.transform((v) => {
return remap$(v, {
"amount_local": "amountLocal",
"currency_local": "currencyLocal",
"estimated_days": "estimatedDays",
});
}),
);
export function liveRateFromJSON(
jsonString: string,
): SafeParseResult {
return safeParse(
jsonString,
(x) => LiveRate$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'LiveRate' from JSON`,
);
}