/* * 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 { CreateTransferDestination, CreateTransferDestination$inboundSchema, CreateTransferDestination$Outbound, CreateTransferDestination$outboundSchema, } from "./createtransferdestination.js"; import { CreateTransferLineItems, CreateTransferLineItems$inboundSchema, CreateTransferLineItems$Outbound, CreateTransferLineItems$outboundSchema, } from "./createtransferlineitems.js"; import { CreateTransferSource, CreateTransferSource$inboundSchema, CreateTransferSource$Outbound, CreateTransferSource$outboundSchema, } from "./createtransfersource.js"; import { FacilitatorFee, FacilitatorFee$inboundSchema, FacilitatorFee$Outbound, FacilitatorFee$outboundSchema, } from "./facilitatorfee.js"; export type CreateTransfer = { /** * Where funds for a transfer originate. For the source, you must include either a `paymentMethodID` or a `transferID`. */ source: CreateTransferSource; /** * The final stage of a transfer and the ultimate recipient of the funds. */ destination: CreateTransferDestination; amount: Amount; /** * Total or markup fee. */ facilitatorFee?: FacilitatorFee | undefined; /** * 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; /** * 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?: CreateTransferLineItems | undefined; }; /** @internal */ export const CreateTransfer$inboundSchema: z.ZodType< CreateTransfer, z.ZodTypeDef, unknown > = z.object({ source: CreateTransferSource$inboundSchema, destination: CreateTransferDestination$inboundSchema, amount: Amount$inboundSchema, facilitatorFee: FacilitatorFee$inboundSchema.optional(), description: z.string().optional(), metadata: z.record(z.string()).optional(), salesTaxAmount: Amount$inboundSchema.optional(), foreignID: z.string().optional(), lineItems: CreateTransferLineItems$inboundSchema.optional(), }); /** @internal */ export type CreateTransfer$Outbound = { source: CreateTransferSource$Outbound; destination: CreateTransferDestination$Outbound; amount: Amount$Outbound; facilitatorFee?: FacilitatorFee$Outbound | undefined; description?: string | undefined; metadata?: { [k: string]: string } | undefined; salesTaxAmount?: Amount$Outbound | undefined; foreignID?: string | undefined; lineItems?: CreateTransferLineItems$Outbound | undefined; }; /** @internal */ export const CreateTransfer$outboundSchema: z.ZodType< CreateTransfer$Outbound, z.ZodTypeDef, CreateTransfer > = z.object({ source: CreateTransferSource$outboundSchema, destination: CreateTransferDestination$outboundSchema, amount: Amount$outboundSchema, facilitatorFee: FacilitatorFee$outboundSchema.optional(), description: z.string().optional(), metadata: z.record(z.string()).optional(), salesTaxAmount: Amount$outboundSchema.optional(), foreignID: z.string().optional(), lineItems: CreateTransferLineItems$outboundSchema.optional(), }); export function createTransferToJSON(createTransfer: CreateTransfer): string { return JSON.stringify(CreateTransfer$outboundSchema.parse(createTransfer)); } export function createTransferFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateTransfer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateTransfer' from JSON`, ); }