/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 29079791f44e */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Company, Company$inboundSchema, Company$Outbound, Company$outboundSchema, } from "./company.js"; import { CustomerMetadata, CustomerMetadata$inboundSchema, CustomerMetadata$Outbound, CustomerMetadata$outboundSchema, } from "./customermetadata.js"; import { Person, Person$inboundSchema, Person$Outbound, Person$outboundSchema, } from "./person.js"; export type Customer = { /** * Unique identifier. */ id: string; /** * Link to company's associated website domains. */ domains?: Array | undefined; company: Company; /** * A map of {string, int} pairs representing counts of each document type associated with this customer. */ documentCounts?: { [k: string]: number } | undefined; /** * A list of POC for company. */ poc?: Array | undefined; metadata?: CustomerMetadata | undefined; /** * A list of Customers. */ mergedCustomers?: Array | undefined; /** * The date when the interaction with customer started. */ startDate?: RFCDate | undefined; /** * Average contract annual revenue with that customer. */ contractAnnualRevenue?: number | undefined; /** * User facing (potentially generated) notes about company. */ notes?: string | undefined; }; /** @internal */ export const Customer$inboundSchema: z.ZodType< Customer, z.ZodTypeDef, unknown > = z.object({ id: z.string(), domains: z.array(z.string()).optional(), company: Company$inboundSchema, documentCounts: z.record(z.number().int()).optional(), poc: z.array(z.lazy(() => Person$inboundSchema)).optional(), metadata: CustomerMetadata$inboundSchema.optional(), mergedCustomers: z.array(z.lazy(() => Customer$inboundSchema)).optional(), startDate: z.string().transform(v => new RFCDate(v)).optional(), contractAnnualRevenue: z.number().optional(), notes: z.string().optional(), }); /** @internal */ export type Customer$Outbound = { id: string; domains?: Array | undefined; company: Company$Outbound; documentCounts?: { [k: string]: number } | undefined; poc?: Array | undefined; metadata?: CustomerMetadata$Outbound | undefined; mergedCustomers?: Array | undefined; startDate?: string | undefined; contractAnnualRevenue?: number | undefined; notes?: string | undefined; }; /** @internal */ export const Customer$outboundSchema: z.ZodType< Customer$Outbound, z.ZodTypeDef, Customer > = z.object({ id: z.string(), domains: z.array(z.string()).optional(), company: Company$outboundSchema, documentCounts: z.record(z.number().int()).optional(), poc: z.array(z.lazy(() => Person$outboundSchema)).optional(), metadata: CustomerMetadata$outboundSchema.optional(), mergedCustomers: z.array(z.lazy(() => Customer$outboundSchema)).optional(), startDate: z.instanceof(RFCDate).transform(v => v.toString()).optional(), contractAnnualRevenue: z.number().optional(), notes: z.string().optional(), }); export function customerToJSON(customer: Customer): string { return JSON.stringify(Customer$outboundSchema.parse(customer)); } export function customerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Customer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Customer' from JSON`, ); }