/* * 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 { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Currency, Currency$inboundSchema } from "./currency.js"; import { Email, Email$inboundSchema } from "./email.js"; import { LinkedEcommerceOrder, LinkedEcommerceOrder$inboundSchema, } from "./linkedecommerceorder.js"; import { PhoneNumber, PhoneNumber$inboundSchema } from "./phonenumber.js"; /** * The current status of the customer */ export const CustomerStatus = { Active: "active", Archived: "archived", } as const; /** * The current status of the customer */ export type CustomerStatus = OpenEnum; export const EcommerceCustomerType = { Billing: "billing", Shipping: "shipping", Other: "other", } as const; export type EcommerceCustomerType = OpenEnum; export type Addresses = { type?: EcommerceCustomerType | undefined; /** * A unique identifier for an object. */ id?: string | null | undefined; /** * First line of the street address of the customer */ line1?: string | null | undefined; /** * Second line of the street address of the customer */ line2?: string | null | undefined; /** * City of the customer */ city?: string | null | undefined; /** * State of the customer */ state?: string | null | undefined; /** * Postal code of the customer */ postalCode?: string | null | undefined; /** * Country of the customer */ country?: string | null | undefined; /** * Tax or VAT identification number registered on this address */ taxNumber?: string | null | undefined; }; export type EcommerceCustomer = { /** * A unique identifier for an object. */ id: string; /** * Full name of the customer */ name?: string | null | undefined; /** * First name of the customer */ firstName?: string | null | undefined; /** * Last name of the customer */ lastName?: string | null | undefined; /** * Company name of the customer */ companyName?: string | null | undefined; /** * The current status of the customer */ status?: CustomerStatus | null | undefined; /** * Tax or VAT identification number of the customer */ taxNumber?: string | null | undefined; /** * Indicates the associated currency for an amount of money. Values correspond to [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217). */ currency?: Currency | null | undefined; /** * An array of email addresses for the customer. */ emails?: Array | null | undefined; /** * An array of phone numbers for the customer. */ phoneNumbers?: Array | null | undefined; /** * An array of addresses for the customer. */ addresses?: Array | undefined; orders?: Array | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; }; /** @internal */ export const CustomerStatus$inboundSchema: z.ZodType< CustomerStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(CustomerStatus)); /** @internal */ export const EcommerceCustomerType$inboundSchema: z.ZodType< EcommerceCustomerType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(EcommerceCustomerType) ); /** @internal */ export const Addresses$inboundSchema: z.ZodType< Addresses, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ type: types.optional(EcommerceCustomerType$inboundSchema), id: z.nullable(types.string()).optional(), line1: z.nullable(types.string()).optional(), line2: z.nullable(types.string()).optional(), city: z.nullable(types.string()).optional(), state: z.nullable(types.string()).optional(), postal_code: z.nullable(types.string()).optional(), country: z.nullable(types.string()).optional(), tax_number: z.nullable(types.string()).optional(), }).transform((v) => { return remap$(v, { "postal_code": "postalCode", "tax_number": "taxNumber", }); }) ); export function addressesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Addresses$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Addresses' from JSON`, ); } /** @internal */ export const EcommerceCustomer$inboundSchema: z.ZodType< EcommerceCustomer, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), name: z.nullable(types.string()).optional(), first_name: z.nullable(types.string()).optional(), last_name: z.nullable(types.string()).optional(), company_name: z.nullable(types.string()).optional(), status: z.nullable(CustomerStatus$inboundSchema).optional(), tax_number: z.nullable(types.string()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), emails: z.nullable(z.array(Email$inboundSchema)).optional(), phone_numbers: z.nullable(z.array(PhoneNumber$inboundSchema)).optional(), addresses: types.optional(z.array(z.lazy(() => Addresses$inboundSchema))), orders: types.optional(z.array(LinkedEcommerceOrder$inboundSchema)), custom_mappings: z.nullable(z.record(z.any())).optional(), created_at: z.nullable(types.date()).optional(), updated_at: z.nullable(types.date()).optional(), }).transform((v) => { return remap$(v, { "first_name": "firstName", "last_name": "lastName", "company_name": "companyName", "tax_number": "taxNumber", "phone_numbers": "phoneNumbers", "custom_mappings": "customMappings", "created_at": "createdAt", "updated_at": "updatedAt", }); }) ); export function ecommerceCustomerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EcommerceCustomer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EcommerceCustomer' from JSON`, ); }