/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { WebhookEventType, WebhookEventType$inboundSchema, WebhookEventType$outboundSchema, } from "./webhookeventtype.js"; import { WebhookStatus, WebhookStatus$inboundSchema, WebhookStatus$outboundSchema, } from "./webhookstatus.js"; /** * Request body for creating a new webhook. */ export type CreateWebhook = { /** * The URL where webhook events will be sent. */ url: string; /** * The status of the webhook. */ status: WebhookStatus; /** * The list of event types this webhook should subscribe to. */ eventTypes: Array; /** * A description of the webhook for reference. Can be an empty string. */ description: string; }; /** @internal */ export const CreateWebhook$inboundSchema: z.ZodType< CreateWebhook, z.ZodTypeDef, unknown > = z.object({ url: z.string(), status: WebhookStatus$inboundSchema, eventTypes: z.array(WebhookEventType$inboundSchema), description: z.string(), }); /** @internal */ export type CreateWebhook$Outbound = { url: string; status: string; eventTypes: Array; description: string; }; /** @internal */ export const CreateWebhook$outboundSchema: z.ZodType< CreateWebhook$Outbound, z.ZodTypeDef, CreateWebhook > = z.object({ url: z.string(), status: WebhookStatus$outboundSchema, eventTypes: z.array(WebhookEventType$outboundSchema), description: z.string(), }); export function createWebhookToJSON(createWebhook: CreateWebhook): string { return JSON.stringify(CreateWebhook$outboundSchema.parse(createWebhook)); } export function createWebhookFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateWebhook$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateWebhook' from JSON`, ); }