/* * 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 { WebhookEventTypeEnum, WebhookEventTypeEnum$inboundSchema, WebhookEventTypeEnum$outboundSchema, } from "./webhookeventtypeenum.js"; /** * Content of the webhook posted to the external URL */ export type WebhookPayloadBatch = { /** * Type of event that triggered the webhook. */ event?: WebhookEventTypeEnum | undefined; /** * Determines whether the webhook is a test webhook or not. */ test?: boolean | undefined; /** * A string containing the batch object ID, of the form 'batch {batchId} (created|processing complete)'. */ data?: string | undefined; }; /** @internal */ export const WebhookPayloadBatch$inboundSchema: z.ZodMiniType< WebhookPayloadBatch, unknown > = z.object({ event: z.optional(WebhookEventTypeEnum$inboundSchema), test: z.optional(z.boolean()), data: z.optional(z.string()), }); /** @internal */ export type WebhookPayloadBatch$Outbound = { event?: string | undefined; test?: boolean | undefined; data?: string | undefined; }; /** @internal */ export const WebhookPayloadBatch$outboundSchema: z.ZodMiniType< WebhookPayloadBatch$Outbound, WebhookPayloadBatch > = z.object({ event: z.optional(WebhookEventTypeEnum$outboundSchema), test: z.optional(z.boolean()), data: z.optional(z.string()), }); export function webhookPayloadBatchToJSON( webhookPayloadBatch: WebhookPayloadBatch, ): string { return JSON.stringify( WebhookPayloadBatch$outboundSchema.parse(webhookPayloadBatch), ); } export function webhookPayloadBatchFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookPayloadBatch$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookPayloadBatch' from JSON`, ); }