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

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

export type StopTranscodeSessionSessionsErrors = {
  code?: number | undefined;
  message?: string | undefined;
  status?: number | undefined;
};

/**
 * Unauthorized - Returned if the X-Plex-Token is missing from the header or query.
 */
export type StopTranscodeSessionUnauthorizedData = {
  errors?: Array<StopTranscodeSessionSessionsErrors> | undefined;
  /**
   * Raw HTTP response; suitable for custom response parsing
   */
  rawResponse?: Response | undefined;
};

/**
 * Unauthorized - Returned if the X-Plex-Token is missing from the header or query.
 */
export class StopTranscodeSessionUnauthorized extends Error {
  errors?: Array<StopTranscodeSessionSessionsErrors> | undefined;
  /**
   * Raw HTTP response; suitable for custom response parsing
   */
  rawResponse?: Response | undefined;

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

  constructor(err: StopTranscodeSessionUnauthorizedData) {
    const message = "message" in err && typeof err.message === "string"
      ? err.message
      : `API error occurred: ${JSON.stringify(err)}`;
    super(message);
    this.data$ = err;

    if (err.errors != null) this.errors = err.errors;
    if (err.rawResponse != null) this.rawResponse = err.rawResponse;

    this.name = "StopTranscodeSessionUnauthorized";
  }
}

export type StopTranscodeSessionErrors = {
  code?: number | undefined;
  message?: string | undefined;
  status?: number | undefined;
};

/**
 * Bad Request - A parameter was not specified, or was specified incorrectly.
 */
export type StopTranscodeSessionBadRequestData = {
  errors?: Array<StopTranscodeSessionErrors> | undefined;
  /**
   * Raw HTTP response; suitable for custom response parsing
   */
  rawResponse?: Response | undefined;
};

/**
 * Bad Request - A parameter was not specified, or was specified incorrectly.
 */
export class StopTranscodeSessionBadRequest extends Error {
  errors?: Array<StopTranscodeSessionErrors> | undefined;
  /**
   * Raw HTTP response; suitable for custom response parsing
   */
  rawResponse?: Response | undefined;

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

  constructor(err: StopTranscodeSessionBadRequestData) {
    const message = "message" in err && typeof err.message === "string"
      ? err.message
      : `API error occurred: ${JSON.stringify(err)}`;
    super(message);
    this.data$ = err;

    if (err.errors != null) this.errors = err.errors;
    if (err.rawResponse != null) this.rawResponse = err.rawResponse;

    this.name = "StopTranscodeSessionBadRequest";
  }
}

/** @internal */
export const StopTranscodeSessionSessionsErrors$inboundSchema: z.ZodType<
  StopTranscodeSessionSessionsErrors,
  z.ZodTypeDef,
  unknown
> = z.object({
  code: z.number().int().optional(),
  message: z.string().optional(),
  status: z.number().int().optional(),
});

/** @internal */
export type StopTranscodeSessionSessionsErrors$Outbound = {
  code?: number | undefined;
  message?: string | undefined;
  status?: number | undefined;
};

/** @internal */
export const StopTranscodeSessionSessionsErrors$outboundSchema: z.ZodType<
  StopTranscodeSessionSessionsErrors$Outbound,
  z.ZodTypeDef,
  StopTranscodeSessionSessionsErrors
