/* * 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 CoreRate = { /** * 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; /** * Unique identifier of the Rate object. */ objectId?: string | undefined; /** * Carrier offering the rate, e.g., `FedEx` or `Deutsche Post DHL`. */ provider?: string | undefined; /** * Object ID of the carrier account that has been used to retrieve the rate. */ carrierAccount?: string | undefined; /** * Service level name, e.g. `Priority Mail` or `FedEx Ground®`. * * @remarks * A service level commonly defines the transit time of a Shipment (e.g., Express vs. Standard), * along with other properties. These names vary depending on the provider.
* See Service Levels. */ servicelevelName?: string | undefined; /** * Token of the Rate's servicelevel, e.g. `usps_priority` or `fedex_ground`. * * @remarks * See servicelevels. */ servicelevelToken?: string | undefined; }; /** @internal */ export const CoreRate$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()), object_id: z.optional(z.string()), provider: z.optional(z.string()), carrier_account: z.optional(z.string()), servicelevel_name: z.optional(z.string()), servicelevel_token: z.optional(z.string()), }), z.transform((v) => { return remap$(v, { "amount_local": "amountLocal", "currency_local": "currencyLocal", "object_id": "objectId", "carrier_account": "carrierAccount", "servicelevel_name": "servicelevelName", "servicelevel_token": "servicelevelToken", }); }), ); /** @internal */ export type CoreRate$Outbound = { amount?: string | undefined; amount_local?: string | undefined; currency?: string | undefined; currency_local?: string | undefined; object_id?: string | undefined; provider?: string | undefined; carrier_account?: string | undefined; servicelevel_name?: string | undefined; servicelevel_token?: string | undefined; }; /** @internal */ export const CoreRate$outboundSchema: z.ZodMiniType< CoreRate$Outbound, CoreRate > = z.pipe( z.object({ amount: z.optional(z.string()), amountLocal: z.optional(z.string()), currency: z.optional(z.string()), currencyLocal: z.optional(z.string()), objectId: z.optional(z.string()), provider: z.optional(z.string()), carrierAccount: z.optional(z.string()), servicelevelName: z.optional(z.string()), servicelevelToken: z.optional(z.string()), }), z.transform((v) => { return remap$(v, { amountLocal: "amount_local", currencyLocal: "currency_local", objectId: "object_id", carrierAccount: "carrier_account", servicelevelName: "servicelevel_name", servicelevelToken: "servicelevel_token", }); }), ); export function coreRateToJSON(coreRate: CoreRate): string { return JSON.stringify(CoreRate$outboundSchema.parse(coreRate)); } export function coreRateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CoreRate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CoreRate' from JSON`, ); }