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

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

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

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

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

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

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

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

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

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

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

    return new DeletePlaylistUnauthorized(remapped);
  });

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

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

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

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

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

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

    return new DeletePlaylistBadRequest(remapped);
  });

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

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