/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { BillingDetails, BillingDetails$inboundSchema, } from "./billingdetails.js"; export type Buyer = { /** * Always `buyer`. */ type: "buyer"; /** * The ID for the buyer. */ id: string; /** * The base62 encoded buyer ID. This represents a shorter version of this buyer's `id` which is sent to payment services, anti-fraud services, and other connectors. You can use this ID to reconcile a payment service's buyer against our system. */ reconciliationId: string; /** * The ID of the merchant account this buyer belongs to. */ merchantAccountId: string; /** * The display name for the buyer. */ displayName?: string | null | undefined; /** * The merchant identifier for this buyer. */ externalIdentifier?: string | null | undefined; /** * The billing name, address, email, and other fields for this buyer. */ billingDetails?: BillingDetails | null | undefined; /** * The buyer account number */ accountNumber?: string | null | undefined; /** * The date this buyer was created at. */ createdAt: Date; /** * The date this buyer was last updated at. */ updatedAt: Date; }; /** @internal */ export const Buyer$inboundSchema: z.ZodType = z .object({ type: z.literal("buyer").default("buyer"), id: z.string(), reconciliation_id: z.string(), merchant_account_id: z.string(), display_name: z.nullable(z.string()).optional(), external_identifier: z.nullable(z.string()).optional(), billing_details: z.nullable(BillingDetails$inboundSchema).optional(), account_number: z.nullable(z.string()).optional(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), }).transform((v) => { return remap$(v, { "reconciliation_id": "reconciliationId", "merchant_account_id": "merchantAccountId", "display_name": "displayName", "external_identifier": "externalIdentifier", "billing_details": "billingDetails", "account_number": "accountNumber", "created_at": "createdAt", "updated_at": "updatedAt", }); }); export function buyerFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Buyer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Buyer' from JSON`, ); }