/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Allocation, Allocation$inboundSchema } from "./allocation.js"; import { Currency, Currency$inboundSchema } from "./currency.js"; import { CustomField, CustomField$inboundSchema } from "./customfield.js"; import { DeprecatedLinkedSupplier, DeprecatedLinkedSupplier$inboundSchema, } from "./deprecatedlinkedsupplier.js"; import { LinkedCustomer, LinkedCustomer$inboundSchema, } from "./linkedcustomer.js"; import { LinkedLedgerAccount, LinkedLedgerAccount$inboundSchema, } from "./linkedledgeraccount.js"; import { LinkedSubsidiary, LinkedSubsidiary$inboundSchema, } from "./linkedsubsidiary.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, } from "./linkedtrackingcategory.js"; import { PassThroughBody, PassThroughBody$inboundSchema, } from "./passthroughbody.js"; import { PaymentStatus, PaymentStatus$inboundSchema } from "./paymentstatus.js"; import { PaymentType, PaymentType$inboundSchema } from "./paymenttype.js"; export type Payment = { /** * A unique identifier for an object. */ id: string; /** * The third-party API ID of original entity */ downstreamId?: string | null | undefined; /** * Indicates the associated currency for an amount of money. Values correspond to [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217). */ currency?: Currency | null | undefined; /** * Currency Exchange Rate at the time entity was recorded/generated. */ currencyRate?: number | null | undefined; /** * The total amount of the transaction or record */ totalAmount: number | null; /** * Optional transaction reference message ie: Debit remittance detail. */ reference?: string | null | undefined; /** * Payment method used for the transaction, such as cash, credit card, bank transfer, or check */ paymentMethod?: string | null | undefined; /** * Optional reference message returned by payment method on processing */ paymentMethodReference?: string | null | undefined; /** * A unique identifier for an object. */ paymentMethodId?: string | null | undefined; /** * Type of accounts receivable account. * * @deprecated field: This field is deprecated and may be removed in a future version.. */ accountsReceivableAccountType?: string | null | undefined; /** * Unique identifier for the account to allocate payment to. * * @deprecated field: This field is deprecated and may be removed in a future version.. */ accountsReceivableAccountId?: string | null | undefined; account?: LinkedLedgerAccount | null | undefined; /** * The date of the transaction - YYYY:MM::DDThh:mm:ss.sTZD */ transactionDate: Date | null; /** * The customer this entity is linked to. */ customer?: LinkedCustomer | null | undefined; /** * The supplier this entity is linked to. * * @deprecated field: This field is deprecated and may be removed in a future version.. */ supplier?: DeprecatedLinkedSupplier | null | undefined; /** * The company ID the transaction belongs to */ companyId?: string | null | undefined; subsidiary?: LinkedSubsidiary | null | undefined; /** * Indicates if the transaction has been reconciled. */ reconciled?: boolean | null | undefined; /** * Status of payment */ status?: PaymentStatus | undefined; /** * Type of payment */ type?: PaymentType | undefined; allocations?: Array | undefined; /** * Note associated with the transaction */ note?: string | null | undefined; /** * Number associated with the transaction */ number?: string | null | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | null | undefined; customFields?: Array | undefined; /** * A binary value used to detect updates to a object and prevent data conflicts. It is incremented each time an update is made to the object. */ rowVersion?: string | null | undefined; /** * Id to be displayed. */ displayId?: string | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | null | undefined; /** * The user who last updated the object. */ updatedBy?: string | null | undefined; /** * The user who created the object. */ createdBy?: string | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; /** @internal */ export const Payment$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), downstream_id: z.nullable(types.string()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), currency_rate: z.nullable(types.number()).optional(), total_amount: types.nullable(types.number()), reference: z.nullable(types.string()).optional(), payment_method: z.nullable(types.string()).optional(), payment_method_reference: z.nullable(types.string()).optional(), payment_method_id: z.nullable(types.string()).optional(), accounts_receivable_account_type: z.nullable(types.string()).optional(), accounts_receivable_account_id: z.nullable(types.string()).optional(), account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), transaction_date: types.nullable(types.date()), customer: z.nullable(LinkedCustomer$inboundSchema).optional(), supplier: z.nullable(DeprecatedLinkedSupplier$inboundSchema).optional(), company_id: z.nullable(types.string()).optional(), subsidiary: z.nullable(LinkedSubsidiary$inboundSchema).optional(), reconciled: z.nullable(types.boolean()).optional(), status: types.optional(PaymentStatus$inboundSchema), type: types.optional(PaymentType$inboundSchema), allocations: types.optional(z.array(Allocation$inboundSchema)), note: z.nullable(types.string()).optional(), number: z.nullable(types.string()).optional(), tracking_categories: z.nullable( z.array(types.nullable(LinkedTrackingCategory$inboundSchema)), ).optional(), custom_fields: types.optional(z.array(CustomField$inboundSchema)), row_version: z.nullable(types.string()).optional(), display_id: z.nullable(types.string()).optional(), custom_mappings: z.nullable(z.record(z.any())).optional(), updated_by: z.nullable(types.string()).optional(), created_by: z.nullable(types.string()).optional(), created_at: z.nullable(types.date()).optional(), updated_at: z.nullable(types.date()).optional(), pass_through: types.optional(z.array(PassThroughBody$inboundSchema)), }).transform((v) => { return remap$(v, { "downstream_id": "downstreamId", "currency_rate": "currencyRate", "total_amount": "totalAmount", "payment_method": "paymentMethod", "payment_method_reference": "paymentMethodReference", "payment_method_id": "paymentMethodId", "accounts_receivable_account_type": "accountsReceivableAccountType", "accounts_receivable_account_id": "accountsReceivableAccountId", "transaction_date": "transactionDate", "company_id": "companyId", "tracking_categories": "trackingCategories", "custom_fields": "customFields", "row_version": "rowVersion", "display_id": "displayId", "custom_mappings": "customMappings", "updated_by": "updatedBy", "created_by": "createdBy", "created_at": "createdAt", "updated_at": "updatedAt", "pass_through": "passThrough", }); }) ); export function paymentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Payment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Payment' from JSON`, ); }