/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod";
import { remap as remap$ } from "../../../lib/primitives.js";
import { safeParse } from "../../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * The type of media to retrieve or filter by.
 *
 * @remarks
 * 1 = movie
 * 2 = show
 * 3 = season
 * 4 = episode
 * E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
 */
export enum GetGenresLibraryQueryParamType {
  Movie = 1,
  TvShow = 2,
  Season = 3,
  Episode = 4,
  Audio = 8,
  Album = 9,
  Track = 10,
}

export type GetGenresLibraryRequest = {
  /**
   * The unique key of the Plex library.
   *
   * @remarks
   * Note: This is unique in the context of the Plex server.
   */
  sectionKey: number;
  /**
   * The type of media to retrieve or filter by.
   *
   * @remarks
   * 1 = movie
   * 2 = show
   * 3 = season
   * 4 = episode
   * E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries
   */
  type: GetGenresLibraryQueryParamType;
};

export type GetGenresLibraryDirectory = {
  fastKey: string;
  key: string;
  title: string;
  type: string;
};

export type GetGenresLibraryMediaContainer = {
  size: number;
  offset?: number | undefined;
  totalSize?: number | undefined;
  identifier: string;
  allowSync: boolean;
  art: string;
  content: string;
  mediaTagPrefix: string;
  mediaTagVersion: number;
  nocache: boolean;
  thumb: string;
  title1: string;
  title2: string;
  viewGroup: string;
  directory?: Array<GetGenresLibraryDirectory> | undefined;
};

/**
 * Successful response containing media container data.
 */
export type GetGenresLibraryResponseBody = {
  mediaContainer?: GetGenresLibraryMediaContainer | undefined;
};

export type GetGenresLibraryResponse = {
  /**
   * HTTP response content type for this operation
   */
  contentType: string;
  /**
   * HTTP response status code for this operation
   */
  statusCode: number;
  /**
   * Raw HTTP response; suitable for custom response parsing
   */
  rawResponse: Response;
  /**
   * Successful response containing media container data.
   */
  object?: GetGenresLibraryResponseBody | undefined;
};

/** @internal */
export const GetGenresLibraryQueryParamType$inboundSchema: z.ZodNativeEnum<
  typeof GetGenresLibraryQueryParamType
> = z.nativeEnum(GetGenresLibraryQueryParamType);

/** @internal */
export const GetGenresLibraryQueryParamType$outboundSchema: z.ZodNativeEnum<
  typeof GetGenresLibraryQueryParamType
> = GetGenresLibraryQueryParamType$inboundSchema;

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace GetGenresLibraryQueryParamType$ {
  /** @deprecated use `GetGenresLibraryQueryParamType$inboundSchema` instead. */
  export const inboundSchema = GetGenresLibraryQueryParamType$inboundSchema;
  /** @deprecated use `GetGenresLibraryQueryParamType$outboundSchema` instead. */
  export const outboundSchema = GetGenresLibraryQueryParamType$outboundSchema;
}

/** @internal */
export const GetGenresLibraryRequest$inboundSchema: z.ZodType<
  GetGenresLibraryRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  sectionKey: z.number().int(),
  type: GetGenresLibraryQueryParamType$inboundSchema,
});

/** @internal */
export type GetGenresLibraryRequest$Outbound = {
  sectionKey: number;
  type: number;
};

/** @internal */
export const GetGenresLibraryRequest$outboundSchema: z.ZodType<
  GetGenresLibraryRequest$Outbound,
  z.ZodTypeDef,
  GetGenresLibraryRequest
> = z.object({
  sectionKey: z.number().int(),
  type: GetGenresLibraryQueryParamType$outboundSchema,
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace GetGenresLibraryRequest$ {
  /** @deprecated use `GetGenresLibraryRequest$inboundSchema` instead. */
  export const inboundSchema = GetGenresLibraryRequest$inboundSchema;
  /** @deprecated use `GetGenresLibraryRequest$outboundSchema` instead. */
  export const outboundSchema = GetGenresLibraryRequest$outboundSchema;
  /** @deprecated use `GetGenresLibraryRequest$Outbound` instead. */
  export type Outbound = GetGenresLibraryRequest$Outbound;
}

export function getGenresLibraryRequestToJSON(
  getGenresLibraryRequest: GetGenresLibraryRequest,
): string {
  return JSON.stringify(
    GetGenresLibraryRequest$outboundSchema.parse(getGenresLibraryRequest),
  );
}

export function getGenresLibraryRequestFromJSON(
  jsonString: string,
): SafeParseResult<GetGenresLibraryRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetGenresLibraryRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetGenresLibraryRequest' from JSON`,
  );
}

