/* * 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 { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Status, Status$inboundSchema } from "./status.js"; import { UnifiedApiId, UnifiedApiId$inboundSchema } from "./unifiedapiid.js"; import { WebhookEventType, WebhookEventType$inboundSchema, } from "./webhookeventtype.js"; /** * Indicates why the webhook has been disabled. `retry_limit`: webhook reached its retry limit. `usage_limit`: account is over its usage limit. `delivery_url_validation_failed`: delivery URL failed validation during webhook creation or update. */ export const DisabledReason = { None: "none", RetryLimit: "retry_limit", UsageLimit: "usage_limit", DeliveryUrlValidationFailed: "delivery_url_validation_failed", } as const; /** * Indicates why the webhook has been disabled. `retry_limit`: webhook reached its retry limit. `usage_limit`: account is over its usage limit. `delivery_url_validation_failed`: delivery URL failed validation during webhook creation or update. */ export type DisabledReason = OpenEnum; export type Webhook = { id?: string | undefined; /** * A description of the object. */ description?: string | null | undefined; /** * Name of Apideck Unified API */ unifiedApi: UnifiedApiId; /** * The status of the webhook. */ status: Status; /** * Indicates why the webhook has been disabled. `retry_limit`: webhook reached its retry limit. `usage_limit`: account is over its usage limit. `delivery_url_validation_failed`: delivery URL failed validation during webhook creation or update. */ disabledReason?: DisabledReason | undefined; /** * The delivery url of the webhook endpoint. The endpoint must respond within 60 seconds or the delivery is recorded as failed. */ deliveryUrl: string; /** * The Unify Base URL events from connectors will be sent to after service id is appended. */ executeBaseUrl: string; /** * The list of subscribed events for this webhook. [`*`] indicates that all events are enabled. */ events: Array; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; }; /** @internal */ export const DisabledReason$inboundSchema: z.ZodType< DisabledReason, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(DisabledReason)); /** @internal */ export const Webhook$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), description: z.nullable(types.string()).optional(), unified_api: UnifiedApiId$inboundSchema, status: Status$inboundSchema, disabled_reason: types.optional(DisabledReason$inboundSchema), delivery_url: types.string(), execute_base_url: types.string(), events: z.array(WebhookEventType$inboundSchema), updated_at: z.nullable(types.date()).optional(), created_at: z.nullable(types.date()).optional(), }).transform((v) => { return remap$(v, { "unified_api": "unifiedApi", "disabled_reason": "disabledReason", "delivery_url": "deliveryUrl", "execute_base_url": "executeBaseUrl", "updated_at": "updatedAt", "created_at": "createdAt", }); }) ); export function webhookFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Webhook$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Webhook' from JSON`, ); }