/* * 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 { Address, Address$inboundSchema, Address$Outbound, Address$outboundSchema, } from "./address.js"; import { TaxId, TaxId$inboundSchema, TaxId$Outbound, TaxId$outboundSchema, } from "./taxid.js"; export type BillingDetails = { /** * The first name(s) or given name for the buyer. */ firstName?: string | null | undefined; /** * The last name, or family name, of the buyer. */ lastName?: string | null | undefined; /** * The email address for the buyer. */ emailAddress?: string | null | undefined; /** * The phone number for the buyer which should be formatted according to the E164 number standard. */ phoneNumber?: string | null | undefined; /** * The billing address for the buyer. */ address?: Address | null | undefined; /** * The tax ID information associated with the billing details. */ taxId?: TaxId | null | undefined; }; /** @internal */ export const BillingDetails$inboundSchema: z.ZodType< BillingDetails, z.ZodTypeDef, unknown > = z.object({ first_name: z.nullable(z.string()).optional(), last_name: z.nullable(z.string()).optional(), email_address: z.nullable(z.string()).optional(), phone_number: z.nullable(z.string()).optional(), address: z.nullable(Address$inboundSchema).optional(), tax_id: z.nullable(TaxId$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "first_name": "firstName", "last_name": "lastName", "email_address": "emailAddress", "phone_number": "phoneNumber", "tax_id": "taxId", }); }); /** @internal */ export type BillingDetails$Outbound = { first_name?: string | null | undefined; last_name?: string | null | undefined; email_address?: string | null | undefined; phone_number?: string | null | undefined; address?: Address$Outbound | null | undefined; tax_id?: TaxId$Outbound | null | undefined; }; /** @internal */ export const BillingDetails$outboundSchema: z.ZodType< BillingDetails$Outbound, z.ZodTypeDef, BillingDetails > = z.object({ firstName: z.nullable(z.string()).optional(), lastName: z.nullable(z.string()).optional(), emailAddress: z.nullable(z.string()).optional(), phoneNumber: z.nullable(z.string()).optional(), address: z.nullable(Address$outboundSchema).optional(), taxId: z.nullable(TaxId$outboundSchema).optional(), }).transform((v) => { return remap$(v, { firstName: "first_name", lastName: "last_name", emailAddress: "email_address", phoneNumber: "phone_number", taxId: "tax_id", }); }); export function billingDetailsToJSON(billingDetails: BillingDetails): string { return JSON.stringify(BillingDetails$outboundSchema.parse(billingDetails)); } export function billingDetailsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BillingDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BillingDetails' from JSON`, ); }