/* * 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 { BenefitGrantWebhook, BenefitGrantWebhook$inboundSchema, BenefitGrantWebhook$Outbound, BenefitGrantWebhook$outboundSchema, } from "./benefitgrantwebhook.js"; /** * Sent when a benefit grant is cycled, * * @remarks * meaning the related subscription has been renewed for another period. * * **Discord & Slack support:** Basic */ export type WebhookBenefitGrantCycledPayload = { type: "benefit_grant.cycled"; timestamp: Date; data: BenefitGrantWebhook; }; /** @internal */ export const WebhookBenefitGrantCycledPayload$inboundSchema: z.ZodMiniType< WebhookBenefitGrantCycledPayload, unknown > = z.object({ type: z.literal("benefit_grant.cycled"), timestamp: z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), ), data: BenefitGrantWebhook$inboundSchema, }); /** @internal */ export type WebhookBenefitGrantCycledPayload$Outbound = { type: "benefit_grant.cycled"; timestamp: string; data: BenefitGrantWebhook$Outbound; }; /** @internal */ export const WebhookBenefitGrantCycledPayload$outboundSchema: z.ZodMiniType< WebhookBenefitGrantCycledPayload$Outbound, WebhookBenefitGrantCycledPayload > = z.object({ type: z.literal("benefit_grant.cycled"), timestamp: z.pipe(z.date(), z.transform(v => v.toISOString())), data: BenefitGrantWebhook$outboundSchema, }); export function webhookBenefitGrantCycledPayloadToJSON( webhookBenefitGrantCycledPayload: WebhookBenefitGrantCycledPayload, ): string { return JSON.stringify( WebhookBenefitGrantCycledPayload$outboundSchema.parse( webhookBenefitGrantCycledPayload, ), ); } export function webhookBenefitGrantCycledPayloadFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookBenefitGrantCycledPayload$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookBenefitGrantCycledPayload' from JSON`, ); }