/*
 * 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 {
  AlreadyCanceledSubscription,
  AlreadyCanceledSubscription$inboundSchema,
} from "./alreadycanceledsubscription.js";
import {
  PauseResumeNotAllowed,
  PauseResumeNotAllowed$inboundSchema,
} from "./pauseresumenotallowed.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

/**
 * Customer subscription is already canceled or will be at the end of the period, the user lacks billing permissions, or pausing/resuming is not enabled for the organization.
 */
export type CustomerPortalSubscriptionsUpdateResponse403CustomerPortalSubscriptionsUpdate =
  | AlreadyCanceledSubscription
  | PauseResumeNotAllowed;

/** @internal */
export const CustomerPortalSubscriptionsUpdateResponse403CustomerPortalSubscriptionsUpdate$inboundSchema:
  z.ZodMiniType<
    CustomerPortalSubscriptionsUpdateResponse403CustomerPortalSubscriptionsUpdate,
    unknown
  > = z.union([
    AlreadyCanceledSubscription$inboundSchema,
    PauseResumeNotAllowed$inboundSchema,
  ]);

export function customerPortalSubscriptionsUpdateResponse403CustomerPortalSubscriptionsUpdateFromJSON(
  jsonString: string,
): SafeParseResult<
  CustomerPortalSubscriptionsUpdateResponse403CustomerPortalSubscriptionsUpdate,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      CustomerPortalSubscriptionsUpdateResponse403CustomerPortalSubscriptionsUpdate$inboundSchema
        .parse(JSON.parse(x)),
    `Failed to parse 'CustomerPortalSubscriptionsUpdateResponse403CustomerPortalSubscriptionsUpdate' from JSON`,
  );
}
