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

import * as z from "zod/v4-mini";
import { PolarError } from "./polarerror.js";

export type ExpiredCheckoutErrorData = {
  error: "ExpiredCheckoutError";
  detail: string;
};

export class ExpiredCheckoutError extends PolarError {
  error: "ExpiredCheckoutError";
  detail: string;

  /** The original data that was passed to this error instance. */
  data$: ExpiredCheckoutErrorData;

  constructor(
    err: ExpiredCheckoutErrorData,
    httpMeta: { response: Response; request: Request; body: string },
  ) {
    const message = "message" in err && typeof err.message === "string"
      ? err.message
      : `API error occurred: ${JSON.stringify(err)}`;
    super(message, httpMeta);
    this.data$ = err;
    this.error = err.error;
    this.detail = err.detail;

    this.name = "ExpiredCheckoutError";
  }
}

/** @internal */
export const ExpiredCheckoutError$inboundSchema: z.ZodMiniType<
  ExpiredCheckoutError,
  unknown
> = z.pipe(
  z.object({
    error: z.literal("ExpiredCheckoutError"),
    detail: z.string(),
    request$: z.custom<Request>(x => x instanceof Request),
    response$: z.custom<Response>(x => x instanceof Response),
    body$: z.string(),
  }),
  z.transform((v) => {
    return new ExpiredCheckoutError(v, {
      request: v.request$,
      response: v.response$,
      body: v.body$,
    });
  }),
);
