/* * 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 { 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 type GetWebhookRequest = { /** * The ID of the webhook to get. */ 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; }; export const GetWebhookEventType = { 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 GetWebhookEventType = OpenEnum; /** * Payload envelope version. V2 is the Stripe-style envelope; V1 is the legacy flat shape and is read-only via this API. */ export const GetWebhookPayloadVersion = { 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 GetWebhookPayloadVersion = OpenEnum< typeof GetWebhookPayloadVersion >; /** * Webhook retrieved successfully */ export type GetWebhookResponse = { /** * 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: GetWebhookPayloadVersion; /** * The date the webhook was created. */ createdAt: string; }; /** @internal */ export type GetWebhookRequest$Outbound = { id: string; projectId?: string | undefined; }; /** @internal */ export const GetWebhookRequest$outboundSchema: z.ZodMiniType< GetWebhookRequest$Outbound, GetWebhookRequest > = z.object({ id: z.string(), projectId: z.optional(z.string()), }); export function getWebhookRequestToJSON( getWebhookRequest: GetWebhookRequest, ): string { return JSON.stringify( GetWebhookRequest$outboundSchema.parse(getWebhookRequest), ); } /** @internal */ export const GetWebhookEventType$inboundSchema: z.ZodMiniType< GetWebhookEventType, unknown > = openEnums.inboundSchema(GetWebhookEventType); /** @internal */ export const GetWebhookPayloadVersion$inboundSchema: z.ZodMiniType< GetWebhookPayloadVersion, unknown > = openEnums.inboundSchema(GetWebhookPayloadVersion); /** @internal */ export const GetWebhookResponse$inboundSchema: z.ZodMiniType< GetWebhookResponse, unknown > = z.object({ id: types.string(), name: types.string(), description: z.optional(z.nullable(types.string())), url: types.string(), eventTypes: z.array(GetWebhookEventType$inboundSchema), payloadVersion: GetWebhookPayloadVersion$inboundSchema, createdAt: types.string(), }); export function getWebhookResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetWebhookResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetWebhookResponse' from JSON`, ); }