/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Order, Order$inboundSchema, Order$Outbound, Order$outboundSchema, } from "./order.js"; /** * Sent when an order is paid. * * @remarks * * When you receive this event, the order is fully processed and payment has been received. * * **Discord & Slack support:** Full */ export type WebhookOrderPaidPayload = { type: "order.paid"; timestamp: Date; data: Order; }; /** @internal */ export const WebhookOrderPaidPayload$inboundSchema: z.ZodMiniType< WebhookOrderPaidPayload, unknown > = z.object({ type: z.literal("order.paid"), timestamp: z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), ), data: Order$inboundSchema, }); /** @internal */ export type WebhookOrderPaidPayload$Outbound = { type: "order.paid"; timestamp: string; data: Order$Outbound; }; /** @internal */ export const WebhookOrderPaidPayload$outboundSchema: z.ZodMiniType< WebhookOrderPaidPayload$Outbound, WebhookOrderPaidPayload > = z.object({ type: z.literal("order.paid"), timestamp: z.pipe(z.date(), z.transform(v => v.toISOString())), data: Order$outboundSchema, }); export function webhookOrderPaidPayloadToJSON( webhookOrderPaidPayload: WebhookOrderPaidPayload, ): string { return JSON.stringify( WebhookOrderPaidPayload$outboundSchema.parse(webhookOrderPaidPayload), ); } export function webhookOrderPaidPayloadFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookOrderPaidPayload$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookOrderPaidPayload' from JSON`, ); }