/* * 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"; /** * The type of phone number */ export const PhoneNumberType = { Primary: "primary", Secondary: "secondary", Home: "home", Work: "work", Office: "office", Mobile: "mobile", Assistant: "assistant", Fax: "fax", DirectDialIn: "direct-dial-in", Personal: "personal", Billing: "billing", Other: "other", } as const; /** * The type of phone number */ export type PhoneNumberType = OpenEnum; export type PhoneNumber = { /** * Unique identifier of the phone number */ id?: string | null | undefined; /** * The country code of the phone number, e.g. +1 */ countryCode?: string | null | undefined; /** * The area code of the phone number, e.g. 323 */ areaCode?: string | null | undefined; /** * The phone number */ number: string; /** * The extension of the phone number */ extension?: string | null | undefined; /** * The type of phone number */ type?: PhoneNumberType | null | undefined; }; /** @internal */ export const PhoneNumberType$inboundSchema: z.ZodType< PhoneNumberType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(PhoneNumberType)); /** @internal */ export const PhoneNumberType$outboundSchema: z.ZodType< string, z.ZodTypeDef, PhoneNumberType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(PhoneNumberType) ); /** @internal */ export const PhoneNumber$inboundSchema: z.ZodType< PhoneNumber, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), country_code: z.nullable(types.string()).optional(), area_code: z.nullable(types.string()).optional(), number: types.string(), extension: z.nullable(types.string()).optional(), type: z.nullable(PhoneNumberType$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "country_code": "countryCode", "area_code": "areaCode", }); }) ); /** @internal */ export type PhoneNumber$Outbound = { id?: string | null | undefined; country_code?: string | null | undefined; area_code?: string | null | undefined; number: string; extension?: string | null | undefined; type?: string | null | undefined; }; /** @internal */ export const PhoneNumber$outboundSchema: z.ZodType< PhoneNumber$Outbound, z.ZodTypeDef, PhoneNumber > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(z.string()).optional(), countryCode: z.nullable(z.string()).optional(), areaCode: z.nullable(z.string()).optional(), number: z.string(), extension: z.nullable(z.string()).optional(), type: z.nullable(PhoneNumberType$outboundSchema).optional(), }).transform((v) => { return remap$(v, { countryCode: "country_code", areaCode: "area_code", }); }) ); export function phoneNumberToJSON(phoneNumber: PhoneNumber): string { return JSON.stringify(PhoneNumber$outboundSchema.parse(phoneNumber)); } export function phoneNumberFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PhoneNumber$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PhoneNumber' from JSON`, ); }