/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { ClosedEnum, OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdk-validation-error.js"; export const UpdateWebhookEventTypeRequest = { QueueItemNew: "QUEUE_ITEM_NEW", QueueItemCompleted: "QUEUE_ITEM_COMPLETED", QueueItemAction: "QUEUE_ITEM_ACTION", QueueItemRejected: "QUEUE_ITEM_REJECTED", QueueItemAllowed: "QUEUE_ITEM_ALLOWED", AuthorBlocked: "AUTHOR_BLOCKED", AuthorUnblocked: "AUTHOR_UNBLOCKED", AuthorSuspended: "AUTHOR_SUSPENDED", AuthorUpdated: "AUTHOR_UPDATED", AuthorTrustLevelChanged: "AUTHOR_TRUST_LEVEL_CHANGED", AuthorAction: "AUTHOR_ACTION", } as const; export type UpdateWebhookEventTypeRequest = ClosedEnum< typeof UpdateWebhookEventTypeRequest >; export type UpdateWebhookRequestBody = { /** * The webhook's name, used to identify it in the dashboard */ name?: string | undefined; /** * The webhook's description */ description?: string | null | undefined; /** * The webhook's URL. We'll call this URL when an event occurs. */ url?: string | undefined; /** * Event types this webhook subscribes to. One webhook URL receives all events you list here. */ eventTypes?: Array | undefined; }; export type UpdateWebhookRequest = { /** * The ID of the webhook to update. */ id: string; /** * The project to act on, when you call with an organization key. Optional when the organization has one project. A project key acts on its own project: naming another one is an error. */ projectId?: string | undefined; body: UpdateWebhookRequestBody; }; export const UpdateWebhookEventTypeResponse = { QueueItemNew: "QUEUE_ITEM_NEW", QueueItemCompleted: "QUEUE_ITEM_COMPLETED", QueueItemAction: "QUEUE_ITEM_ACTION", QueueItemRejected: "QUEUE_ITEM_REJECTED", QueueItemAllowed: "QUEUE_ITEM_ALLOWED", AuthorBlocked: "AUTHOR_BLOCKED", AuthorUnblocked: "AUTHOR_UNBLOCKED", AuthorSuspended: "AUTHOR_SUSPENDED", AuthorUpdated: "AUTHOR_UPDATED", AuthorTrustLevelChanged: "AUTHOR_TRUST_LEVEL_CHANGED", AuthorAction: "AUTHOR_ACTION", } as const; export type UpdateWebhookEventTypeResponse = OpenEnum< typeof UpdateWebhookEventTypeResponse >; /** * Payload envelope version. V2 is the Stripe-style envelope; V1 is the legacy flat shape and is read-only via this API. */ export const UpdateWebhookPayloadVersion = { V1: "V1", V2: "V2", } as const; /** * Payload envelope version. V2 is the Stripe-style envelope; V1 is the legacy flat shape and is read-only via this API. */ export type UpdateWebhookPayloadVersion = OpenEnum< typeof UpdateWebhookPayloadVersion >; /** * Webhook updated successfully */ export type UpdateWebhookResponse = { /** * The ID of the webhook. */ id: string; /** * The webhook's name. */ name: string; /** * The webhook's description. */ description?: string | null | undefined; /** * The URL we call when a subscribed event occurs. */ url: string; /** * Event types this webhook subscribes to. Empty for legacy v1 webhooks, which subscribe via their single deprecated `type` instead. */ eventTypes: Array; /** * Payload envelope version. V2 is the Stripe-style envelope; V1 is the legacy flat shape and is read-only via this API. */ payloadVersion: UpdateWebhookPayloadVersion; /** * The date the webhook was created. */ createdAt: string; }; /** @internal */ export const UpdateWebhookEventTypeRequest$outboundSchema: z.ZodMiniEnum< typeof UpdateWebhookEventTypeRequest > = z.enum(UpdateWebhookEventTypeRequest); /** @internal */ export type UpdateWebhookRequestBody$Outbound = { name?: string | undefined; description?: string | null | undefined; url?: string | undefined; eventTypes?: Array | undefined; }; /** @internal */ export const UpdateWebhookRequestBody$outboundSchema: z.ZodMiniType< UpdateWebhookRequestBody$Outbound, UpdateWebhookRequestBody > = z.object({ name: z.optional(z.string()), description: z.optional(z.nullable(z.string())), url: z.optional(z.string()), eventTypes: z.optional(z.array(UpdateWebhookEventTypeRequest$outboundSchema)), }); export function updateWebhookRequestBodyToJSON( updateWebhookRequestBody: UpdateWebhookRequestBody, ): string { return JSON.stringify( UpdateWebhookRequestBody$outboundSchema.parse(updateWebhookRequestBody), ); } /** @internal */ export type UpdateWebhookRequest$Outbound = { id: string; projectId?: string | undefined; body: UpdateWebhookRequestBody$Outbound; }; /** @internal */ export const UpdateWebhookRequest$outboundSchema: z.ZodMiniType< UpdateWebhookRequest$Outbound, UpdateWebhookRequest > = z.object({ id: z.string(), projectId: z.optional(z.string()), body: z.lazy(() => UpdateWebhookRequestBody$outboundSchema), }); export function updateWebhookRequestToJSON( updateWebhookRequest: UpdateWebhookRequest, ): string { return JSON.stringify( UpdateWebhookRequest$outboundSchema.parse(updateWebhookRequest), ); } /** @internal */ export const UpdateWebhookEventTypeResponse$inboundSchema: z.ZodMiniType< UpdateWebhookEventTypeResponse, unknown > = openEnums.inboundSchema(UpdateWebhookEventTypeResponse); /** @internal */ export const UpdateWebhookPayloadVersion$inboundSchema: z.ZodMiniType< UpdateWebhookPayloadVersion, unknown > = openEnums.inboundSchema(UpdateWebhookPayloadVersion); /** @internal */ export const UpdateWebhookResponse$inboundSchema: z.ZodMiniType< UpdateWebhookResponse, unknown > = z.object({ id: types.string(), name: types.string(), description: z.optional(z.nullable(types.string())), url: types.string(), eventTypes: z.array(UpdateWebhookEventTypeResponse$inboundSchema), payloadVersion: UpdateWebhookPayloadVersion$inboundSchema, createdAt: types.string(), }); export function updateWebhookResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UpdateWebhookResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateWebhookResponse' from JSON`, ); }