/*
* 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 {
FedExConnectExistingOwnAccountParameters,
FedExConnectExistingOwnAccountParameters$Outbound,
FedExConnectExistingOwnAccountParameters$outboundSchema,
} from "./fedexconnectexistingownaccountparameters.js";
import {
UPSConnectExistingOwnAccountParameters,
UPSConnectExistingOwnAccountParameters$Outbound,
UPSConnectExistingOwnAccountParameters$outboundSchema,
} from "./upsconnectexistingownaccountparameters.js";
export type CarrierAccountBaseParameters =
| UPSConnectExistingOwnAccountParameters
| FedExConnectExistingOwnAccountParameters
| { [k: string]: any };
export type CarrierAccountBase = {
/**
* 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;
};
/** @internal */
export type CarrierAccountBaseParameters$Outbound =
| UPSConnectExistingOwnAccountParameters$Outbound
| FedExConnectExistingOwnAccountParameters$Outbound
| { [k: string]: any };
/** @internal */
export const CarrierAccountBaseParameters$outboundSchema: z.ZodMiniType<
CarrierAccountBaseParameters$Outbound,
CarrierAccountBaseParameters
> = z.union([
UPSConnectExistingOwnAccountParameters$outboundSchema,
FedExConnectExistingOwnAccountParameters$outboundSchema,
z.record(z.string(), z.any()),
]);
export function carrierAccountBaseParametersToJSON(
carrierAccountBaseParameters: CarrierAccountBaseParameters,
): string {
return JSON.stringify(
CarrierAccountBaseParameters$outboundSchema.parse(
carrierAccountBaseParameters,
),
);
}
/** @internal */
export type CarrierAccountBase$Outbound = {
account_id: string;
active?: boolean | undefined;
carrier: string;
parameters?:
| UPSConnectExistingOwnAccountParameters$Outbound
| FedExConnectExistingOwnAccountParameters$Outbound
| { [k: string]: any }
| undefined;
};
/** @internal */
export const CarrierAccountBase$outboundSchema: z.ZodMiniType<
CarrierAccountBase$Outbound,
CarrierAccountBase
> = z.pipe(
z.object({
accountId: z.string(),
active: z.optional(z.boolean()),
carrier: z.string(),
parameters: z.optional(
z.union([
UPSConnectExistingOwnAccountParameters$outboundSchema,
FedExConnectExistingOwnAccountParameters$outboundSchema,
z.record(z.string(), z.any()),
]),
),
}),
z.transform((v) => {
return remap$(v, {
accountId: "account_id",
});
}),
);
export function carrierAccountBaseToJSON(
carrierAccountBase: CarrierAccountBase,
): string {
return JSON.stringify(
CarrierAccountBase$outboundSchema.parse(carrierAccountBase),
);
}