/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { catchUnrecognizedEnum, OpenEnum, Unrecognized, } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { PostalAddressCreate, PostalAddressCreate$inboundSchema, PostalAddressCreate$Outbound, PostalAddressCreate$outboundSchema, } from "./postaladdresscreate.js"; /** * Delivery method instruction for account statements for a given Interested Party; Can be `PHYSICAL`, `SUPPRESS`; Defaults to `PHYSICAL` on party creation */ export enum StatementDeliveryPreference { Physical = "PHYSICAL", Suppress = "SUPPRESS", } /** * Delivery method instruction for account statements for a given Interested Party; Can be `PHYSICAL`, `SUPPRESS`; Defaults to `PHYSICAL` on party creation */ export type StatementDeliveryPreferenceOpen = OpenEnum< typeof StatementDeliveryPreference >; /** * Delivery method instruction for trade confirmations for a given Interested Party record; Can be `PHYSICAL`, `SUPPRESS`; Defaults to `PHYSICAL` on party creation */ export enum TradeConfirmationDeliveryPreference { Physical = "PHYSICAL", Suppress = "SUPPRESS", } /** * Delivery method instruction for trade confirmations for a given Interested Party record; Can be `PHYSICAL`, `SUPPRESS`; Defaults to `PHYSICAL` on party creation */ export type TradeConfirmationDeliveryPreferenceOpen = OpenEnum< typeof TradeConfirmationDeliveryPreference >; /** * An interested party. */ export type InterestedPartyCreate = { /** * Represents a postal address, e.g. for postal delivery or payments addresses. Given a postal address, a postal service can deliver items to a premise, P.O. Box or similar. It is not intended to model geographical locations (roads, towns, mountains). * * @remarks * * In typical usage an address would be created via user input or from importing existing data, depending on the type of process. * * Advice on address input / editing: - Use an i18n-ready address widget such as https://github.com/google/libaddressinput) - Users should not be presented with UI elements for input or editing of fields outside countries where that field is used. * * For more guidance on how to use this schema, please see: https://support.google.com/business/answer/6397478 */ mailingAddress: PostalAddressCreate; /** * The sending address name for mailings to Interested Parties The name of an Interested Party; Used for envelope/communication addressing */ recipient: string; /** * Delivery method instruction for account statements for a given Interested Party; Can be `PHYSICAL`, `SUPPRESS`; Defaults to `PHYSICAL` on party creation */ statementDeliveryPreference?: StatementDeliveryPreferenceOpen | undefined; /** * Delivery method instruction for trade confirmations for a given Interested Party record; Can be `PHYSICAL`, `SUPPRESS`; Defaults to `PHYSICAL` on party creation */ tradeConfirmationDeliveryPreference?: | TradeConfirmationDeliveryPreferenceOpen | undefined; }; /** @internal */ export const StatementDeliveryPreference$inboundSchema: z.ZodType< StatementDeliveryPreferenceOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(StatementDeliveryPreference), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const StatementDeliveryPreference$outboundSchema: z.ZodType< StatementDeliveryPreferenceOpen, z.ZodTypeDef, StatementDeliveryPreferenceOpen > = z.union([ z.nativeEnum(StatementDeliveryPreference), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace StatementDeliveryPreference$ { /** @deprecated use `StatementDeliveryPreference$inboundSchema` instead. */ export const inboundSchema = StatementDeliveryPreference$inboundSchema; /** @deprecated use `StatementDeliveryPreference$outboundSchema` instead. */ export const outboundSchema = StatementDeliveryPreference$outboundSchema; } /** @internal */ export const TradeConfirmationDeliveryPreference$inboundSchema: z.ZodType< TradeConfirmationDeliveryPreferenceOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(TradeConfirmationDeliveryPreference), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const TradeConfirmationDeliveryPreference$outboundSchema: z.ZodType< TradeConfirmationDeliveryPreferenceOpen, z.ZodTypeDef, TradeConfirmationDeliveryPreferenceOpen > = z.union([ z.nativeEnum(TradeConfirmationDeliveryPreference), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TradeConfirmationDeliveryPreference$ { /** @deprecated use `TradeConfirmationDeliveryPreference$inboundSchema` instead. */ export const inboundSchema = TradeConfirmationDeliveryPreference$inboundSchema; /** @deprecated use `TradeConfirmationDeliveryPreference$outboundSchema` instead. */ export const outboundSchema = TradeConfirmationDeliveryPreference$outboundSchema; } /** @internal */ export const InterestedPartyCreate$inboundSchema: z.ZodType< InterestedPartyCreate, z.ZodTypeDef, unknown > = z.object({ mailing_address: PostalAddressCreate$inboundSchema, recipient: z.string(), statement_delivery_preference: StatementDeliveryPreference$inboundSchema .optional(), trade_confirmation_delivery_preference: TradeConfirmationDeliveryPreference$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "mailing_address": "mailingAddress", "statement_delivery_preference": "statementDeliveryPreference", "trade_confirmation_delivery_preference": "tradeConfirmationDeliveryPreference", }); }); /** @internal */ export type InterestedPartyCreate$Outbound = { mailing_address: PostalAddressCreate$Outbound; recipient: string; statement_delivery_preference?: string | undefined; trade_confirmation_delivery_preference?: string | undefined; }; /** @internal */ export const InterestedPartyCreate$outboundSchema: z.ZodType< InterestedPartyCreate$Outbound, z.ZodTypeDef, InterestedPartyCreate > = z.object({ mailingAddress: PostalAddressCreate$outboundSchema, recipient: z.string(), statementDeliveryPreference: StatementDeliveryPreference$outboundSchema .optional(), tradeConfirmationDeliveryPreference: TradeConfirmationDeliveryPreference$outboundSchema.optional(), }).transform((v) => { return remap$(v, { mailingAddress: "mailing_address", statementDeliveryPreference: "statement_delivery_preference", tradeConfirmationDeliveryPreference: "trade_confirmation_delivery_preference", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace InterestedPartyCreate$ { /** @deprecated use `InterestedPartyCreate$inboundSchema` instead. */ export const inboundSchema = InterestedPartyCreate$inboundSchema; /** @deprecated use `InterestedPartyCreate$outboundSchema` instead. */ export const outboundSchema = InterestedPartyCreate$outboundSchema; /** @deprecated use `InterestedPartyCreate$Outbound` instead. */ export type Outbound = InterestedPartyCreate$Outbound; } export function interestedPartyCreateToJSON( interestedPartyCreate: InterestedPartyCreate, ): string { return JSON.stringify( InterestedPartyCreate$outboundSchema.parse(interestedPartyCreate), ); } export function interestedPartyCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => InterestedPartyCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InterestedPartyCreate' from JSON`, ); }