/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v4-mini";
import { remap as remap$ } from "../../lib/primitives.js";

export type SubscriptionPause = {
  /**
   * Pause an active subscription at the end of the current period.
   *
   * @remarks
   *
   * Or cancel a scheduled pause on a subscription set to be paused at
   * period end.
   */
  pauseAtPeriodEnd: boolean;
  /**
   * Date at which the paused subscription should automatically resume.
   *
   * @remarks
   *
   * If not set, the subscription stays paused until it is resumed manually.
   * Must be after the current period end.
   */
  resumesAt?: Date | null | undefined;
};

/** @internal */
export type SubscriptionPause$Outbound = {
  pause_at_period_end: boolean;
  resumes_at?: string | null | undefined;
};

/** @internal */
export const SubscriptionPause$outboundSchema: z.ZodMiniType<
  SubscriptionPause$Outbound,
  SubscriptionPause
> = z.pipe(
  z.object({
    pauseAtPeriodEnd: z.boolean(),
    resumesAt: z.optional(
      z.nullable(z.pipe(z.date(), z.transform(v => v.toISOString()))),
    ),
  }),
  z.transform((v) => {
    return remap$(v, {
      pauseAtPeriodEnd: "pause_at_period_end",
      resumesAt: "resumes_at",
    });
  }),
);

export function subscriptionPauseToJSON(
  subscriptionPause: SubscriptionPause,
): string {
  return JSON.stringify(
    SubscriptionPause$outboundSchema.parse(subscriptionPause),
  );
}
