/* * 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"; /** * An internal indicator from where the agreement was generated; Typically `ACCOUNTS_SERVICE` if accessing our public APIs */ export enum AgreementSource { AgreementSourceUnspecified = "AGREEMENT_SOURCE_UNSPECIFIED", AtlasForm = "ATLAS_FORM", OtherSource = "OTHER_SOURCE", AccountsService = "ACCOUNTS_SERVICE", } /** * An internal indicator from where the agreement was generated; Typically `ACCOUNTS_SERVICE` if accessing our public APIs */ export type AgreementSourceOpen = OpenEnum; /** * The status of an agreement which blocks an enrollment; `REQUIRED` if not yet received, or `AFFIRMED` if acknowledgement has been received by AFS */ export enum AgreementState { AgreementStateUnspecified = "AGREEMENT_STATE_UNSPECIFIED", Required = "REQUIRED", Affirmed = "AFFIRMED", Voided = "VOIDED", } /** * The status of an agreement which blocks an enrollment; `REQUIRED` if not yet received, or `AFFIRMED` if acknowledgement has been received by AFS */ export type AgreementStateOpen = OpenEnum; /** * A legal Agreement for an Account. */ export type Agreement = { /** * The time recorded relating to when a given agreement is `AFFIRMED` by the Customer; This is set to the time when the affirmation is processed by AFS */ affirmationTime?: Date | null | undefined; /** * An Apex-generated identifier used to reference a single legal agreement associated with the account */ agreementId?: string | undefined; /** * The friendly name of the agreement; Typically mirrors the enrollment it is attached to (e.g., `LENDING_FULLY_PAID_STOCK_LOAN`) */ agreementName?: string | undefined; /** * An internal indicator from where the agreement was generated; Typically `ACCOUNTS_SERVICE` if accessing our public APIs */ agreementSource?: AgreementSourceOpen | undefined; /** * The status of an agreement which blocks an enrollment; `REQUIRED` if not yet received, or `AFFIRMED` if acknowledgement has been received by AFS */ agreementState?: AgreementStateOpen | undefined; /** * A URI referencing a static PDF containing the legalese of a given agreement; All agreements of the same nature link to the same publicly-available PDF. */ agreementUri?: string | undefined; /** * An internal version number based on typographical revisions of the related agreement; Version numbers are automatically updated when new agreements are available and should be of no technical concern to the integrator */ agreementVersion?: string | undefined; /** * A system-generated unique identifier referencing a single instance of an enrollment; Used to access the record after creation */ enrollmentId?: string | undefined; /** * References a single entity */ legalEntityId?: string | undefined; /** * References a single natural person */ legalNaturalPersonId?: string | undefined; /** * The name field Format: accounts/{account}/agreements/{agreement} */ name?: string | undefined; }; /** @internal */ export const AgreementSource$inboundSchema: z.ZodType< AgreementSourceOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(AgreementSource), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const AgreementSource$outboundSchema: z.ZodType< AgreementSourceOpen, z.ZodTypeDef, AgreementSourceOpen > = z.union([ z.nativeEnum(AgreementSource), 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 AgreementSource$ { /** @deprecated use `AgreementSource$inboundSchema` instead. */ export const inboundSchema = AgreementSource$inboundSchema; /** @deprecated use `AgreementSource$outboundSchema` instead. */ export const outboundSchema = AgreementSource$outboundSchema; } /** @internal */ export const AgreementState$inboundSchema: z.ZodType< AgreementStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(AgreementState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const AgreementState$outboundSchema: z.ZodType< AgreementStateOpen, z.ZodTypeDef, AgreementStateOpen > = z.union([ z.nativeEnum(AgreementState), 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 AgreementState$ { /** @deprecated use `AgreementState$inboundSchema` instead. */ export const inboundSchema = AgreementState$inboundSchema; /** @deprecated use `AgreementState$outboundSchema` instead. */ export const outboundSchema = AgreementState$outboundSchema; } /** @internal */ export const Agreement$inboundSchema: z.ZodType< Agreement, z.ZodTypeDef, unknown > = z.object({ affirmation_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), agreement_id: z.string().optional(), agreement_name: z.string().optional(), agreement_source: AgreementSource$inboundSchema.optional(), agreement_state: AgreementState$inboundSchema.optional(), agreement_uri: z.string().optional(), agreement_version: z.string().optional(), enrollment_id: z.string().optional(), legal_entity_id: z.string().optional(), legal_natural_person_id: z.string().optional(), name: z.string().optional(), }).transform((v) => { return remap$(v, { "affirmation_time": "affirmationTime", "agreement_id": "agreementId", "agreement_name": "agreementName", "agreement_source": "agreementSource", "agreement_state": "agreementState", "agreement_uri": "agreementUri", "agreement_version": "agreementVersion", "enrollment_id": "enrollmentId", "legal_entity_id": "legalEntityId", "legal_natural_person_id": "legalNaturalPersonId", }); }); /** @internal */ export type Agreement$Outbound = { affirmation_time?: string | null | undefined; agreement_id?: string | undefined; agreement_name?: string | undefined; agreement_source?: string | undefined; agreement_state?: string | undefined; agreement_uri?: string | undefined; agreement_version?: string | undefined; enrollment_id?: string | undefined; legal_entity_id?: string | undefined; legal_natural_person_id?: string | undefined; name?: string | undefined; }; /** @internal */ export const Agreement$outboundSchema: z.ZodType< Agreement$Outbound, z.ZodTypeDef, Agreement > = z.object({ affirmationTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), agreementId: z.string().optional(), agreementName: z.string().optional(), agreementSource: AgreementSource$outboundSchema.optional(), agreementState: AgreementState$outboundSchema.optional(), agreementUri: z.string().optional(), agreementVersion: z.string().optional(), enrollmentId: z.string().optional(), legalEntityId: z.string().optional(), legalNaturalPersonId: z.string().optional(), name: z.string().optional(), }).transform((v) => { return remap$(v, { affirmationTime: "affirmation_time", agreementId: "agreement_id", agreementName: "agreement_name", agreementSource: "agreement_source", agreementState: "agreement_state", agreementUri: "agreement_uri", agreementVersion: "agreement_version", enrollmentId: "enrollment_id", legalEntityId: "legal_entity_id", legalNaturalPersonId: "legal_natural_person_id", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Agreement$ { /** @deprecated use `Agreement$inboundSchema` instead. */ export const inboundSchema = Agreement$inboundSchema; /** @deprecated use `Agreement$outboundSchema` instead. */ export const outboundSchema = Agreement$outboundSchema; /** @deprecated use `Agreement$Outbound` instead. */ export type Outbound = Agreement$Outbound; } export function agreementToJSON(agreement: Agreement): string { return JSON.stringify(Agreement$outboundSchema.parse(agreement)); } export function agreementFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Agreement$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Agreement' from JSON`, ); }