/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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 { IndividualName, IndividualName$inboundSchema, IndividualName$Outbound, IndividualName$outboundSchema, } from "./individualname.js"; import { PhoneNumber, PhoneNumber$inboundSchema, PhoneNumber$Outbound, PhoneNumber$outboundSchema, } from "./phonenumber.js"; import { RepresentativeResponsibilities, RepresentativeResponsibilities$inboundSchema, RepresentativeResponsibilities$Outbound, RepresentativeResponsibilities$outboundSchema, } from "./representativeresponsibilities.js"; /** * Describes a business representative. */ export type Representative = { /** * Unique identifier for this representative. */ representativeID: string; name: IndividualName; phone?: PhoneNumber | undefined; email?: string | undefined; address?: Address | undefined; /** * Indicates whether this representative's birth date has been provided. */ birthDateProvided?: boolean | undefined; /** * Indicates whether a government ID (SSN, ITIN, etc.) has been provided for this representative. */ governmentIDProvided?: boolean | undefined; /** * Describes the job responsibilities of a business representative. */ responsibilities?: RepresentativeResponsibilities | undefined; createdOn: Date; updatedOn: Date; disabledOn?: Date | undefined; }; /** @internal */ export const Representative$inboundSchema: z.ZodType< Representative, z.ZodTypeDef, unknown > = z.object({ representativeID: z.string(), name: IndividualName$inboundSchema, phone: PhoneNumber$inboundSchema.optional(), email: z.string().optional(), address: Address$inboundSchema.optional(), birthDateProvided: z.boolean().optional(), governmentIDProvided: z.boolean().optional(), responsibilities: RepresentativeResponsibilities$inboundSchema.optional(), createdOn: z.string().datetime({ offset: true }).transform(v => new Date(v)), updatedOn: z.string().datetime({ offset: true }).transform(v => new Date(v)), disabledOn: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), }); /** @internal */ export type Representative$Outbound = { representativeID: string; name: IndividualName$Outbound; phone?: PhoneNumber$Outbound | undefined; email?: string | undefined; address?: Address$Outbound | undefined; birthDateProvided?: boolean | undefined; governmentIDProvided?: boolean | undefined; responsibilities?: RepresentativeResponsibilities$Outbound | undefined; createdOn: string; updatedOn: string; disabledOn?: string | undefined; }; /** @internal */ export const Representative$outboundSchema: z.ZodType< Representative$Outbound, z.ZodTypeDef, Representative > = z.object({ representativeID: z.string(), name: IndividualName$outboundSchema, phone: PhoneNumber$outboundSchema.optional(), email: z.string().optional(), address: Address$outboundSchema.optional(), birthDateProvided: z.boolean().optional(), governmentIDProvided: z.boolean().optional(), responsibilities: RepresentativeResponsibilities$outboundSchema.optional(), createdOn: z.date().transform(v => v.toISOString()), updatedOn: z.date().transform(v => v.toISOString()), disabledOn: z.date().transform(v => v.toISOString()).optional(), }); export function representativeToJSON(representative: Representative): string { return JSON.stringify(Representative$outboundSchema.parse(representative)); } export function representativeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Representative$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Representative' from JSON`, ); }