/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Transaction, Transaction$inboundSchema, Transaction$Outbound, Transaction$outboundSchema, } from "./transaction.js"; import { WebhookEventTypeEnum, WebhookEventTypeEnum$inboundSchema, WebhookEventTypeEnum$outboundSchema, } from "./webhookeventtypeenum.js"; /** * Content of the webhook posted to the external URL */ export type WebhookPayloadTransaction = { /** * Type of event that triggered the webhook. */ event?: WebhookEventTypeEnum | undefined; /** * Determines whether the webhook is a test webhook or not. */ test?: boolean | undefined; data?: Transaction | undefined; }; /** @internal */ export const WebhookPayloadTransaction$inboundSchema: z.ZodMiniType< WebhookPayloadTransaction, unknown > = z.object({ event: z.optional(WebhookEventTypeEnum$inboundSchema), test: z.optional(z.boolean()), data: z.optional(Transaction$inboundSchema), }); /** @internal */ export type WebhookPayloadTransaction$Outbound = { event?: string | undefined; test?: boolean | undefined; data?: Transaction$Outbound | undefined; }; /** @internal */ export const WebhookPayloadTransaction$outboundSchema: z.ZodMiniType< WebhookPayloadTransaction$Outbound, WebhookPayloadTransaction > = z.object({ event: z.optional(WebhookEventTypeEnum$outboundSchema), test: z.optional(z.boolean()), data: z.optional(Transaction$outboundSchema), }); export function webhookPayloadTransactionToJSON( webhookPayloadTransaction: WebhookPayloadTransaction, ): string { return JSON.stringify( WebhookPayloadTransaction$outboundSchema.parse(webhookPayloadTransaction), ); } export function webhookPayloadTransactionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookPayloadTransaction$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookPayloadTransaction' from JSON`, ); }