/* * 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 { DateCreate, DateCreate$inboundSchema, DateCreate$Outbound, DateCreate$outboundSchema, } from "./datecreate.js"; import { EntityDueDiligenceCreate, EntityDueDiligenceCreate$inboundSchema, EntityDueDiligenceCreate$Outbound, EntityDueDiligenceCreate$outboundSchema, } from "./entityduediligencecreate.js"; import { LargeTraderCreate, LargeTraderCreate$inboundSchema, LargeTraderCreate$Outbound, LargeTraderCreate$outboundSchema, } from "./largetradercreate.js"; import { PostalAddressCreate, PostalAddressCreate$inboundSchema, PostalAddressCreate$Outbound, PostalAddressCreate$outboundSchema, } from "./postaladdresscreate.js"; import { TaxProfileCreate, TaxProfileCreate$inboundSchema, TaxProfileCreate$Outbound, TaxProfileCreate$outboundSchema, } from "./taxprofilecreate.js"; export enum BusinessIndustrialClassification { BusinessIndustrialClassificationUnspecified = "BUSINESS_INDUSTRIAL_CLASSIFICATION_UNSPECIFIED", AgricultureForestryAndFishing = "AGRICULTURE_FORESTRY_AND_FISHING", Mining = "MINING", Construction = "CONSTRUCTION", Manufacturing = "MANUFACTURING", TransportationCommunicationsElectricGasAndSanitaryServices = "TRANSPORTATION_COMMUNICATIONS_ELECTRIC_GAS_AND_SANITARY_SERVICES", WholesaleTrade = "WHOLESALE_TRADE", RetailTrade = "RETAIL_TRADE", FinanceInsuranceAndRealEstate = "FINANCE_INSURANCE_AND_REAL_ESTATE", Services = "SERVICES", PublicAdministration = "PUBLIC_ADMINISTRATION", } export type BusinessIndustrialClassificationOpen = OpenEnum< typeof BusinessIndustrialClassification >; /** * Corporate structure of the entity. */ export enum CorporateStructure { EntityCorporateStructureUnspecified = "ENTITY_CORPORATE_STRUCTURE_UNSPECIFIED", CorporationCCorp = "CORPORATION_C_CORP", CorporationSCorp = "CORPORATION_S_CORP", CorporationBCorp = "CORPORATION_B_CORP", CorporationNonprofit = "CORPORATION_NONPROFIT", } /** * Corporate structure of the entity. */ export type CorporateStructureOpen = OpenEnum; /** * The entity type. */ export enum EntityType { EntityTypeUnspecified = "ENTITY_TYPE_UNSPECIFIED", Corporation = "CORPORATION", LimitedLiabilityCompany = "LIMITED_LIABILITY_COMPANY", Trust = "TRUST", Estate = "ESTATE", } /** * The entity type. */ export type EntityTypeOpen = OpenEnum; /** * **Field Dependencies:** * * @remarks * * Exempt entities must set `exempt_verifying_beneficial_owners` to `true` and provide an `exempt_customer_reason` on the owner record. * * Required if `exempt_verifying_beneficial_owners` is `true`. * * Otherwise, must be empty. */ export enum ExemptCustomerReason { ExemptReasonUnspecified = "EXEMPT_REASON_UNSPECIFIED", RegulatedFinancialInstitution = "REGULATED_FINANCIAL_INSTITUTION", DepartmentOrAgencyOfFederalStateOrSubdivision = "DEPARTMENT_OR_AGENCY_OF_FEDERAL_STATE_OR_SUBDIVISION", NonBankListedEntity = "NON_BANK_LISTED_ENTITY", Section12SecuritiesExchangeAct1934Or15D = "SECTION_12_SECURITIES_EXCHANGE_ACT_1934_OR_15D", Section3InvestmentCompanyAct1940 = "SECTION_3_INVESTMENT_COMPANY_ACT_1940", Section202AInvestmentAdvisorsAct1940 = "SECTION_202A_INVESTMENT_ADVISORS_ACT_1940", Section3SecuritiesExchangeAct1934Section6Or17A = "SECTION_3_SECURITIES_EXCHANGE_ACT_1934_SECTION_6_OR_17A", AnyOtherSecuritiesExchangeAct1934 = "ANY_OTHER_SECURITIES_EXCHANGE_ACT_1934", CommodityFuturesTradingCommissionRegistered = "COMMODITY_FUTURES_TRADING_COMMISSION_REGISTERED", PublicAccountingFirmSection102SarbanesOxley = "PUBLIC_ACCOUNTING_FIRM_SECTION_102_SARBANES_OXLEY", StateRegulatedInsuranceCompany = "STATE_REGULATED_INSURANCE_COMPANY", } /** * **Field Dependencies:** * * @remarks * * Exempt entities must set `exempt_verifying_beneficial_owners` to `true` and provide an `exempt_customer_reason` on the owner record. * * Required if `exempt_verifying_beneficial_owners` is `true`. * * Otherwise, must be empty. */ export type ExemptCustomerReasonOpen = OpenEnum; /** * The nature of the U.S. Tax ID indicated in the related tax_id field; Examples include ITIN, SSN, EIN. */ export enum LegalEntityCreateTaxIdType { TaxIdTypeUnspecified = "TAX_ID_TYPE_UNSPECIFIED", TaxIdTypeSsn = "TAX_ID_TYPE_SSN", TaxIdTypeItin = "TAX_ID_TYPE_ITIN", TaxIdTypeEin = "TAX_ID_TYPE_EIN", } /** * The nature of the U.S. Tax ID indicated in the related tax_id field; Examples include ITIN, SSN, EIN. */ export type LegalEntityCreateTaxIdTypeOpen = OpenEnum< typeof LegalEntityCreateTaxIdType >; /** * A legal entity. Legal entities are organizations, such as companies, that participate in financial transactions */ export type LegalEntityCreate = { /** * Indicates whether the entity is an accredited investor. By default, this is set to `false`. */ accreditedInvestor?: boolean | undefined; /** * Indicates whether the entity is an adviser. By default, this is set to `false`. */ adviser?: boolean | undefined; /** * Indicates whether the entity is a broker dealer. By default, this is set to `false`. */ brokerDealer?: boolean | undefined; businessIndustrialClassification?: | BusinessIndustrialClassificationOpen | undefined; /** * An external identifier for the legal entity. This identifier does not have internal uniqueness constraints. */ clientEntityId?: string | undefined; /** * Corporate structure of the entity. */ corporateStructure?: CorporateStructureOpen | undefined; /** * The correspondent id associated with the legal entity. */ correspondentId: string; /** * DBA (Doing Business As) names. Can list up to 5 associated with the Legal Entity */ doingBusinessAs?: Array | undefined; /** * Due Diligence for Legal Entities required when a Legal Entity is the Primary Owner on an Account. */ entityDueDiligence?: EntityDueDiligenceCreate | undefined; /** * The legal entity name. */ entityName: string; /** * The entity type. */ entityType: EntityTypeOpen; /** * **Field Dependencies:** * * @remarks * * Exempt entities must set `exempt_verifying_beneficial_owners` to `true` and provide an `exempt_customer_reason` on the owner record. * * Required if `exempt_verifying_beneficial_owners` is `true`. * * Otherwise, must be empty. */ exemptCustomerReason?: ExemptCustomerReasonOpen | undefined; /** * Indicates whether the entity is exempt from verifying beneficial owners and Enhanced Due Diligence. By default, this is set to `false` */ exemptVerifyingBeneficialOwners?: boolean | undefined; /** * If the legal entity is a trust, they may set this field to convey ownership and value to a trustee. */ forTheBenefitOf?: string | undefined; /** * Indicates whether the entity is a foreign financial institution. By default, this is set to `false`. */ foreignFinancialInstitution?: boolean | undefined; /** * Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * * @remarks * * * A full date, with non-zero year, month, and day values * A month and day value, with a zero year, such as an anniversary * A year on its own, with zero month and day values * A year and month value, with a zero day, such as a credit card expiration date * * Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and `google.protobuf.Timestamp`. */ formationDate?: DateCreate | undefined; /** * Indicates whether the entity is an institutional customer. By default, this is set to `false`. */ institutionalCustomer?: boolean | undefined; /** * A large trader. */ largeTrader?: LargeTraderCreate | undefined; /** * 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 */ legalAddress: PostalAddressCreate; /** * The Legal Entity Identifier (LEI) is the financial industry term for a unique global identifier for legal entities participating in financial transactions */ leiCode?: string | undefined; /** * The operational footprint of an entity. Operating regions encompass all countries and regions where a company has a significant business presence This includes locations with physical offices, manufacturing plants, service centers, and sales and marketing activities Regions must be provided as two-character CLDR country codes */ operatingRegions: Array; /** * The legal home of an entity. A region of registration, in the context of a corporation, refers to the specific geographic area where the corporation is legally registered and incorporated Defines the legal jurisdiction and framework under which the corporation operates, including legal regulations, tax obligations, and compliance requirements Region must be provided as a two-character CLDR country code */ registrationRegion: string; /** * Indicates whether the entity is a regulated investment company. By default, this is set to `false`. */ regulatedInvestmentCompany?: boolean | undefined; /** * Document ids related to the legal entity. At least one is required for RIA correspondents when creating Estate or Trust accounts. */ relatedDocumentIds?: Array | undefined; /** * Indicates whether the trust is a revocable trust. By default, this is set to `false`. */ revocableTrust?: boolean | undefined; /** * Boolean indicator whether the LE is subject to backup withholding. By default, this is set to `false`. */ subjectToBackupWithholding?: boolean | undefined; /** * The full U.S. tax ID for a related entity; Must be provided with `EIN` tax ID type */ taxId: string; /** * The nature of the U.S. Tax ID indicated in the related tax_id field; Examples include ITIN, SSN, EIN. */ taxIdType: LegalEntityCreateTaxIdTypeOpen; /** * Tax Profile pertaining to the Legal Entity or Natural Person. */ taxProfile: TaxProfileCreate; }; /** @internal */ export const BusinessIndustrialClassification$inboundSchema: z.ZodType< BusinessIndustrialClassificationOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BusinessIndustrialClassification), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BusinessIndustrialClassification$outboundSchema: z.ZodType< BusinessIndustrialClassificationOpen, z.ZodTypeDef, BusinessIndustrialClassificationOpen > = z.union([ z.nativeEnum(BusinessIndustrialClassification), 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 BusinessIndustrialClassification$ { /** @deprecated use `BusinessIndustrialClassification$inboundSchema` instead. */ export const inboundSchema = BusinessIndustrialClassification$inboundSchema; /** @deprecated use `BusinessIndustrialClassification$outboundSchema` instead. */ export const outboundSchema = BusinessIndustrialClassification$outboundSchema; } /** @internal */ export const CorporateStructure$inboundSchema: z.ZodType< CorporateStructureOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(CorporateStructure), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const CorporateStructure$outboundSchema: z.ZodType< CorporateStructureOpen, z.ZodTypeDef, CorporateStructureOpen > = z.union([ z.nativeEnum(CorporateStructure), 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 CorporateStructure$ { /** @deprecated use `CorporateStructure$inboundSchema` instead. */ export const inboundSchema = CorporateStructure$inboundSchema; /** @deprecated use `CorporateStructure$outboundSchema` instead. */ export const outboundSchema = CorporateStructure$outboundSchema; } /** @internal */ export const EntityType$inboundSchema: z.ZodType< EntityTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(EntityType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const EntityType$outboundSchema: z.ZodType< EntityTypeOpen, z.ZodTypeDef, EntityTypeOpen > = z.union([ z.nativeEnum(EntityType), 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 EntityType$ { /** @deprecated use `EntityType$inboundSchema` instead. */ export const inboundSchema = EntityType$inboundSchema; /** @deprecated use `EntityType$outboundSchema` instead. */ export const outboundSchema = EntityType$outboundSchema; } /** @internal */ export const ExemptCustomerReason$inboundSchema: z.ZodType< ExemptCustomerReasonOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(ExemptCustomerReason), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const ExemptCustomerReason$outboundSchema: z.ZodType< ExemptCustomerReasonOpen, z.ZodTypeDef, ExemptCustomerReasonOpen > = z.union([ z.nativeEnum(ExemptCustomerReason), 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 ExemptCustomerReason$ { /** @deprecated use `ExemptCustomerReason$inboundSchema` instead. */ export const inboundSchema = ExemptCustomerReason$inboundSchema; /** @deprecated use `ExemptCustomerReason$outboundSchema` instead. */ export const outboundSchema = ExemptCustomerReason$outboundSchema; } /** @internal */ export const LegalEntityCreateTaxIdType$inboundSchema: z.ZodType< LegalEntityCreateTaxIdTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(LegalEntityCreateTaxIdType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const LegalEntityCreateTaxIdType$outboundSchema: z.ZodType< LegalEntityCreateTaxIdTypeOpen, z.ZodTypeDef, LegalEntityCreateTaxIdTypeOpen > = z.union([ z.nativeEnum(LegalEntityCreateTaxIdType), 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 LegalEntityCreateTaxIdType$ { /** @deprecated use `LegalEntityCreateTaxIdType$inboundSchema` instead. */ export const inboundSchema = LegalEntityCreateTaxIdType$inboundSchema; /** @deprecated use `LegalEntityCreateTaxIdType$outboundSchema` instead. */ export const outboundSchema = LegalEntityCreateTaxIdType$outboundSchema; } /** @internal */ export const LegalEntityCreate$inboundSchema: z.ZodType< LegalEntityCreate, z.ZodTypeDef, unknown > = z.object({ accredited_investor: z.boolean().optional(), adviser: z.boolean().optional(), broker_dealer: z.boolean().optional(), business_industrial_classification: BusinessIndustrialClassification$inboundSchema.optional(), client_entity_id: z.string().optional(), corporate_structure: CorporateStructure$inboundSchema.optional(), correspondent_id: z.string(), doing_business_as: z.array(z.string()).optional(), entity_due_diligence: EntityDueDiligenceCreate$inboundSchema.optional(), entity_name: z.string(), entity_type: EntityType$inboundSchema, exempt_customer_reason: ExemptCustomerReason$inboundSchema.optional(), exempt_verifying_beneficial_owners: z.boolean().optional(), for_the_benefit_of: z.string().optional(), foreign_financial_institution: z.boolean().optional(), formation_date: DateCreate$inboundSchema.optional(), institutional_customer: z.boolean().optional(), large_trader: LargeTraderCreate$inboundSchema.optional(), legal_address: PostalAddressCreate$inboundSchema, lei_code: z.string().optional(), operating_regions: z.array(z.string()), registration_region: z.string(), regulated_investment_company: z.boolean().optional(), related_document_ids: z.array(z.string()).optional(), revocable_trust: z.boolean().optional(), subject_to_backup_withholding: z.boolean().optional(), tax_id: z.string(), tax_id_type: LegalEntityCreateTaxIdType$inboundSchema, tax_profile: TaxProfileCreate$inboundSchema, }).transform((v) => { return remap$(v, { "accredited_investor": "accreditedInvestor", "broker_dealer": "brokerDealer", "business_industrial_classification": "businessIndustrialClassification", "client_entity_id": "clientEntityId", "corporate_structure": "corporateStructure", "correspondent_id": "correspondentId", "doing_business_as": "doingBusinessAs", "entity_due_diligence": "entityDueDiligence", "entity_name": "entityName", "entity_type": "entityType", "exempt_customer_reason": "exemptCustomerReason", "exempt_verifying_beneficial_owners": "exemptVerifyingBeneficialOwners", "for_the_benefit_of": "forTheBenefitOf", "foreign_financial_institution": "foreignFinancialInstitution", "formation_date": "formationDate", "institutional_customer": "institutionalCustomer", "large_trader": "largeTrader", "legal_address": "legalAddress", "lei_code": "leiCode", "operating_regions": "operatingRegions", "registration_region": "registrationRegion", "regulated_investment_company": "regulatedInvestmentCompany", "related_document_ids": "relatedDocumentIds", "revocable_trust": "revocableTrust", "subject_to_backup_withholding": "subjectToBackupWithholding", "tax_id": "taxId", "tax_id_type": "taxIdType", "tax_profile": "taxProfile", }); }); /** @internal */ export type LegalEntityCreate$Outbound = { accredited_investor?: boolean | undefined; adviser?: boolean | undefined; broker_dealer?: boolean | undefined; business_industrial_classification?: string | undefined; client_entity_id?: string | undefined; corporate_structure?: string | undefined; correspondent_id: string; doing_business_as?: Array | undefined; entity_due_diligence?: EntityDueDiligenceCreate$Outbound | undefined; entity_name: string; entity_type: string; exempt_customer_reason?: string | undefined; exempt_verifying_beneficial_owners?: boolean | undefined; for_the_benefit_of?: string | undefined; foreign_financial_institution?: boolean | undefined; formation_date?: DateCreate$Outbound | undefined; institutional_customer?: boolean | undefined; large_trader?: LargeTraderCreate$Outbound | undefined; legal_address: PostalAddressCreate$Outbound; lei_code?: string | undefined; operating_regions: Array; registration_region: string; regulated_investment_company?: boolean | undefined; related_document_ids?: Array | undefined; revocable_trust?: boolean | undefined; subject_to_backup_withholding?: boolean | undefined; tax_id: string; tax_id_type: string; tax_profile: TaxProfileCreate$Outbound; }; /** @internal */ export const LegalEntityCreate$outboundSchema: z.ZodType< LegalEntityCreate$Outbound, z.ZodTypeDef, LegalEntityCreate > = z.object({ accreditedInvestor: z.boolean().optional(), adviser: z.boolean().optional(), brokerDealer: z.boolean().optional(), businessIndustrialClassification: BusinessIndustrialClassification$outboundSchema.optional(), clientEntityId: z.string().optional(), corporateStructure: CorporateStructure$outboundSchema.optional(), correspondentId: z.string(), doingBusinessAs: z.array(z.string()).optional(), entityDueDiligence: EntityDueDiligenceCreate$outboundSchema.optional(), entityName: z.string(), entityType: EntityType$outboundSchema, exemptCustomerReason: ExemptCustomerReason$outboundSchema.optional(), exemptVerifyingBeneficialOwners: z.boolean().optional(), forTheBenefitOf: z.string().optional(), foreignFinancialInstitution: z.boolean().optional(), formationDate: DateCreate$outboundSchema.optional(), institutionalCustomer: z.boolean().optional(), largeTrader: LargeTraderCreate$outboundSchema.optional(), legalAddress: PostalAddressCreate$outboundSchema, leiCode: z.string().optional(), operatingRegions: z.array(z.string()), registrationRegion: z.string(), regulatedInvestmentCompany: z.boolean().optional(), relatedDocumentIds: z.array(z.string()).optional(), revocableTrust: z.boolean().optional(), subjectToBackupWithholding: z.boolean().optional(), taxId: z.string(), taxIdType: LegalEntityCreateTaxIdType$outboundSchema, taxProfile: TaxProfileCreate$outboundSchema, }).transform((v) => { return remap$(v, { accreditedInvestor: "accredited_investor", brokerDealer: "broker_dealer", businessIndustrialClassification: "business_industrial_classification", clientEntityId: "client_entity_id", corporateStructure: "corporate_structure", correspondentId: "correspondent_id", doingBusinessAs: "doing_business_as", entityDueDiligence: "entity_due_diligence", entityName: "entity_name", entityType: "entity_type", exemptCustomerReason: "exempt_customer_reason", exemptVerifyingBeneficialOwners: "exempt_verifying_beneficial_owners", forTheBenefitOf: "for_the_benefit_of", foreignFinancialInstitution: "foreign_financial_institution", formationDate: "formation_date", institutionalCustomer: "institutional_customer", largeTrader: "large_trader", legalAddress: "legal_address", leiCode: "lei_code", operatingRegions: "operating_regions", registrationRegion: "registration_region", regulatedInvestmentCompany: "regulated_investment_company", relatedDocumentIds: "related_document_ids", revocableTrust: "revocable_trust", subjectToBackupWithholding: "subject_to_backup_withholding", taxId: "tax_id", taxIdType: "tax_id_type", taxProfile: "tax_profile", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace LegalEntityCreate$ { /** @deprecated use `LegalEntityCreate$inboundSchema` instead. */ export const inboundSchema = LegalEntityCreate$inboundSchema; /** @deprecated use `LegalEntityCreate$outboundSchema` instead. */ export const outboundSchema = LegalEntityCreate$outboundSchema; /** @deprecated use `LegalEntityCreate$Outbound` instead. */ export type Outbound = LegalEntityCreate$Outbound; } export function legalEntityCreateToJSON( legalEntityCreate: LegalEntityCreate, ): string { return JSON.stringify( LegalEntityCreate$outboundSchema.parse(legalEntityCreate), ); } export function legalEntityCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LegalEntityCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LegalEntityCreate' from JSON`, ); }