/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type WebhookEndpoint = { id: string; createdAt: Date; updatedAt: Date; name: string; url: string; partitionPattern: string | null; active: boolean; }; /** @internal */ export const WebhookEndpoint$inboundSchema: z.ZodType< WebhookEndpoint, z.ZodTypeDef, unknown > = z.object({ id: z.string(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), name: z.string(), url: z.string(), partition_pattern: z.nullable(z.string()), active: z.boolean(), }).transform((v) => { return remap$(v, { "created_at": "createdAt", "updated_at": "updatedAt", "partition_pattern": "partitionPattern", }); }); /** @internal */ export type WebhookEndpoint$Outbound = { id: string; created_at: string; updated_at: string; name: string; url: string; partition_pattern: string | null; active: boolean; }; /** @internal */ export const WebhookEndpoint$outboundSchema: z.ZodType< WebhookEndpoint$Outbound, z.ZodTypeDef, WebhookEndpoint > = z.object({ id: z.string(), createdAt: z.date().transform(v => v.toISOString()), updatedAt: z.date().transform(v => v.toISOString()), name: z.string(), url: z.string(), partitionPattern: z.nullable(z.string()), active: z.boolean(), }).transform((v) => { return remap$(v, { createdAt: "created_at", updatedAt: "updated_at", partitionPattern: "partition_pattern", }); }); export function webhookEndpointToJSON( webhookEndpoint: WebhookEndpoint, ): string { return JSON.stringify(WebhookEndpoint$outboundSchema.parse(webhookEndpoint)); } export function webhookEndpointFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookEndpoint$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookEndpoint' from JSON`, ); }