/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AllocationInput, AllocationInput$inboundSchema, AllocationInput$Outbound, AllocationInput$outboundSchema, } from "./allocation.js"; import { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { CustomField, CustomField$inboundSchema, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { DeprecatedLinkedSupplierInput, DeprecatedLinkedSupplierInput$inboundSchema, DeprecatedLinkedSupplierInput$Outbound, DeprecatedLinkedSupplierInput$outboundSchema, } from "./deprecatedlinkedsupplierinput.js"; import { LinkedCustomerInput, LinkedCustomerInput$inboundSchema, LinkedCustomerInput$Outbound, LinkedCustomerInput$outboundSchema, } from "./linkedcustomerinput.js"; import { LinkedLedgerAccountInput, LinkedLedgerAccountInput$inboundSchema, LinkedLedgerAccountInput$Outbound, LinkedLedgerAccountInput$outboundSchema, } from "./linkedledgeraccountinput.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, LinkedTrackingCategory$Outbound, LinkedTrackingCategory$outboundSchema, } from "./linkedtrackingcategory.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; import { PaymentStatus, PaymentStatus$inboundSchema, PaymentStatus$outboundSchema, } from "./paymentstatus.js"; import { PaymentType, PaymentType$inboundSchema, PaymentType$outboundSchema, } from "./paymenttype.js"; export type PaymentInput = { /** * 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 */ 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 will be removed in a future release, please migrate away from it as soon as possible. */ accountsReceivableAccountType?: string | null | undefined; /** * Unique identifier for the account to allocate payment to. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ accountsReceivableAccountId?: string | null | undefined; account?: LinkedLedgerAccountInput | null | undefined; /** * The date of the transaction - YYYY:MM::DDThh:mm:ss.sTZD */ transactionDate: Date | null; /** * The customer this entity is linked to. */ customer?: LinkedCustomerInput | null | undefined; /** * The supplier this entity is linked to. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ supplier?: DeprecatedLinkedSupplierInput | null | undefined; /** * The company or subsidiary id the transaction belongs to */ companyId?: string | 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; /** * 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 PaymentInput$inboundSchema: z.ZodType< PaymentInput, z.ZodTypeDef, unknown > = z.object({ currency: z.nullable(Currency$inboundSchema).optional(), currency_rate: z.nullable(z.number()).optional(), total_amount: z.nullable(z.number()), reference: z.nullable(z.string()).optional(), payment_method: z.nullable(z.string()).optional(), payment_method_reference: z.nullable(z.string()).optional(), payment_method_id: z.nullable(z.string()).optional(), accounts_receivable_account_type: z.nullable(z.string()).optional(), accounts_receivable_account_id: z.nullable(z.string()).optional(), account: z.nullable(LinkedLedgerAccountInput$inboundSchema).optional(), transaction_date: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), customer: z.nullable(LinkedCustomerInput$inboundSchema).optional(), supplier: z.nullable(DeprecatedLinkedSupplierInput$inboundSchema).optional(), company_id: z.nullable(z.string()).optional(), reconciled: z.nullable(z.boolean()).optional(), status: PaymentStatus$inboundSchema.optional(), type: PaymentType$inboundSchema.optional(), allocations: z.array(AllocationInput$inboundSchema).optional(), note: z.nullable(z.string()).optional(), number: z.nullable(z.string()).optional(), tracking_categories: z.nullable(z.array(LinkedTrackingCategory$inboundSchema)) .optional(), custom_fields: z.array(CustomField$inboundSchema).optional(), row_version: z.nullable(z.string()).optional(), display_id: z.nullable(z.string()).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "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", "pass_through": "passThrough", }); }); /** @internal */ export type PaymentInput$Outbound = { currency?: string | null | undefined; currency_rate?: number | null | undefined; total_amount: number | null; reference?: string | null | undefined; payment_method?: string | null | undefined; payment_method_reference?: string | null | undefined; payment_method_id?: string | null | undefined; accounts_receivable_account_type?: string | null | undefined; accounts_receivable_account_id?: string | null | undefined; account?: LinkedLedgerAccountInput$Outbound | null | undefined; transaction_date: string | null; customer?: LinkedCustomerInput$Outbound | null | undefined; supplier?: DeprecatedLinkedSupplierInput$Outbound | null | undefined; company_id?: string | null | undefined; reconciled?: boolean | null | undefined; status?: string | undefined; type?: string | undefined; allocations?: Array | undefined; note?: string | null | undefined; number?: string | null | undefined; tracking_categories?: | Array | null | undefined; custom_fields?: Array | undefined; row_version?: string | null | undefined; display_id?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const PaymentInput$outboundSchema: z.ZodType< PaymentInput$Outbound, z.ZodTypeDef, PaymentInput > = z.object({ currency: z.nullable(Currency$outboundSchema).optional(), currencyRate: z.nullable(z.number()).optional(), totalAmount: z.nullable(z.number()), reference: z.nullable(z.string()).optional(), paymentMethod: z.nullable(z.string()).optional(), paymentMethodReference: z.nullable(z.string()).optional(), paymentMethodId: z.nullable(z.string()).optional(), accountsReceivableAccountType: z.nullable(z.string()).optional(), accountsReceivableAccountId: z.nullable(z.string()).optional(), account: z.nullable(LinkedLedgerAccountInput$outboundSchema).optional(), transactionDate: z.nullable(z.date().transform(v => v.toISOString())), customer: z.nullable(LinkedCustomerInput$outboundSchema).optional(), supplier: z.nullable(DeprecatedLinkedSupplierInput$outboundSchema).optional(), companyId: z.nullable(z.string()).optional(), reconciled: z.nullable(z.boolean()).optional(), status: PaymentStatus$outboundSchema.optional(), type: PaymentType$outboundSchema.optional(), allocations: z.array(AllocationInput$outboundSchema).optional(), note: z.nullable(z.string()).optional(), number: z.nullable(z.string()).optional(), trackingCategories: z.nullable(z.array(LinkedTrackingCategory$outboundSchema)) .optional(), customFields: z.array(CustomField$outboundSchema).optional(), rowVersion: z.nullable(z.string()).optional(), displayId: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { currencyRate: "currency_rate", totalAmount: "total_amount", paymentMethod: "payment_method", paymentMethodReference: "payment_method_reference", paymentMethodId: "payment_method_id", accountsReceivableAccountType: "accounts_receivable_account_type", accountsReceivableAccountId: "accounts_receivable_account_id", transactionDate: "transaction_date", companyId: "company_id", trackingCategories: "tracking_categories", customFields: "custom_fields", rowVersion: "row_version", displayId: "display_id", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PaymentInput$ { /** @deprecated use `PaymentInput$inboundSchema` instead. */ export const inboundSchema = PaymentInput$inboundSchema; /** @deprecated use `PaymentInput$outboundSchema` instead. */ export const outboundSchema = PaymentInput$outboundSchema; /** @deprecated use `PaymentInput$Outbound` instead. */ export type Outbound = PaymentInput$Outbound; } export function paymentInputToJSON(paymentInput: PaymentInput): string { return JSON.stringify(PaymentInput$outboundSchema.parse(paymentInput)); } export function paymentInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PaymentInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaymentInput' from JSON`, ); }