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

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

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

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

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

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

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

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

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

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

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

    return new GetServerActivitiesUnauthorized(remapped);
  });

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

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

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

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

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

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

    return new GetServerActivitiesBadRequest(remapped);
  });

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

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