/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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 WebhookSubscription = { /** * The ID of the downstream service */ downstreamId?: string | undefined; /** * The list of Unify Events this connection is subscribed to */ unifyEventTypes?: Array | undefined; /** * The list of downstream Events this connection is subscribed to */ downstreamEventTypes?: Array | undefined; /** * The URL the downstream is sending to when the event is triggered */ executeUrl?: string | undefined; /** * The date and time the webhook subscription was created downstream */ createdAt?: string | undefined; }; /** @internal */ export const WebhookSubscription$inboundSchema: z.ZodType< WebhookSubscription, z.ZodTypeDef, unknown > = z.object({ downstream_id: z.string().optional(), unify_event_types: z.array(z.string()).optional(), downstream_event_types: z.array(z.string()).optional(), execute_url: z.string().optional(), created_at: z.string().optional(), }).transform((v) => { return remap$(v, { "downstream_id": "downstreamId", "unify_event_types": "unifyEventTypes", "downstream_event_types": "downstreamEventTypes", "execute_url": "executeUrl", "created_at": "createdAt", }); }); /** @internal */ export type WebhookSubscription$Outbound = { downstream_id?: string | undefined; unify_event_types?: Array | undefined; downstream_event_types?: Array | undefined; execute_url?: string | undefined; created_at?: string | undefined; }; /** @internal */ export const WebhookSubscription$outboundSchema: z.ZodType< WebhookSubscription$Outbound, z.ZodTypeDef, WebhookSubscription > = z.object({ downstreamId: z.string().optional(), unifyEventTypes: z.array(z.string()).optional(), downstreamEventTypes: z.array(z.string()).optional(), executeUrl: z.string().optional(), createdAt: z.string().optional(), }).transform((v) => { return remap$(v, { downstreamId: "downstream_id", unifyEventTypes: "unify_event_types", downstreamEventTypes: "downstream_event_types", executeUrl: "execute_url", createdAt: "created_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace WebhookSubscription$ { /** @deprecated use `WebhookSubscription$inboundSchema` instead. */ export const inboundSchema = WebhookSubscription$inboundSchema; /** @deprecated use `WebhookSubscription$outboundSchema` instead. */ export const outboundSchema = WebhookSubscription$outboundSchema; /** @deprecated use `WebhookSubscription$Outbound` instead. */ export type Outbound = WebhookSubscription$Outbound; } export function webhookSubscriptionToJSON( webhookSubscription: WebhookSubscription, ): string { return JSON.stringify( WebhookSubscription$outboundSchema.parse(webhookSubscription), ); } export function webhookSubscriptionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookSubscription$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookSubscription' from JSON`, ); }