/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../../lib/schemas.js"; import { Decimal as Decimal$ } from "../../types/decimal.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { BankAccountStatus, BankAccountStatus$inboundSchema, } from "./bankaccountstatus.js"; import { DataType, DataType$inboundSchema } from "./datatype.js"; import { PushOperationChange, PushOperationChange$inboundSchema, } from "./pushoperationchange.js"; import { PushOperationStatus, PushOperationStatus$inboundSchema, } from "./pushoperationstatus.js"; import { Validation, Validation$inboundSchema } from "./validation.js"; /** * The type of transactions and balances on the account. * * @remarks * For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. * For Debit accounts, positive balances are assets, and positive transactions **increase** assets. */ export const BankAccountCreateResponseBankAccountType = { Unknown: "Unknown", Credit: "Credit", Debit: "Debit", } as const; /** * The type of transactions and balances on the account. * * @remarks * For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. * For Debit accounts, positive balances are assets, and positive transactions **increase** assets. */ export type BankAccountCreateResponseBankAccountType = ClosedEnum< typeof BankAccountCreateResponseBankAccountType >; export type BankAccountCreateResponseMetadata = { /** * Indicates whether the record has been deleted in the third-party system this record originated from. */ isDeleted?: boolean | null | undefined; }; /** * Supplemental data is additional data you can include in our standard data types. * * @remarks * * It is referenced as a configured dynamic key value pair that is unique to the accounting software. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. */ export type BankAccountCreateResponseSupplementalData = { content?: { [k: string]: { [k: string]: any } } | null | undefined; }; /** * > **Accessing Bank Accounts through Banking API** * * @remarks * > * > This datatype was originally used for accessing bank account data both in accounting integrations and open banking aggregators. * > * > To view bank account data through the Banking API, please refer to the new [Banking: Account](https://docs.codat.io/bank-feeds-api#/schemas/Account) data type. * * ## Overview * * A list of bank accounts associated with a company and a specific data connection. * * Bank accounts data includes: * * The name and ID of the account in the accounting software. * * The currency and balance of the account. * * The sort code and account number. * * @deprecated class: This will be removed in a future release, please migrate away from it as soon as possible. */ export type BankAccountCreateResponseAccountingBankAccount = { modifiedDate?: string | undefined; sourceModifiedDate?: string | undefined; /** * Identifier for the account, unique for the company in the accounting software. */ id?: string | undefined; /** * Name of the bank account in the accounting software. */ accountName?: string | null | undefined; /** * The type of transactions and balances on the account. * * @remarks * For Credit accounts, positive balances are liabilities, and positive transactions **reduce** liabilities. * For Debit accounts, positive balances are assets, and positive transactions **increase** assets. */ accountType?: BankAccountCreateResponseBankAccountType | undefined; /** * Code used to identify each nominal account for a business. */ nominalCode?: string | null | undefined; /** * Sort code for the bank account. * * @remarks * * Xero integrations * The sort code is only displayed when the currency = GBP and the sort code and account number sum to 14 digits. For non-GBP accounts, this field is not populated. */ sortCode?: string | null | undefined; /** * Account number for the bank account. * * @remarks * * Xero integrations * Only a UK account number shows for bank accounts with GBP currency and a combined total of sort code and account number that equals 14 digits, For non-GBP accounts, the full bank account number is populated. * * FreeAgent integrations * For Credit accounts, only the last four digits are required. For other types, the field is optional. */ accountNumber?: string | null | undefined; /** * International bank account number of the account. Often used when making or receiving international payments. */ iBan?: string | null | undefined; /** * The currency data type in Codat is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, e.g. _GBP_. * * @remarks * * ## Unknown currencies * * In line with the ISO 4217 specification, the code _XXX_ is used when the data source does not return a currency for a transaction. * * There are only a very small number of edge cases where this currency code is returned by the Codat system. */ currency?: string | undefined; /** * Balance of the bank account. */ balance?: Decimal$ | number | null | undefined; /** * The institution of the bank account. */ institution?: string | null | undefined; /** * Total available balance of the bank account as reported by the underlying data source. This may take into account overdrafts or pending transactions for example. */ availableBalance?: Decimal$ | number | null | undefined; /** * Pre-arranged overdraft limit of the account. * * @remarks * * The value is always positive. For example, an overdraftLimit of `1000` means that the balance of the account can go down to `-1000`. */ overdraftLimit?: Decimal$ | number | null | undefined; /** * Status of the bank account. */ status?: BankAccountStatus | undefined; metadata?: BankAccountCreateResponseMetadata | undefined; /** * Supplemental data is additional data you can include in our standard data types. * * @remarks * * It is referenced as a configured dynamic key value pair that is unique to the accounting software. [Learn more](https://docs.codat.io/using-the-api/supplemental-data/overview) about supplemental data. */ supplementalData?: BankAccountCreateResponseSupplementalData | undefined; }; export type BankAccountCreateResponse = { data?: BankAccountCreateResponseAccountingBankAccount | null | undefined; /** * Contains a single entry that communicates which record has changed and the manner in which it changed. */ changes?: Array | null | undefined; /** * Available data types */ dataType?: DataType | undefined; /** * Unique identifier for your SMB in Codat. */ companyId: string; /** * A unique identifier generated by Codat to represent this single push operation. This identifier can be used to track the status of the push, and should be persisted. */ pushOperationKey: string; /** * Unique identifier for a company's data connection. */ dataConnectionKey: string; /** * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: * * @remarks * * ``` * 2020-10-08T22:40:50Z * 2021-01-01T00:00:00 * ``` * * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: * * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` * - Unqualified local time: `2021-11-15T01:00:00` * - UTC time offsets: `2021-11-15T01:00:00-05:00` * * > Time zones * > * > Not all dates from Codat will contain information about time zones. * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. */ requestedOnUtc: string; /** * In Codat's data model, dates and times are represented using the ISO 8601 standard. Date and time fields are formatted as strings; for example: * * @remarks * * ``` * 2020-10-08T22:40:50Z * 2021-01-01T00:00:00 * ``` * * When syncing data that contains `DateTime` fields from Codat, make sure you support the following cases when reading time information: * * - Coordinated Universal Time (UTC): `2021-11-15T06:00:00Z` * - Unqualified local time: `2021-11-15T01:00:00` * - UTC time offsets: `2021-11-15T01:00:00-05:00` * * > Time zones * > * > Not all dates from Codat will contain information about time zones. * > Where it is not available from the underlying platform, Codat will return these as times local to the business whose data has been synced. */ completedOnUtc?: string | undefined; /** * Number of minutes the push operation must complete within before it times out. */ timeoutInMinutes?: number | null | undefined; /** * Number of seconds the push operation must complete within before it times out. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ timeoutInSeconds?: number | null | undefined; /** * The current status of the push operation. */ status: PushOperationStatus; /** * A message about the error. */ errorMessage?: string | null | undefined; /** * A human-readable object describing validation decisions Codat has made when pushing data into the platform. If a push has failed because of validation errors, they will be detailed here. */ validation?: Validation | undefined; /** * Push status code. */ statusCode: number; }; /** @internal */ export const BankAccountCreateResponseBankAccountType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(BankAccountCreateResponseBankAccountType); /** @internal */ export const BankAccountCreateResponseMetadata$inboundSchema: z.ZodType< BankAccountCreateResponseMetadata, z.ZodTypeDef, unknown > = z.object({ isDeleted: z.nullable(z.boolean()).optional(), }); export function bankAccountCreateResponseMetadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BankAccountCreateResponseMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BankAccountCreateResponseMetadata' from JSON`, ); } /** @internal */ export const BankAccountCreateResponseSupplementalData$inboundSchema: z.ZodType< BankAccountCreateResponseSupplementalData, z.ZodTypeDef, unknown > = z.object({ content: z.nullable(z.record(z.record(z.any()))).optional(), }); export function bankAccountCreateResponseSupplementalDataFromJSON( jsonString: string, ): SafeParseResult< BankAccountCreateResponseSupplementalData, SDKValidationError > { return safeParse( jsonString, (x) => BankAccountCreateResponseSupplementalData$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'BankAccountCreateResponseSupplementalData' from JSON`, ); } /** @internal */ export const BankAccountCreateResponseAccountingBankAccount$inboundSchema: z.ZodType< BankAccountCreateResponseAccountingBankAccount, z.ZodTypeDef, unknown > = z.object({ modifiedDate: z.string().optional(), sourceModifiedDate: z.string().optional(), id: z.string().optional(), accountName: z.nullable(z.string()).optional(), accountType: BankAccountCreateResponseBankAccountType$inboundSchema .optional(), nominalCode: z.nullable(z.string()).optional(), sortCode: z.nullable(z.string()).optional(), accountNumber: z.nullable(z.string()).optional(), iBan: z.nullable(z.string()).optional(), currency: z.string().optional(), balance: z.nullable(z.number().transform(v => new Decimal$(v))).optional(), institution: z.nullable(z.string()).optional(), availableBalance: z.nullable(z.number().transform(v => new Decimal$(v))) .optional(), overdraftLimit: z.nullable(z.number().transform(v => new Decimal$(v))) .optional(), status: BankAccountStatus$inboundSchema.optional(), metadata: z.lazy(() => BankAccountCreateResponseMetadata$inboundSchema) .optional(), supplementalData: z.lazy(() => BankAccountCreateResponseSupplementalData$inboundSchema ).optional(), }); export function bankAccountCreateResponseAccountingBankAccountFromJSON( jsonString: string, ): SafeParseResult< BankAccountCreateResponseAccountingBankAccount, SDKValidationError > { return safeParse( jsonString, (x) => BankAccountCreateResponseAccountingBankAccount$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'BankAccountCreateResponseAccountingBankAccount' from JSON`, ); } /** @internal */ export const BankAccountCreateResponse$inboundSchema: z.ZodType< BankAccountCreateResponse, z.ZodTypeDef, unknown > = z.object({ data: z.nullable( z.lazy(() => BankAccountCreateResponseAccountingBankAccount$inboundSchema), ).optional(), changes: z.nullable(z.array(PushOperationChange$inboundSchema)).optional(), dataType: DataType$inboundSchema.optional(), companyId: z.string(), pushOperationKey: z.string(), dataConnectionKey: z.string(), requestedOnUtc: z.string(), completedOnUtc: z.string().optional(), timeoutInMinutes: z.nullable(z.number().int()).optional(), timeoutInSeconds: z.nullable(z.number().int()).optional(), status: PushOperationStatus$inboundSchema, errorMessage: z.nullable(z.string()).optional(), validation: Validation$inboundSchema.optional(), statusCode: z.number().int(), }); export function bankAccountCreateResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BankAccountCreateResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BankAccountCreateResponse' from JSON`, ); }