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

import * as z from "zod/v3";
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";

/**
 * Whether this hub is visible on the home screen
 *
 * @remarks
 *   - all: Visible to all users
 *   - none: Visible to no users
 *   - admin: Visible to only admin users
 *   - shared: Visible to shared users
 */
export enum HomeVisibility {
  All = "all",
  None = "none",
  Admin = "admin",
  Shared = "shared",
}

/**
 * The visibility of this hub in recommendations:
 *
 * @remarks
 *   - all: Visible to all users
 *   - none: Visible to no users
 *   - admin: Visible to only admin users
 *   - shared: Visible to shared users
 */
export enum RecommendationsVisibility {
  All = "all",
  None = "none",
  Admin = "admin",
  Shared = "shared",
}

export type HubResponse = {
  /**
   * Whether this hub is visible on the home screen
   *
   * @remarks
   *   - all: Visible to all users
   *   - none: Visible to no users
   *   - admin: Visible to only admin users
   *   - shared: Visible to shared users
   */
  homeVisibility?: HomeVisibility | undefined;
  /**
   * The identifier for this hub
   */
  identifier?: string | undefined;
  /**
   * Whether this hub is visible to admin user home
   */
  promotedToOwnHome?: boolean | undefined;
  /**
   * Whether this hub is promoted to all for recommendations
   */
  promotedToRecommended?: boolean | undefined;
  /**
   * Whether this hub is visible to shared user's home
   */
  promotedToSharedHome?: boolean | undefined;
  /**
   * The visibility of this hub in recommendations:
   *
   * @remarks
   *   - all: Visible to all users
   *   - none: Visible to no users
   *   - admin: Visible to only admin users
   *   - shared: Visible to shared users
   */
  recommendationsVisibility?: RecommendationsVisibility | undefined;
  /**
   * The title of this hub
   */
  title?: string | undefined;
};

/**
 * `MediaContainer` is the root element of most Plex API responses. It serves as a generic container for various types of content (Metadata, Hubs, Directories, etc.) and includes pagination information (offset, size, totalSize) when applicable.
 *
 * @remarks
 * Common attributes: - identifier: Unique identifier for this container - size: Number of items in this response page - totalSize: Total number of items available (for pagination) - offset: Starting index of this page (for pagination)
 * The container often "hoists" common attributes from its children. For example, if all tracks in a container share the same album title, the `parentTitle` attribute may appear on the MediaContainer rather than being repeated on each track.
 */
export type GetResponses200MediaContainer = {
  identifier?: string | undefined;
  /**
   * The offset of where this container page starts among the total objects available. Also provided in the `X-Plex-Container-Start` header.
   *
   * @remarks
   */
  offset?: number | undefined;
  size?: number | undefined;
  /**
   * The total size of objects available. Also provided in the `X-Plex-Container-Total-Size` header.
   *
   * @remarks
   */
  totalSize?: number | undefined;
  hub?: Array<HubResponse> | undefined;
};

/**
 * OK
 */
export type GetResponses200 = {
  mediaContainer?: GetResponses200MediaContainer | undefined;
};

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

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

/** @internal */
export const HubResponse$inboundSchema: z.ZodType<
  HubResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  homeVisibility: HomeVisibility$inboundSchema.optional(),
  identifier: z.string().optional(),
  promotedToOwnHome: z.boolean().optional(),
  promotedToRecommended: z.boolean().optional(),
  promotedToSharedHome: z.boolean().optional(),
  recommendationsVisibility: RecommendationsVisibility$inboundSchema.optional(),
  title: z.string().optional(),
});

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

/** @internal */
export const GetResponses200MediaContainer$inboundSchema: z.ZodType<
  GetResponses200MediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  identifier: z.string().optional(),
  offset: z.number().int().optional(),
  size: z.number().int().optional(),
  totalSize: z.number().int().optional(),
  Hub: z.array(z.lazy(() => HubResponse$inboundSchema)).optional(),
}).transform((v) => {
  return remap$(v, {
    "Hub": "hub",
  });
});

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

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

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