/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { remap as remap$ } from "../../lib/primitives.js"; 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"; import * as models from "../index.js"; export type ListWebhooksRequest = { page?: number | undefined; pageSize?: number | undefined; /** * 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 ListWebhooksEventType = { 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 ListWebhooksEventType = 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 ListWebhooksPayloadVersion = { 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 ListWebhooksPayloadVersion = OpenEnum< typeof ListWebhooksPayloadVersion >; export type ListWebhooksData = { /** * 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: ListWebhooksPayloadVersion; /** * The date the webhook was created. */ createdAt: string; }; /** * Webhooks retrieved successfully */ export type ListWebhooksResponseBody = { /** * The items on this page. */ data: Array; /** * Where this page is in the full list. */ pagination: models.Pagination; }; export type ListWebhooksResponse = { result: ListWebhooksResponseBody; }; /** @internal */ export type ListWebhooksRequest$Outbound = { page: number; pageSize: number; projectId?: string | undefined; }; /** @internal */ export const ListWebhooksRequest$outboundSchema: z.ZodMiniType< ListWebhooksRequest$Outbound, ListWebhooksRequest > = z.object({ page: z._default(z.int(), 1), pageSize: z._default(z.int(), 20), projectId: z.optional(z.string()), }); export function listWebhooksRequestToJSON( listWebhooksRequest: ListWebhooksRequest, ): string { return JSON.stringify( ListWebhooksRequest$outboundSchema.parse(listWebhooksRequest), ); } /** @internal */ export const ListWebhooksEventType$inboundSchema: z.ZodMiniType< ListWebhooksEventType, unknown > = openEnums.inboundSchema(ListWebhooksEventType); /** @internal */ export const ListWebhooksPayloadVersion$inboundSchema: z.ZodMiniType< ListWebhooksPayloadVersion, unknown > = openEnums.inboundSchema(ListWebhooksPayloadVersion); /** @internal */ export const ListWebhooksData$inboundSchema: z.ZodMiniType< ListWebhooksData, unknown > = z.object({ id: types.string(), name: types.string(), description: z.optional(z.nullable(types.string())), url: types.string(), eventTypes: z.array(ListWebhooksEventType$inboundSchema), payloadVersion: ListWebhooksPayloadVersion$inboundSchema, createdAt: types.string(), }); export function listWebhooksDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListWebhooksData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListWebhooksData' from JSON`, ); } /** @internal */ export const ListWebhooksResponseBody$inboundSchema: z.ZodMiniType< ListWebhooksResponseBody, unknown > = z.object({ data: z.array(z.lazy(() => ListWebhooksData$inboundSchema)), pagination: models.Pagination$inboundSchema, }); export function listWebhooksResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListWebhooksResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListWebhooksResponseBody' from JSON`, ); } /** @internal */ export const ListWebhooksResponse$inboundSchema: z.ZodMiniType< ListWebhooksResponse, unknown > = z.pipe( z.object({ Result: z.lazy(() => ListWebhooksResponseBody$inboundSchema), }), z.transform((v) => { return remap$(v, { "Result": "result", }); }), ); export function listWebhooksResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListWebhooksResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListWebhooksResponse' from JSON`, ); }