/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Amount, Amount$inboundSchema, Amount$Outbound, Amount$outboundSchema, } from "./amount.js"; import { Cancellation, Cancellation$inboundSchema, Cancellation$Outbound, Cancellation$outboundSchema, } from "./cancellation.js"; import { CardAcquiringDispute, CardAcquiringDispute$inboundSchema, CardAcquiringDispute$Outbound, CardAcquiringDispute$outboundSchema, } from "./cardacquiringdispute.js"; import { CardAcquiringRefund, CardAcquiringRefund$inboundSchema, CardAcquiringRefund$Outbound, CardAcquiringRefund$outboundSchema, } from "./cardacquiringrefund.js"; import { FacilitatorFee, FacilitatorFee$inboundSchema, FacilitatorFee$Outbound, FacilitatorFee$outboundSchema, } from "./facilitatorfee.js"; import { MoovFee, MoovFee$inboundSchema, MoovFee$Outbound, MoovFee$outboundSchema, } from "./moovfee.js"; import { MoovFeeDetails, MoovFeeDetails$inboundSchema, MoovFeeDetails$Outbound, MoovFeeDetails$outboundSchema, } from "./moovfeedetails.js"; import { TransferDestination, TransferDestination$inboundSchema, TransferDestination$Outbound, TransferDestination$outboundSchema, } from "./transferdestination.js"; import { TransferFailureReason, TransferFailureReason$inboundSchema, TransferFailureReason$outboundSchema, } from "./transferfailurereason.js"; import { TransferLineItems, TransferLineItems$inboundSchema, TransferLineItems$Outbound, TransferLineItems$outboundSchema, } from "./transferlineitems.js"; import { TransferSource, TransferSource$inboundSchema, TransferSource$Outbound, TransferSource$outboundSchema, } from "./transfersource.js"; import { TransferStatus, TransferStatus$inboundSchema, TransferStatus$outboundSchema, } from "./transferstatus.js"; /** * Details of a Transfer. */ export type Transfer = { transferID: string; createdOn: Date; source: TransferSource; destination: TransferDestination; completedOn?: Date | undefined; /** * Status of a transfer. */ status: TransferStatus; /** * Reason for a transfer's failure. */ failureReason?: TransferFailureReason | undefined; amount: Amount; /** * An optional description of the transfer that is used on receipts and for your own internal use. */ description?: string | undefined; /** * Free-form key-value pair list. Useful for storing information that is not captured elsewhere. */ metadata?: { [k: string]: string } | undefined; /** * Total or markup fee. */ facilitatorFee?: FacilitatorFee | undefined; /** * Fees charged to your platform account for transfers. */ moovFee?: number | undefined; /** * Same as `moovFee`, but a decimal-formatted numerical string that represents up to 9 decimal place precision. */ moovFeeDecimal?: string | undefined; /** * Processing and pass-through costs that add up to the moovFee. */ moovFeeDetails?: MoovFeeDetails | undefined; /** * Fees charged to accounts involved in the transfer. */ moovFees?: Array | undefined; groupID?: string | undefined; cancellations?: Array | undefined; refundedAmount?: Amount | undefined; refunds?: Array | undefined; disputedAmount?: Amount | undefined; disputes?: Array | undefined; /** * ID of the sweep that created this transfer. */ sweepID?: string | undefined; scheduleID?: string | undefined; occurrenceID?: string | undefined; paymentLinkCode?: string | undefined; /** * Optional sales tax amount. `transfer.amount.value` should be inclusive of any sales tax and represents the total amount charged. */ salesTaxAmount?: Amount | undefined; /** * Optional alias from a foreign/external system which can be used to reference this resource. */ foreignID?: string | undefined; /** * An optional collection of line items for a transfer. * * @remarks * When line items are provided, their total plus sales tax must equal the transfer amount. */ lineItems?: TransferLineItems | undefined; }; /** @internal */ export const Transfer$inboundSchema: z.ZodType< Transfer, z.ZodTypeDef, unknown > = z.object({ transferID: z.string(), createdOn: z.string().datetime({ offset: true }).transform(v => new Date(v)), source: TransferSource$inboundSchema, destination: TransferDestination$inboundSchema, completedOn: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), status: TransferStatus$inboundSchema, failureReason: TransferFailureReason$inboundSchema.optional(), amount: Amount$inboundSchema, description: z.string().optional(), metadata: z.record(z.string()).optional(), facilitatorFee: FacilitatorFee$inboundSchema.optional(), moovFee: z.number().int().optional(), moovFeeDecimal: z.string().optional(), moovFeeDetails: MoovFeeDetails$inboundSchema.optional(), moovFees: z.array(MoovFee$inboundSchema).optional(), groupID: z.string().optional(), cancellations: z.array(Cancellation$inboundSchema).optional(), refundedAmount: Amount$inboundSchema.optional(), refunds: z.array(CardAcquiringRefund$inboundSchema).optional(), disputedAmount: Amount$inboundSchema.optional(), disputes: z.array(CardAcquiringDispute$inboundSchema).optional(), sweepID: z.string().optional(), scheduleID: z.string().optional(), occurrenceID: z.string().optional(), paymentLinkCode: z.string().optional(), salesTaxAmount: Amount$inboundSchema.optional(), foreignID: z.string().optional(), lineItems: TransferLineItems$inboundSchema.optional(), }); /** @internal */ export type Transfer$Outbound = { transferID: string; createdOn: string; source: TransferSource$Outbound; destination: TransferDestination$Outbound; completedOn?: string | undefined; status: string; failureReason?: string | undefined; amount: Amount$Outbound; description?: string | undefined; metadata?: { [k: string]: string } | undefined; facilitatorFee?: FacilitatorFee$Outbound | undefined; moovFee?: number | undefined; moovFeeDecimal?: string | undefined; moovFeeDetails?: MoovFeeDetails$Outbound | undefined; moovFees?: Array | undefined; groupID?: string | undefined; cancellations?: Array | undefined; refundedAmount?: Amount$Outbound | undefined; refunds?: Array | undefined; disputedAmount?: Amount$Outbound | undefined; disputes?: Array | undefined; sweepID?: string | undefined; scheduleID?: string | undefined; occurrenceID?: string | undefined; paymentLinkCode?: string | undefined; salesTaxAmount?: Amount$Outbound | undefined; foreignID?: string | undefined; lineItems?: TransferLineItems$Outbound | undefined; }; /** @internal */ export const Transfer$outboundSchema: z.ZodType< Transfer$Outbound, z.ZodTypeDef, Transfer > = z.object({ transferID: z.string(), createdOn: z.date().transform(v => v.toISOString()), source: TransferSource$outboundSchema, destination: TransferDestination$outboundSchema, completedOn: z.date().transform(v => v.toISOString()).optional(), status: TransferStatus$outboundSchema, failureReason: TransferFailureReason$outboundSchema.optional(), amount: Amount$outboundSchema, description: z.string().optional(), metadata: z.record(z.string()).optional(), facilitatorFee: FacilitatorFee$outboundSchema.optional(), moovFee: z.number().int().optional(), moovFeeDecimal: z.string().optional(), moovFeeDetails: MoovFeeDetails$outboundSchema.optional(), moovFees: z.array(MoovFee$outboundSchema).optional(), groupID: z.string().optional(), cancellations: z.array(Cancellation$outboundSchema).optional(), refundedAmount: Amount$outboundSchema.optional(), refunds: z.array(CardAcquiringRefund$outboundSchema).optional(), disputedAmount: Amount$outboundSchema.optional(), disputes: z.array(CardAcquiringDispute$outboundSchema).optional(), sweepID: z.string().optional(), scheduleID: z.string().optional(), occurrenceID: z.string().optional(), paymentLinkCode: z.string().optional(), salesTaxAmount: Amount$outboundSchema.optional(), foreignID: z.string().optional(), lineItems: TransferLineItems$outboundSchema.optional(), }); export function transferToJSON(transfer: Transfer): string { return JSON.stringify(Transfer$outboundSchema.parse(transfer)); } export function transferFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Transfer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Transfer' from JSON`, ); }