/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The status of the webhook subscription. */ export const WebhookSubscriptionStatus = { Pending: "pending", Verified: "verified", Removed: "removed", Unreachable: "unreachable", } as const; /** * The status of the webhook subscription. */ export type WebhookSubscriptionStatus = ClosedEnum< typeof WebhookSubscriptionStatus >; export const SubscriptionTypes = { BankAccount: "BankAccount", Company: "Company", CompanyBenefit: "CompanyBenefit", Contractor: "Contractor", ContractorPayment: "ContractorPayment", Employee: "Employee", EmployeeBenefit: "EmployeeBenefit", EmployeeJobCompensation: "EmployeeJobCompensation", ExternalPayroll: "ExternalPayroll", Form: "Form", Location: "Location", Notification: "Notification", Payroll: "Payroll", PayrollSync: "PayrollSync", PaySchedule: "PaySchedule", Signatory: "Signatory", } as const; export type SubscriptionTypes = ClosedEnum; /** * The representation of webhook subscription. */ export type WebhookSubscription = { /** * The UUID of the webhook subscription. */ uuid: string; /** * The webhook subscriber URL. Updates will be POSTed to this URL. */ url?: string | undefined; /** * The status of the webhook subscription. */ status?: WebhookSubscriptionStatus | undefined; /** * Receive updates for these types. */ subscriptionTypes?: Array | undefined; }; /** @internal */ export const WebhookSubscriptionStatus$inboundSchema: z.ZodNativeEnum< typeof WebhookSubscriptionStatus > = z.nativeEnum(WebhookSubscriptionStatus); /** @internal */ export const SubscriptionTypes$inboundSchema: z.ZodNativeEnum< typeof SubscriptionTypes > = z.nativeEnum(SubscriptionTypes); /** @internal */ export const WebhookSubscription$inboundSchema: z.ZodType< WebhookSubscription, z.ZodTypeDef, unknown > = z.object({ uuid: z.string(), url: z.string().optional(), status: WebhookSubscriptionStatus$inboundSchema.optional(), subscription_types: z.array(SubscriptionTypes$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "subscription_types": "subscriptionTypes", }); }); export function webhookSubscriptionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookSubscription$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookSubscription' from JSON`, ); }