/*
 * 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 CustomerSubscriptionPause = {
  /**
   * 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. If not set, it stays paused until resumed. Must be after the current period end.
   */
  resumesAt?: Date | null | undefined;
};

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

/** @internal */
export const CustomerSubscriptionPause$outboundSchema: z.ZodMiniType<
  CustomerSubscriptionPause$Outbound,
  CustomerSubscriptionPause
> = 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 customerSubscriptionPauseToJSON(
  customerSubscriptionPause: CustomerSubscriptionPause,
): string {
  return JSON.stringify(
    CustomerSubscriptionPause$outboundSchema.parse(customerSubscriptionPause),
  );
}
