/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CommissionCreatedEvent, CommissionCreatedEvent$inboundSchema, CommissionCreatedEvent$Outbound, CommissionCreatedEvent$outboundSchema, } from "./commissioncreatedevent.js"; import { LeadCreatedEvent, LeadCreatedEvent$inboundSchema, LeadCreatedEvent$Outbound, LeadCreatedEvent$outboundSchema, } from "./leadcreatedevent.js"; import { LinkClickedEvent, LinkClickedEvent$inboundSchema, LinkClickedEvent$Outbound, LinkClickedEvent$outboundSchema, } from "./linkclickedevent.js"; import { LinkWebhookEvent, LinkWebhookEvent$inboundSchema, LinkWebhookEvent$Outbound, LinkWebhookEvent$outboundSchema, } from "./linkwebhookevent.js"; import { PartnerApplicationSubmittedEvent, PartnerApplicationSubmittedEvent$inboundSchema, PartnerApplicationSubmittedEvent$Outbound, PartnerApplicationSubmittedEvent$outboundSchema, } from "./partnerapplicationsubmittedevent.js"; import { PartnerEnrolledEvent, PartnerEnrolledEvent$inboundSchema, PartnerEnrolledEvent$Outbound, PartnerEnrolledEvent$outboundSchema, } from "./partnerenrolledevent.js"; import { SaleCreatedEvent, SaleCreatedEvent$inboundSchema, SaleCreatedEvent$Outbound, SaleCreatedEvent$outboundSchema, } from "./salecreatedevent.js"; /** * Webhook event schema */ export type WebhookEvent = | LinkWebhookEvent | LinkClickedEvent | LeadCreatedEvent | SaleCreatedEvent | PartnerEnrolledEvent | PartnerApplicationSubmittedEvent | CommissionCreatedEvent; /** @internal */ export const WebhookEvent$inboundSchema: z.ZodType< WebhookEvent, z.ZodTypeDef, unknown > = z.union([ LinkWebhookEvent$inboundSchema, LinkClickedEvent$inboundSchema, LeadCreatedEvent$inboundSchema, SaleCreatedEvent$inboundSchema, PartnerEnrolledEvent$inboundSchema, PartnerApplicationSubmittedEvent$inboundSchema, CommissionCreatedEvent$inboundSchema, ]); /** @internal */ export type WebhookEvent$Outbound = | LinkWebhookEvent$Outbound | LinkClickedEvent$Outbound | LeadCreatedEvent$Outbound | SaleCreatedEvent$Outbound | PartnerEnrolledEvent$Outbound | PartnerApplicationSubmittedEvent$Outbound | CommissionCreatedEvent$Outbound; /** @internal */ export const WebhookEvent$outboundSchema: z.ZodType< WebhookEvent$Outbound, z.ZodTypeDef, WebhookEvent > = z.union([ LinkWebhookEvent$outboundSchema, LinkClickedEvent$outboundSchema, LeadCreatedEvent$outboundSchema, SaleCreatedEvent$outboundSchema, PartnerEnrolledEvent$outboundSchema, PartnerApplicationSubmittedEvent$outboundSchema, CommissionCreatedEvent$outboundSchema, ]); export function webhookEventToJSON(webhookEvent: WebhookEvent): string { return JSON.stringify(WebhookEvent$outboundSchema.parse(webhookEvent)); } export function webhookEventFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookEvent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookEvent' from JSON`, ); }