/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v4-mini";
import {
  WebhookEventType,
  WebhookEventType$outboundSchema,
} from "./webhookeventtype.js";
import {
  WebhookFormat,
  WebhookFormat$outboundSchema,
} from "./webhookformat.js";

/**
 * Schema to update a webhook endpoint.
 */
export type WebhookEndpointUpdate = {
  url?: string | null | undefined;
  /**
   * An optional name for the webhook endpoint to help organize and identify it.
   */
  name?: string | null | undefined;
  format?: WebhookFormat | null | undefined;
  events?: Array<WebhookEventType> | null | undefined;
  /**
   * Whether the webhook endpoint is enabled.
   */
  enabled?: boolean | null | undefined;
};

/** @internal */
export type WebhookEndpointUpdate$Outbound = {
  url?: string | null | undefined;
  name?: string | null | undefined;
  format?: string | null | undefined;
  events?: Array<string> | null | undefined;
  enabled?: boolean | null | undefined;
};

/** @internal */
export const WebhookEndpointUpdate$outboundSchema: z.ZodMiniType<
  WebhookEndpointUpdate$Outbound,
  WebhookEndpointUpdate
> = z.object({
  url: z.optional(z.nullable(z.string())),
  name: z.optional(z.nullable(z.string())),
  format: z.optional(z.nullable(WebhookFormat$outboundSchema)),
  events: z.optional(z.nullable(z.array(WebhookEventType$outboundSchema))),
  enabled: z.optional(z.nullable(z.boolean())),
});

export function webhookEndpointUpdateToJSON(
  webhookEndpointUpdate: WebhookEndpointUpdate,
): string {
  return JSON.stringify(
    WebhookEndpointUpdate$outboundSchema.parse(webhookEndpointUpdate),
  );
}
