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

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

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

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

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

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

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

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

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

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

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

    return new GetGeoDataUnauthorized(remapped);
  });

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

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

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

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

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

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

    return new GetGeoDataBadRequest(remapped);
  });

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

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