/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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 mode of cancellation (immediate or scheduled), default can be configured in the store billing settings. */ export const Mode = { Immediate: "immediate", Scheduled: "scheduled", } as const; /** * The mode of cancellation (immediate or scheduled), default can be configured in the store billing settings. */ export type Mode = ClosedEnum; /** * The action to execute when canceling (cancel or pause) when mode is scheduled, ignored when mode is immediate or not provided */ export const OnExecute = { Cancel: "cancel", Pause: "pause", } as const; /** * The action to execute when canceling (cancel or pause) when mode is scheduled, ignored when mode is immediate or not provided */ export type OnExecute = ClosedEnum; export type CancelSubscriptionRequestEntity = { /** * The mode of cancellation (immediate or scheduled), default can be configured in the store billing settings. */ mode?: Mode | undefined; /** * The action to execute when canceling (cancel or pause) when mode is scheduled, ignored when mode is immediate or not provided */ onExecute?: OnExecute | undefined; }; /** @internal */ export const Mode$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Mode, ); /** @internal */ export const Mode$outboundSchema: z.ZodNativeEnum = Mode$inboundSchema; /** @internal */ export const OnExecute$inboundSchema: z.ZodNativeEnum = z .nativeEnum(OnExecute); /** @internal */ export const OnExecute$outboundSchema: z.ZodNativeEnum = OnExecute$inboundSchema; /** @internal */ export const CancelSubscriptionRequestEntity$inboundSchema: z.ZodType< CancelSubscriptionRequestEntity, z.ZodTypeDef, unknown > = z.object({ mode: Mode$inboundSchema.optional(), onExecute: OnExecute$inboundSchema.optional(), }); /** @internal */ export type CancelSubscriptionRequestEntity$Outbound = { mode?: string | undefined; onExecute?: string | undefined; }; /** @internal */ export const CancelSubscriptionRequestEntity$outboundSchema: z.ZodType< CancelSubscriptionRequestEntity$Outbound, z.ZodTypeDef, CancelSubscriptionRequestEntity > = z.object({ mode: Mode$outboundSchema.optional(), onExecute: OnExecute$outboundSchema.optional(), }); export function cancelSubscriptionRequestEntityToJSON( cancelSubscriptionRequestEntity: CancelSubscriptionRequestEntity, ): string { return JSON.stringify( CancelSubscriptionRequestEntity$outboundSchema.parse( cancelSubscriptionRequestEntity, ), ); } export function cancelSubscriptionRequestEntityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CancelSubscriptionRequestEntity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CancelSubscriptionRequestEntity' from JSON`, ); }