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

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

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

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

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

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

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

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

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

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

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

    return new LogMultiLineUnauthorized(remapped);
  });

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

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

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

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

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

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

    return new LogMultiLineBadRequest(remapped);
  });

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

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