/** @internal */
export const GetGenresLibraryDirectory$inboundSchema: z.ZodType<
  GetGenresLibraryDirectory,
  z.ZodTypeDef,
  unknown
> = z.object({
  fastKey: z.string(),
  key: z.string(),
  title: z.string(),
  type: z.string(),
});

/** @internal */
export type GetGenresLibraryDirectory$Outbound = {
  fastKey: string;
  key: string;
  title: string;
  type: string;
};

/** @internal */
export const GetGenresLibraryDirectory$outboundSchema: z.ZodType<
  GetGenresLibraryDirectory$Outbound,
  z.ZodTypeDef,
  GetGenresLibraryDirectory
> = z.object({
  fastKey: z.string(),
  key: z.string(),
  title: z.string(),
  type: z.string(),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace GetGenresLibraryDirectory$ {
  /** @deprecated use `GetGenresLibraryDirectory$inboundSchema` instead. */
  export const inboundSchema = GetGenresLibraryDirectory$inboundSchema;
  /** @deprecated use `GetGenresLibraryDirectory$outboundSchema` instead. */
  export const outboundSchema = GetGenresLibraryDirectory$outboundSchema;
  /** @deprecated use `GetGenresLibraryDirectory$Outbound` instead. */
  export type Outbound = GetGenresLibraryDirectory$Outbound;
}

export function getGenresLibraryDirectoryToJSON(
  getGenresLibraryDirectory: GetGenresLibraryDirectory,
): string {
  return JSON.stringify(
    GetGenresLibraryDirectory$outboundSchema.parse(getGenresLibraryDirectory),
  );
}

export function getGenresLibraryDirectoryFromJSON(
  jsonString: string,
): SafeParseResult<GetGenresLibraryDirectory, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetGenresLibraryDirectory$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetGenresLibraryDirectory' from JSON`,
  );
}

/** @internal */
export const GetGenresLibraryMediaContainer$inboundSchema: z.ZodType<
  GetGenresLibraryMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  size: z.number(),
  offset: z.number().int().optional(),
  totalSize: z.number().int().optional(),
  identifier: z.string(),
  allowSync: z.boolean(),
  art: z.string(),
  content: z.string(),
  mediaTagPrefix: z.string(),
  mediaTagVersion: z.number().int(),
  nocache: z.boolean(),
  thumb: z.string(),
  title1: z.string(),
  title2: z.string(),
  viewGroup: z.string(),
  Directory: z.array(z.lazy(() => GetGenresLibraryDirectory$inboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "Directory": "directory",
  });
});

/** @internal */
export type GetGenresLibraryMediaContainer$Outbound = {
  size: number;
  offset?: number | undefined;
  totalSize?: number | undefined;
  identifier: string;
  allowSync: boolean;
  art: string;
  content: string;
  mediaTagPrefix: string;
  mediaTagVersion: number;
  nocache: boolean;
  thumb: string;
  title1: string;
  title2: string;
  viewGroup: string;
  Directory?: Array<GetGenresLibraryDirectory$Outbound> | undefined;
};

/** @internal */
export const GetGenresLibraryMediaContainer$outboundSchema: z.ZodType<
  GetGenresLibraryMediaContainer$Outbound,
  z.ZodTypeDef,
  GetGenresLibraryMediaContainer
> = z.object({
  size: z.number(),
  offset: z.number().int().optional(),
  totalSize: z.number().int().optional(),
  identifier: z.string(),
  allowSync: z.boolean(),
  art: z.string(),
  content: z.string(),
  mediaTagPrefix: z.string(),
  mediaTagVersion: z.number().int(),
  nocache: z.boolean(),
  thumb: z.string(),
  title1: z.string(),
  title2: z.string(),
  viewGroup: z.string(),
  directory: z.array(z.lazy(() => GetGenresLibraryDirectory$outboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    directory: "Directory",
  });
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace GetGenresLibraryMediaContainer$ {
  /** @deprecated use `GetGenresLibraryMediaContainer$inboundSchema` instead. */
  export const inboundSchema = GetGenresLibraryMediaContainer$inboundSchema;
  /** @deprecated use `GetGenresLibraryMediaContainer$outboundSchema` instead. */
  export const outboundSchema = GetGenresLibraryMediaContainer$outboundSchema;
  /** @deprecated use `GetGenresLibraryMediaContainer$Outbound` instead. */
  export type Outbound = GetGenresLibraryMediaContainer$Outbound;
}

export function getGenresLibraryMediaContainerToJSON(
  getGenresLibraryMediaContainer: GetGenresLibraryMediaContainer,
): string {
  return JSON.stringify(
    GetGenresLibraryMediaContainer$outboundSchema.parse(
      getGenresLibraryMediaContainer,
    ),
  );
}

export function getGenresLibraryMediaContainerFromJSON(
  jsonString: string,
): SafeParseResult<GetGenresLibraryMediaContainer, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetGenresLibraryMediaContainer$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetGenresLibraryMediaContainer' from JSON`,
  );
}

