/* * 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 { smartUnion } from "../../types/smartUnion.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Address, Address$inboundSchema } from "./address.js"; import { CustomerPortalOAuthAccount, CustomerPortalOAuthAccount$inboundSchema, } from "./customerportaloauthaccount.js"; import { CustomerType, CustomerType$inboundSchema } from "./customertype.js"; import { TaxIDFormat, TaxIDFormat$inboundSchema } from "./taxidformat.js"; export type CustomerPortalCustomerTaxId = string | TaxIDFormat; export type CustomerPortalCustomer = { /** * Creation timestamp of the object. */ createdAt: Date; /** * Last modification timestamp of the object. */ modifiedAt: Date | null; /** * The ID of the object. */ id: string; email: string | null; emailVerified: boolean; name: string | null; billingName: string | null; billingAddress: Address | null; taxId: Array | null; oauthAccounts: { [k: string]: CustomerPortalOAuthAccount }; defaultPaymentMethodId?: string | null | undefined; type?: CustomerType | null | undefined; }; /** @internal */ export const CustomerPortalCustomerTaxId$inboundSchema: z.ZodMiniType< CustomerPortalCustomerTaxId, unknown > = smartUnion([z.string(), TaxIDFormat$inboundSchema]); export function customerPortalCustomerTaxIdFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomerPortalCustomerTaxId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomerPortalCustomerTaxId' from JSON`, ); } /** @internal */ export const CustomerPortalCustomer$inboundSchema: z.ZodMiniType< CustomerPortalCustomer, unknown > = z.pipe( z.object({ created_at: z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), ), modified_at: z.nullable( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), id: z.string(), email: z.nullable(z.string()), email_verified: z.boolean(), name: z.nullable(z.string()), billing_name: z.nullable(z.string()), billing_address: z.nullable(Address$inboundSchema), tax_id: z.nullable( z.array(z.nullable(smartUnion([z.string(), TaxIDFormat$inboundSchema]))), ), oauth_accounts: z.record( z.string(), CustomerPortalOAuthAccount$inboundSchema, ), default_payment_method_id: z.optional(z.nullable(z.string())), type: z.optional(z.nullable(CustomerType$inboundSchema)), }), z.transform((v) => { return remap$(v, { "created_at": "createdAt", "modified_at": "modifiedAt", "email_verified": "emailVerified", "billing_name": "billingName", "billing_address": "billingAddress", "tax_id": "taxId", "oauth_accounts": "oauthAccounts", "default_payment_method_id": "defaultPaymentMethodId", }); }), ); export function customerPortalCustomerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomerPortalCustomer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomerPortalCustomer' from JSON`, ); }