/* * 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 { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Address, Address$inboundSchema, Address$Outbound, Address$outboundSchema, } from "./address.js"; /** * Recipient of an account funding transaction */ export type Recipient = { /** * The first name of the recipient. */ firstName: string; /** * The last name of the recipient. */ lastName: string; /** * The recipient of the fund's address. */ address?: Address | null | undefined; /** * The account number of the recipient. Depending on the type of funds transfer, this could be a wallet ID, bank accoutn number, or email address. */ accountNumber?: string | null | undefined; /** * The date of birth of the recipient. */ dateOfBirth?: RFCDate | null | undefined; }; /** @internal */ export const Recipient$inboundSchema: z.ZodType< Recipient, z.ZodTypeDef, unknown > = z.object({ first_name: z.string(), last_name: z.string(), address: z.nullable(Address$inboundSchema).optional(), account_number: z.nullable(z.string()).optional(), date_of_birth: z.nullable(z.string().transform(v => new RFCDate(v))) .optional(), }).transform((v) => { return remap$(v, { "first_name": "firstName", "last_name": "lastName", "account_number": "accountNumber", "date_of_birth": "dateOfBirth", }); }); /** @internal */ export type Recipient$Outbound = { first_name: string; last_name: string; address?: Address$Outbound | null | undefined; account_number?: string | null | undefined; date_of_birth?: string | null | undefined; }; /** @internal */ export const Recipient$outboundSchema: z.ZodType< Recipient$Outbound, z.ZodTypeDef, Recipient > = z.object({ firstName: z.string(), lastName: z.string(), address: z.nullable(Address$outboundSchema).optional(), accountNumber: z.nullable(z.string()).optional(), dateOfBirth: z.nullable(z.instanceof(RFCDate).transform(v => v.toString())) .optional(), }).transform((v) => { return remap$(v, { firstName: "first_name", lastName: "last_name", accountNumber: "account_number", dateOfBirth: "date_of_birth", }); }); export function recipientToJSON(recipient: Recipient): string { return JSON.stringify(Recipient$outboundSchema.parse(recipient)); } export function recipientFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Recipient$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Recipient' from JSON`, ); }