/** @internal */
export const GetGenresLibraryResponseBody$inboundSchema: z.ZodType<
  GetGenresLibraryResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  MediaContainer: z.lazy(() => GetGenresLibraryMediaContainer$inboundSchema)
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "MediaContainer": "mediaContainer",
  });
});

/** @internal */
export type GetGenresLibraryResponseBody$Outbound = {
  MediaContainer?: GetGenresLibraryMediaContainer$Outbound | undefined;
};

/** @internal */
export const GetGenresLibraryResponseBody$outboundSchema: z.ZodType<
  GetGenresLibraryResponseBody$Outbound,
  z.ZodTypeDef,
  GetGenresLibraryResponseBody
> = z.object({
  mediaContainer: z.lazy(() => GetGenresLibraryMediaContainer$outboundSchema)
    .optional(),
}).transform((v) => {
  return remap$(v, {
    mediaContainer: "MediaContainer",
  });
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace GetGenresLibraryResponseBody$ {
  /** @deprecated use `GetGenresLibraryResponseBody$inboundSchema` instead. */
  export const inboundSchema = GetGenresLibraryResponseBody$inboundSchema;
  /** @deprecated use `GetGenresLibraryResponseBody$outboundSchema` instead. */
  export const outboundSchema = GetGenresLibraryResponseBody$outboundSchema;
  /** @deprecated use `GetGenresLibraryResponseBody$Outbound` instead. */
  export type Outbound = GetGenresLibraryResponseBody$Outbound;
}

export function getGenresLibraryResponseBodyToJSON(
  getGenresLibraryResponseBody: GetGenresLibraryResponseBody,
): string {
  return JSON.stringify(
    GetGenresLibraryResponseBody$outboundSchema.parse(
      getGenresLibraryResponseBody,
    ),
  );
}

export function getGenresLibraryResponseBodyFromJSON(
  jsonString: string,
): SafeParseResult<GetGenresLibraryResponseBody, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetGenresLibraryResponseBody$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetGenresLibraryResponseBody' from JSON`,
  );
}

/** @internal */
export const GetGenresLibraryResponse$inboundSchema: z.ZodType<
  GetGenresLibraryResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  ContentType: z.string(),
  StatusCode: z.number().int(),
  RawResponse: z.instanceof(Response),
  object: z.lazy(() => GetGenresLibraryResponseBody$inboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    "ContentType": "contentType",
    "StatusCode": "statusCode",
    "RawResponse": "rawResponse",
  });
});

/** @internal */
export type GetGenresLibraryResponse$Outbound = {
  ContentType: string;
  StatusCode: number;
  RawResponse: never;
  object?: GetGenresLibraryResponseBody$Outbound | undefined;
};

/** @internal */
export const GetGenresLibraryResponse$outboundSchema: z.ZodType<
  GetGenresLibraryResponse$Outbound,
  z.ZodTypeDef,
  GetGenresLibraryResponse
> = z.object({
  contentType: z.string(),
  statusCode: z.number().int(),
  rawResponse: z.instanceof(Response).transform(() => {
    throw new Error("Response cannot be serialized");
  }),
  object: z.lazy(() => GetGenresLibraryResponseBody$outboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    contentType: "ContentType",
    statusCode: "StatusCode",
    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 GetGenresLibraryResponse$ {
  /** @deprecated use `GetGenresLibraryResponse$inboundSchema` instead. */
  export const inboundSchema = GetGenresLibraryResponse$inboundSchema;
  /** @deprecated use `GetGenresLibraryResponse$outboundSchema` instead. */
  export const outboundSchema = GetGenresLibraryResponse$outboundSchema;
  /** @deprecated use `GetGenresLibraryResponse$Outbound` instead. */
  export type Outbound = GetGenresLibraryResponse$Outbound;
}

export function getGenresLibraryResponseToJSON(
  getGenresLibraryResponse: GetGenresLibraryResponse,
): string {
  return JSON.stringify(
    GetGenresLibraryResponse$outboundSchema.parse(getGenresLibraryResponse),
  );
}

export function getGenresLibraryResponseFromJSON(
  jsonString: string,
): SafeParseResult<GetGenresLibraryResponse, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetGenresLibraryResponse$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetGenresLibraryResponse' from JSON`,
  );
}
