/*
* 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 {
CarrierAccountServiceLevel,
CarrierAccountServiceLevel$inboundSchema,
} from "./carrieraccountservicelevel.js";
import {
FedExConnectExistingOwnAccountParameters,
FedExConnectExistingOwnAccountParameters$inboundSchema,
} from "./fedexconnectexistingownaccountparameters.js";
import {
UPSConnectExistingOwnAccountParameters,
UPSConnectExistingOwnAccountParameters$inboundSchema,
} from "./upsconnectexistingownaccountparameters.js";
export type CarrierAccountParameters =
| UPSConnectExistingOwnAccountParameters
| FedExConnectExistingOwnAccountParameters
| { [k: string]: any };
export type CarrierAccount = {
/**
* Unique identifier of the account. Please check the carrier accounts tutorial
*
* @remarks
* page for the `account_id` per carrier.
* To protect account information, this field will be masked in any API response.
*/
accountId: string;
/**
* Determines whether the account is active. When creating a shipment, if no `carrier_accounts` are explicitly
*
* @remarks
* passed Shippo will query all carrier accounts that have this field set. By default, this is set to True.
*/
active?: boolean | undefined;
/**
* Carrier token, see Carriers
*
* @remarks
* Please check the carrier accounts tutorial page for all supported carriers.
*/
carrier: string;
parameters?:
| UPSConnectExistingOwnAccountParameters
| FedExConnectExistingOwnAccountParameters
| { [k: string]: any }
| undefined;
/**
* Carrier name, see Carriers
*/
carrierName?: any | undefined;
isShippoAccount?: boolean | undefined;
metadata?: string | undefined;
/**
* Unique identifier of the carrier account object.
*/
objectId?: string | undefined;
/**
* Username of the user who created the carrier account object.
*/
objectOwner?: string | undefined;
serviceLevels?: Array | undefined;
/**
* Indicates whether the object has been created in test mode.
*/
test?: boolean | undefined;
};
/** @internal */
export const CarrierAccountParameters$inboundSchema: z.ZodMiniType<
CarrierAccountParameters,
unknown
> = z.union([
UPSConnectExistingOwnAccountParameters$inboundSchema,
FedExConnectExistingOwnAccountParameters$inboundSchema,
z.record(z.string(), z.any()),
]);
export function carrierAccountParametersFromJSON(
jsonString: string,
): SafeParseResult {
return safeParse(
jsonString,
(x) => CarrierAccountParameters$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CarrierAccountParameters' from JSON`,
);
}
/** @internal */
export const CarrierAccount$inboundSchema: z.ZodMiniType<
CarrierAccount,
unknown
> = z.pipe(
z.object({
account_id: z.string(),
active: z.optional(z.boolean()),
carrier: z.string(),
parameters: z.optional(
z.union([
UPSConnectExistingOwnAccountParameters$inboundSchema,
FedExConnectExistingOwnAccountParameters$inboundSchema,
z.record(z.string(), z.any()),
]),
),
carrier_name: z.optional(z.any()),
is_shippo_account: z.optional(z.boolean()),
metadata: z.optional(z.string()),
object_id: z.optional(z.string()),
object_owner: z.optional(z.string()),
service_levels: z.optional(
z.array(CarrierAccountServiceLevel$inboundSchema),
),
test: z.optional(z.boolean()),
}),
z.transform((v) => {
return remap$(v, {
"account_id": "accountId",
"carrier_name": "carrierName",
"is_shippo_account": "isShippoAccount",
"object_id": "objectId",
"object_owner": "objectOwner",
"service_levels": "serviceLevels",
});
}),
);
export function carrierAccountFromJSON(
jsonString: string,
): SafeParseResult {
return safeParse(
jsonString,
(x) => CarrierAccount$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CarrierAccount' from JSON`,
);
}