/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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 { BillingDetails, BillingDetails$inboundSchema, BillingDetails$Outbound, BillingDetails$outboundSchema, } from "./billingdetails.js"; import { ShippingDetailsCreate, ShippingDetailsCreate$inboundSchema, ShippingDetailsCreate$Outbound, ShippingDetailsCreate$outboundSchema, } from "./shippingdetailscreate.js"; export type GuestBuyer = { /** * The display name for the buyer. */ displayName?: string | null | undefined; /** * The merchant identifier for this buyer. */ externalIdentifier?: string | null | undefined; /** * The billing name, address, email, and other fields for this buyer. */ billingDetails?: BillingDetails | null | undefined; /** * The buyer account number */ accountNumber?: string | null | undefined; /** * The optional shipping details for this buyer. */ shippingDetails?: ShippingDetailsCreate | null | undefined; }; /** @internal */ export const GuestBuyer$inboundSchema: z.ZodType< GuestBuyer, z.ZodTypeDef, unknown > = z.object({ display_name: z.nullable(z.string()).optional(), external_identifier: z.nullable(z.string()).optional(), billing_details: z.nullable(BillingDetails$inboundSchema).optional(), account_number: z.nullable(z.string()).optional(), shipping_details: z.nullable(ShippingDetailsCreate$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "display_name": "displayName", "external_identifier": "externalIdentifier", "billing_details": "billingDetails", "account_number": "accountNumber", "shipping_details": "shippingDetails", }); }); /** @internal */ export type GuestBuyer$Outbound = { display_name?: string | null | undefined; external_identifier?: string | null | undefined; billing_details?: BillingDetails$Outbound | null | undefined; account_number?: string | null | undefined; shipping_details?: ShippingDetailsCreate$Outbound | null | undefined; }; /** @internal */ export const GuestBuyer$outboundSchema: z.ZodType< GuestBuyer$Outbound, z.ZodTypeDef, GuestBuyer > = z.object({ displayName: z.nullable(z.string()).optional(), externalIdentifier: z.nullable(z.string()).optional(), billingDetails: z.nullable(BillingDetails$outboundSchema).optional(), accountNumber: z.nullable(z.string()).optional(), shippingDetails: z.nullable(ShippingDetailsCreate$outboundSchema).optional(), }).transform((v) => { return remap$(v, { displayName: "display_name", externalIdentifier: "external_identifier", billingDetails: "billing_details", accountNumber: "account_number", shippingDetails: "shipping_details", }); }); export function guestBuyerToJSON(guestBuyer: GuestBuyer): string { return JSON.stringify(GuestBuyer$outboundSchema.parse(guestBuyer)); } export function guestBuyerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GuestBuyer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GuestBuyer' from JSON`, ); }