/* * 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 { ServiceLevel, ServiceLevel$inboundSchema, ServiceLevel$Outbound, ServiceLevel$outboundSchema, } from "./servicelevel.js"; /** * Contains details regarding the service level for the given rate. */ export type ServiceLevelWithParent = { /** * Name of the Rate's servicelevel, e.g. `International Priority` or `Standard Post`. * * @remarks * A servicelevel commonly defines the transit time of a Shipment (e.g., Express vs. Standard), along with other properties. * These names vary depending on the provider. */ name?: string | undefined; /** * Further clarification of the service. */ terms?: string | undefined; /** * Token of the Rate's servicelevel, e.g. `usps_priority` or `fedex_ground`. * * @remarks * See servicelevels. */ token?: string | undefined; /** * Unique, extended version of the Service Level "token". * * @remarks * Guaranteed to be unique across all Service Levels, and may help offer insight into the specific Service Level it describes. */ extendedToken?: string | undefined; parentServicelevel?: ServiceLevel | undefined; }; /** @internal */ export const ServiceLevelWithParent$inboundSchema: z.ZodMiniType< ServiceLevelWithParent, unknown > = z.pipe( z.object({ name: z.optional(z.string()), terms: z.optional(z.string()), token: z.optional(z.string()), extended_token: z.optional(z.string()), parent_servicelevel: z.optional(ServiceLevel$inboundSchema), }), z.transform((v) => { return remap$(v, { "extended_token": "extendedToken", "parent_servicelevel": "parentServicelevel", }); }), ); /** @internal */ export type ServiceLevelWithParent$Outbound = { name?: string | undefined; terms?: string | undefined; token?: string | undefined; extended_token?: string | undefined; parent_servicelevel?: ServiceLevel$Outbound | undefined; }; /** @internal */ export const ServiceLevelWithParent$outboundSchema: z.ZodMiniType< ServiceLevelWithParent$Outbound, ServiceLevelWithParent > = z.pipe( z.object({ name: z.optional(z.string()), terms: z.optional(z.string()), token: z.optional(z.string()), extendedToken: z.optional(z.string()), parentServicelevel: z.optional(ServiceLevel$outboundSchema), }), z.transform((v) => { return remap$(v, { extendedToken: "extended_token", parentServicelevel: "parent_servicelevel", }); }), ); export function serviceLevelWithParentToJSON( serviceLevelWithParent: ServiceLevelWithParent, ): string { return JSON.stringify( ServiceLevelWithParent$outboundSchema.parse(serviceLevelWithParent), ); } export function serviceLevelWithParentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ServiceLevelWithParent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ServiceLevelWithParent' from JSON`, ); }