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

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

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

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

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

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

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

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

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

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

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

    return new MarkUnplayedUnauthorized(remapped);
  });

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

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

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

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

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

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

    return new MarkUnplayedBadRequest(remapped);
  });

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

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