/*
 * 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 StopAllTasksButlerErrors = {
  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 StopAllTasksUnauthorizedData = {
  errors?: Array<StopAllTasksButlerErrors> | 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 StopAllTasksUnauthorized extends Error {
  errors?: Array<StopAllTasksButlerErrors> | undefined;
  /**
   * Raw HTTP response; suitable for custom response parsing
   */
  rawResponse?: Response | undefined;

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

  constructor(err: StopAllTasksUnauthorizedData) {
    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 = "StopAllTasksUnauthorized";
  }
}

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

/**
 * Bad Request - A parameter was not specified, or was specified incorrectly.
 */
export type StopAllTasksBadRequestData = {
  errors?: Array<StopAllTasksErrors> | 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 StopAllTasksBadRequest extends Error {
  errors?: Array<StopAllTasksErrors> | undefined;
  /**
   * Raw HTTP response; suitable for custom response parsing
   */
  rawResponse?: Response | undefined;

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

  constructor(err: StopAllTasksBadRequestData) {
    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 = "StopAllTasksBadRequest";
  }
}

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

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

/** @internal */
export const StopAllTasksButlerErrors$outboundSchema: z.ZodType<
  StopAllTasksButlerErrors$Outbound,
  z.ZodTypeDef,
  StopAllTasksButlerErrors
> = 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 StopAllTasksButlerErrors$ {
  /** @deprecated use `StopAllTasksButlerErrors$inboundSchema` instead. */
  export const inboundSchema = StopAllTasksButlerErrors$inboundSchema;
  /** @deprecated use `StopAllTasksButlerErrors$outboundSchema` instead. */
  export const outboundSchema = StopAllTasksButlerErrors$outboundSchema;
  /** @deprecated use `StopAllTasksButlerErrors$Outbound` instead. */
  export type Outbound = StopAllTasksButlerErrors$Outbound;
}

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

    return new StopAllTasksUnauthorized(remapped);
  });

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

/** @internal */
export const StopAllTasksUnauthorized$outboundSchema: z.ZodType<
  StopAllTasksUnauthorized$Outbound,
  z.ZodTypeDef,
  StopAllTasksUnauthorized
> = z.instanceof(StopAllTasksUnauthorized)
  .transform(v => v.data$)
  .pipe(
    z.object({
      errors: z.array(z.lazy(() => StopAllTasksButlerErrors$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 StopAllTasksUnauthorized$ {
  /** @deprecated use `StopAllTasksUnauthorized$inboundSchema` instead. */
  export const inboundSchema = StopAllTasksUnauthorized$inboundSchema;
  /** @deprecated use `StopAllTasksUnauthorized$outboundSchema` instead. */
  export const outboundSchema = StopAllTasksUnauthorized$outboundSchema;
  /** @deprecated use `StopAllTasksUnauthorized$Outbound` instead. */
  export type Outbound = StopAllTasksUnauthorized$Outbound;
}

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

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

/** @internal */
export const StopAllTasksErrors$outboundSchema: z.ZodType<
  StopAllTasksErrors$Outbound,
  z.ZodTypeDef,
  StopAllTasksErrors
> = 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 StopAllTasksErrors$ {
  /** @deprecated use `StopAllTasksErrors$inboundSchema` instead. */
  export const inboundSchema = StopAllTasksErrors$inboundSchema;
  /** @deprecated use `StopAllTasksErrors$outboundSchema` instead. */
  export const outboundSchema = StopAllTasksErrors$outboundSchema;
  /** @deprecated use `StopAllTasksErrors$Outbound` instead. */
  export type Outbound = StopAllTasksErrors$Outbound;
}

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

    return new StopAllTasksBadRequest(remapped);
  });

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

/** @internal */
export const StopAllTasksBadRequest$outboundSchema: z.ZodType<
  StopAllTasksBadRequest$Outbound,
  z.ZodTypeDef,
  StopAllTasksBadRequest
> = z.instanceof(StopAllTasksBadRequest)
  .transform(v => v.data$)
  .pipe(
    z.object({
      errors: z.array(z.lazy(() => StopAllTasksErrors$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 StopAllTasksBadRequest$ {
  /** @deprecated use `StopAllTasksBadRequest$inboundSchema` instead. */
  export const inboundSchema = StopAllTasksBadRequest$inboundSchema;
  /** @deprecated use `StopAllTasksBadRequest$outboundSchema` instead. */
  export const outboundSchema = StopAllTasksBadRequest$outboundSchema;
  /** @deprecated use `StopAllTasksBadRequest$Outbound` instead. */
  export type Outbound = StopAllTasksBadRequest$Outbound;
}
