/*
 * 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";
import {
  MediaTypeString,
  MediaTypeString$inboundSchema,
} from "./mediatypestring.js";

/**
 * Represents a top-level location on disk where media in this library section is stored
 */
export type LibrarySectionLocation = {
  id?: number | undefined;
  /**
   * The path of where this directory exists on disk
   */
  path?: any | undefined;
};

export type LibrarySection = {
  /**
   * The title of the library
   */
  title?: string | undefined;
  /**
   * The type of media content in the Plex library. This can represent videos, music, or photos.
   *
   * @remarks
   */
  type: MediaTypeString;
  agent?: string | undefined;
  allowSync?: boolean | undefined;
  art?: string | undefined;
  composite?: string | undefined;
  content?: boolean | undefined;
  contentChangedAt?: number | undefined;
  createdAt?: number | undefined;
  directory?: boolean | undefined;
  /**
   * Indicates whether this section has filtering capabilities
   */
  filters?: boolean | undefined;
  hidden?: boolean | undefined;
  key?: string | undefined;
  language: string;
  /**
   * The universally unique identifier for the library.
   */
  uuid: string;
  location?: Array<LibrarySectionLocation> | undefined;
  /**
   * Indicates whether this library section is currently scanning
   */
  refreshing?: boolean | undefined;
  scannedAt?: number | undefined;
  scanner?: string | undefined;
  thumb?: string | undefined;
  updatedAt?: number | undefined;
};

/** @internal */
export const LibrarySectionLocation$inboundSchema: z.ZodType<
  LibrarySectionLocation,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.number().int().optional(),
  path: z.any().optional(),
});

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

/** @internal */
export const LibrarySection$inboundSchema: z.ZodType<
  LibrarySection,
  z.ZodTypeDef,
  unknown
> = z.object({
  title: z.string().optional(),
  type: MediaTypeString$inboundSchema,
  agent: z.string().optional(),
  allowSync: z.boolean().optional(),
  art: z.string().optional(),
  composite: z.string().optional(),
  content: z.boolean().optional(),
  contentChangedAt: z.number().int().optional(),
  createdAt: z.number().int().optional(),
  directory: z.boolean().optional(),
  filters: z.boolean().optional(),
  hidden: z.boolean().optional(),
  key: z.string().optional(),
  language: z.string(),
  uuid: z.string(),
  Location: z.array(z.lazy(() => LibrarySectionLocation$inboundSchema))
    .optional(),
  refreshing: z.boolean().optional(),
  scannedAt: z.number().int().optional(),
  scanner: z.string().optional(),
  thumb: z.string().optional(),
  updatedAt: z.number().int().optional(),
}).transform((v) => {
  return remap$(v, {
    "Location": "location",
  });
});

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