/* * 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 { CancelStatus, CancelStatus$inboundSchema } from "./cancelstatus.js"; import { Transaction, Transaction$inboundSchema } from "./transaction.js"; export type TransactionCancel = { /** * Always `transaction-cancel`. */ type: "transaction-cancel"; status: CancelStatus; /** * The standardized error code set by Gr4vy. */ code: string | null; /** * This is the response code received from the payment service. This can be set to any value and is not standardized across different payment services. */ rawResponseCode: string | null; /** * This is the response description received from the payment service. This can be set to any value and is not standardized across different payment services. */ rawResponseDescription: string | null; /** * A full transaction resource. */ transaction: Transaction; }; /** @internal */ export const TransactionCancel$inboundSchema: z.ZodType< TransactionCancel, z.ZodTypeDef, unknown > = z.object({ type: z.literal("transaction-cancel").default("transaction-cancel"), status: CancelStatus$inboundSchema, code: z.nullable(z.string()), raw_response_code: z.nullable(z.string()), raw_response_description: z.nullable(z.string()), transaction: Transaction$inboundSchema, }).transform((v) => { return remap$(v, { "raw_response_code": "rawResponseCode", "raw_response_description": "rawResponseDescription", }); }); export function transactionCancelFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransactionCancel$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransactionCancel' from JSON`, ); }