/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type Webhook = { /** * Type of event that triggers the webhook. */ event: string; /** * URL webhook events are sent to. */ url: string; /** * Determines whether the webhook is active or not. */ active?: boolean | undefined; /** * Determines whether the webhook is a test webhook or not. */ isTest?: boolean | undefined; /** * Timestamp of the creation of the webhook. */ objectCreated?: Date | undefined; /** * Unique identifier of the webhook. This can be used to retrieve or delete the webhook. */ objectId?: string | undefined; /** * Timestamp of the last update of the webhook. */ objectUpdated?: Date | undefined; /** * Username of the user who created the webhook. */ objectOwner?: string | undefined; }; /** @internal */ export const Webhook$inboundSchema: z.ZodMiniType = z.pipe( z.object({ event: z.string(), url: z.string(), active: z.optional(z.boolean()), is_test: z.optional(z.boolean()), object_created: z.optional( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), object_id: z.optional(z.string()), object_updated: z.optional( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), object_owner: z.optional(z.string()), }), z.transform((v) => { return remap$(v, { "is_test": "isTest", "object_created": "objectCreated", "object_id": "objectId", "object_updated": "objectUpdated", "object_owner": "objectOwner", }); }), ); export function webhookFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Webhook$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Webhook' from JSON`, ); }