/* * 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 * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CaptureTransactionGlobals = { merchantAccountId?: string | undefined; }; export type CaptureTransactionRequest = { /** * The ID of the transaction */ transactionId: string; /** * The preferred resource type in the response. */ prefer?: Array | null | undefined; /** * The ID of the merchant account to use for this request. */ merchantAccountId?: string | null | undefined; /** * A unique key that identifies this request. Providing this header will make this an idempotent request. We recommend using V4 UUIDs, or another random string with enough entropy to avoid collisions. */ idempotencyKey?: string | null | undefined; transactionCaptureCreate: components.TransactionCaptureCreate; }; /** * Successful Response */ export type CaptureTransactionResponse200CaptureTransaction = | components.Transaction | components.TransactionCapture; /** @internal */ export type CaptureTransactionRequest$Outbound = { transaction_id: string; prefer?: Array | null | undefined; merchantAccountId?: string | null | undefined; "idempotency-key"?: string | null | undefined; TransactionCaptureCreate: components.TransactionCaptureCreate$Outbound; }; /** @internal */ export const CaptureTransactionRequest$outboundSchema: z.ZodType< CaptureTransactionRequest$Outbound, z.ZodTypeDef, CaptureTransactionRequest > = z.object({ transactionId: z.string(), prefer: z.nullable(z.array(z.string())).optional(), merchantAccountId: z.nullable(z.string()).optional(), idempotencyKey: z.nullable(z.string()).optional(), transactionCaptureCreate: components.TransactionCaptureCreate$outboundSchema, }).transform((v) => { return remap$(v, { transactionId: "transaction_id", idempotencyKey: "idempotency-key", transactionCaptureCreate: "TransactionCaptureCreate", }); }); export function captureTransactionRequestToJSON( captureTransactionRequest: CaptureTransactionRequest, ): string { return JSON.stringify( CaptureTransactionRequest$outboundSchema.parse(captureTransactionRequest), ); } /** @internal */ export const CaptureTransactionResponse200CaptureTransaction$inboundSchema: z.ZodType< CaptureTransactionResponse200CaptureTransaction, z.ZodTypeDef, unknown > = z.union([ components.Transaction$inboundSchema, components.TransactionCapture$inboundSchema, ]); export function captureTransactionResponse200CaptureTransactionFromJSON( jsonString: string, ): SafeParseResult< CaptureTransactionResponse200CaptureTransaction, SDKValidationError > { return safeParse( jsonString, (x) => CaptureTransactionResponse200CaptureTransaction$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CaptureTransactionResponse200CaptureTransaction' from JSON`, ); }