> = z.object({
  code: z.number().int().optional(),
  message: z.string().optional(),
  status: z.number().int().optional(),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace StopTranscodeSessionSessionsErrors$ {
  /** @deprecated use `StopTranscodeSessionSessionsErrors$inboundSchema` instead. */
  export const inboundSchema = StopTranscodeSessionSessionsErrors$inboundSchema;
  /** @deprecated use `StopTranscodeSessionSessionsErrors$outboundSchema` instead. */
  export const outboundSchema =
    StopTranscodeSessionSessionsErrors$outboundSchema;
  /** @deprecated use `StopTranscodeSessionSessionsErrors$Outbound` instead. */
  export type Outbound = StopTranscodeSessionSessionsErrors$Outbound;
}

/** @internal */
export const StopTranscodeSessionUnauthorized$inboundSchema: z.ZodType<
  StopTranscodeSessionUnauthorized,
  z.ZodTypeDef,
  unknown
> = z.object({
  errors: z.array(
    z.lazy(() => StopTranscodeSessionSessionsErrors$inboundSchema),
  ).optional(),
  RawResponse: z.instanceof(Response).optional(),
})
  .transform((v) => {
    const remapped = remap$(v, {
      "RawResponse": "rawResponse",
    });

    return new StopTranscodeSessionUnauthorized(remapped);
  });

/** @internal */
export type StopTranscodeSessionUnauthorized$Outbound = {
  errors?: Array<StopTranscodeSessionSessionsErrors$Outbound> | undefined;
  RawResponse?: never | undefined;
};

/** @internal */
export const StopTranscodeSessionUnauthorized$outboundSchema: z.ZodType<
  StopTranscodeSessionUnauthorized$Outbound,
  z.ZodTypeDef,
  StopTranscodeSessionUnauthorized
> = z.instanceof(StopTranscodeSessionUnauthorized)
  .transform(v => v.data$)
  .pipe(
    z.object({
      errors: z.array(
        z.lazy(() => StopTranscodeSessionSessionsErrors$outboundSchema),
      ).optional(),
      rawResponse: z.instanceof(Response).transform(() => {
        throw new Error("Response cannot be serialized");
      }).optional(),
    }).transform((v) => {
      return remap$(v, {
        rawResponse: "RawResponse",
      });
    }),
  );

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace StopTranscodeSessionUnauthorized$ {
  /** @deprecated use `StopTranscodeSessionUnauthorized$inboundSchema` instead. */
  export const inboundSchema = StopTranscodeSessionUnauthorized$inboundSchema;
  /** @deprecated use `StopTranscodeSessionUnauthorized$outboundSchema` instead. */
  export const outboundSchema = StopTranscodeSessionUnauthorized$outboundSchema;
  /** @deprecated use `StopTranscodeSessionUnauthorized$Outbound` instead. */
  export type Outbound = StopTranscodeSessionUnauthorized$Outbound;
}

/** @internal */
export const StopTranscodeSessionErrors$inboundSchema: z.ZodType<
  StopTranscodeSessionErrors,
  z.ZodTypeDef,
  unknown
> = z.object({
  code: z.number().int().optional(),
  message: z.string().optional(),
  status: z.number().int().optional(),
});

/** @internal */
export type StopTranscodeSessionErrors$Outbound = {
  code?: number | undefined;
  message?: string | undefined;
  status?: number | undefined;
};

/** @internal */
export const StopTranscodeSessionErrors$outboundSchema: z.ZodType<
  StopTranscodeSessionErrors$Outbound,
  z.ZodTypeDef,
  StopTranscodeSessionErrors
> = z.object({
  code: z.number().int().optional(),
  message: z.string().optional(),
  status: z.number().int().optional(),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace StopTranscodeSessionErrors$ {
  /** @deprecated use `StopTranscodeSessionErrors$inboundSchema` instead. */
  export const inboundSchema = StopTranscodeSessionErrors$inboundSchema;
  /** @deprecated use `StopTranscodeSessionErrors$outboundSchema` instead. */
  export const outboundSchema = StopTranscodeSessionErrors$outboundSchema;
  /** @deprecated use `StopTranscodeSessionErrors$Outbound` instead. */
  export type Outbound = StopTranscodeSessionErrors$Outbound;
}

/** @internal */
export const StopTranscodeSessionBadRequest$inboundSchema: z.ZodType<
  StopTranscodeSessionBadRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  errors: z.array(z.lazy(() => StopTranscodeSessionErrors$inboundSchema))
    .optional(),
  RawResponse: z.instanceof(Response).optional(),
})
  .transform((v) => {
    const remapped = remap$(v, {
      "RawResponse": "rawResponse",
    });

    return new StopTranscodeSessionBadRequest(remapped);
  });

/** @internal */
export type StopTranscodeSessionBadRequest$Outbound = {
  errors?: Array<StopTranscodeSessionErrors$Outbound> | undefined;
  RawResponse?: never | undefined;
};

/** @internal */
export const StopTranscodeSessionBadRequest$outboundSchema: z.ZodType<
  StopTranscodeSessionBadRequest$Outbound,
  z.ZodTypeDef,
  StopTranscodeSessionBadRequest
> = z.instanceof(StopTranscodeSessionBadRequest)
  .transform(v => v.data$)
  .pipe(
    z.object({
      errors: z.array(z.lazy(() => StopTranscodeSessionErrors$outboundSchema))
        .optional(),
      rawResponse: z.instanceof(Response).transform(() => {
        throw new Error("Response cannot be serialized");
      }).optional(),
    }).transform((v) => {
      return remap$(v, {
        rawResponse: "RawResponse",
      });
    }),
  );

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace StopTranscodeSessionBadRequest$ {
  /** @deprecated use `StopTranscodeSessionBadRequest$inboundSchema` instead. */
  export const inboundSchema = StopTranscodeSessionBadRequest$inboundSchema;
  /** @deprecated use `StopTranscodeSessionBadRequest$outboundSchema` instead. */
  export const outboundSchema = StopTranscodeSessionBadRequest$outboundSchema;
  /** @deprecated use `StopTranscodeSessionBadRequest$Outbound` instead. */
  export type Outbound = StopTranscodeSessionBadRequest$Outbound;
}
