/* * 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 { CustomerType, CustomerType$inboundSchema } from "./customertype.js"; import { MetadataOutputType, MetadataOutputType$inboundSchema, } from "./metadataoutputtype.js"; import { TaxIDFormat, TaxIDFormat$inboundSchema } from "./taxidformat.js"; export type LicenseKeyCustomerTaxId = string | TaxIDFormat; export type LicenseKeyCustomer = { /** * The ID of the customer. */ id: string; /** * Creation timestamp of the object. */ createdAt: Date; /** * Last modification timestamp of the object. */ modifiedAt: Date | null; metadata: { [k: string]: MetadataOutputType }; /** * The ID of the customer in your system. This must be unique within the organization. Once set, it can't be updated. */ externalId?: string | null | undefined; /** * The email address of the customer. This must be unique within the organization. */ email?: string | null | undefined; /** * Whether the customer email address is verified. The address is automatically verified when the customer accesses the customer portal using their email address. */ emailVerified: boolean; type: CustomerType; /** * The name of the customer. */ name: string | null; billingAddress: Address | null; taxId: Array | null; locale?: string | null | undefined; /** * The ID of the organization owning the customer. */ organizationId: string; /** * The ID of the customer's default payment method, if any. Use the payment methods endpoint to retrieve its details. */ defaultPaymentMethodId?: string | null | undefined; /** * Timestamp for when the customer was soft deleted. */ deletedAt: Date | null; avatarUrl: string; }; /** @internal */ export const LicenseKeyCustomerTaxId$inboundSchema: z.ZodMiniType< LicenseKeyCustomerTaxId, unknown > = smartUnion([z.string(), TaxIDFormat$inboundSchema]); export function licenseKeyCustomerTaxIdFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LicenseKeyCustomerTaxId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LicenseKeyCustomerTaxId' from JSON`, ); } /** @internal */ export const LicenseKeyCustomer$inboundSchema: z.ZodMiniType< LicenseKeyCustomer, unknown > = z.pipe( z.object({ id: z.string(), 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))), ), metadata: z.record(z.string(), MetadataOutputType$inboundSchema), external_id: z.optional(z.nullable(z.string())), email: z.optional(z.nullable(z.string())), email_verified: z.boolean(), type: CustomerType$inboundSchema, name: z.nullable(z.string()), billing_address: z.nullable(Address$inboundSchema), tax_id: z.nullable( z.array(z.nullable(smartUnion([z.string(), TaxIDFormat$inboundSchema]))), ), locale: z.optional(z.nullable(z.string())), organization_id: z.string(), default_payment_method_id: z.optional(z.nullable(z.string())), deleted_at: z.nullable( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), avatar_url: z.string(), }), z.transform((v) => { return remap$(v, { "created_at": "createdAt", "modified_at": "modifiedAt", "external_id": "externalId", "email_verified": "emailVerified", "billing_address": "billingAddress", "tax_id": "taxId", "organization_id": "organizationId", "default_payment_method_id": "defaultPaymentMethodId", "deleted_at": "deletedAt", "avatar_url": "avatarUrl", }); }), ); export function licenseKeyCustomerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LicenseKeyCustomer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LicenseKeyCustomer' from JSON`, ); }