/*
 * 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 * as shared from "../shared/index.js";

export type GetLibraryDetailsGlobals = {
  /**
   * Indicates the client accepts the indicated media types
   */
  accepts?: shared.Accepts | undefined;
  /**
   * An opaque identifier unique to the client
   */
  clientIdentifier?: string | undefined;
  /**
   * The name of the client product
   */
  product?: string | undefined;
  /**
   * The version of the client application
   */
  version?: string | undefined;
  /**
   * The platform of the client
   */
  platform?: string | undefined;
  /**
   * The version of the platform
   */
  platformVersion?: string | undefined;
  /**
   * A relatively friendly name for the client device
   */
  device?: string | undefined;
  /**
   * A potentially less friendly identifier for the device model
   */
  model?: string | undefined;
  /**
   * The device vendor
   */
  deviceVendor?: string | undefined;
  /**
   * A friendly name for the client
   */
  deviceName?: string | undefined;
  /**
   * The marketplace on which the client application is distributed
   */
  marketplace?: string | undefined;
};

export type GetLibraryDetailsRequest = {
  /**
   * Indicates the client accepts the indicated media types
   */
  accepts?: shared.Accepts | undefined;
  /**
   * An opaque identifier unique to the client
   */
  clientIdentifier?: string | undefined;
  /**
   * The name of the client product
   */
  product?: string | undefined;
  /**
   * The version of the client application
   */
  version?: string | undefined;
  /**
   * The platform of the client
   */
  platform?: string | undefined;
  /**
   * The version of the platform
   */
  platformVersion?: string | undefined;
  /**
   * A relatively friendly name for the client device
   */
  device?: string | undefined;
  /**
   * A potentially less friendly identifier for the device model
   */
  model?: string | undefined;
  /**
   * The device vendor
   */
  deviceVendor?: string | undefined;
  /**
   * A friendly name for the client
   */
  deviceName?: string | undefined;
  /**
   * The marketplace on which the client application is distributed
   */
  marketplace?: string | undefined;
  /**
   * The section identifier
   */
  sectionId: string;
  /**
   * Whether or not to include details for a section (types, filters, and sorts). Only exists for backwards compatibility, media providers other than the server libraries have it on always.
   */
  includeDetails?: shared.BoolInt | undefined;
};

export type GetLibraryDetailsMediaContainer = {
  /**
   * The flavors of directory found here:
   *
   * @remarks
   *   - Primary: (e.g. all, On Deck) These are still used in some clients to provide "shortcuts" to subsets of media. However, with the exception of On Deck, all of them can be created by media queries, and the desire is to allow these to be customized by users.
   *   - Secondary: These are marked with `"secondary": true` and were used by old clients to provide nested menus allowing for primative (but structured) navigation.
   *   - Special: There is a By Folder entry which allows browsing the media by the underlying filesystem structure, and there's a completely obsolete entry marked `"search": true` which used to be used to allow clients to build search dialogs on the fly.
   */
  content?: string | undefined;
  allowSync?: boolean | undefined;
  art?: string | undefined;
  directory?: Array<shared.Metadata> | undefined;
  identifier?: string | undefined;
  librarySectionID?: number | undefined;
  mediaTagPrefix?: string | undefined;
  mediaTagVersion?: number | undefined;
  size?: number | undefined;
  sortAsc?: boolean | undefined;
  thumb?: string | undefined;
  title1?: string | undefined;
  viewGroup?: string | undefined;
  viewMode?: number | undefined;
};

/**
 * OK
 */
export type GetLibraryDetailsResponseBody = {
  mediaContainer?: GetLibraryDetailsMediaContainer | undefined;
};

export type GetLibraryDetailsResponse = {
  /**
   * 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;
  /**
   * OK
   */
  object?: GetLibraryDetailsResponseBody | undefined;
};

/** @internal */
export type GetLibraryDetailsRequest$Outbound = {
  accepts: string;
  "Client-Identifier"?: string | undefined;
  Product?: string | undefined;
  Version?: string | undefined;
  Platform?: string | undefined;
  "Platform-Version"?: string | undefined;
  Device?: string | undefined;
  Model?: string | undefined;
  "Device-Vendor"?: string | undefined;
  "Device-Name"?: string | undefined;
  Marketplace?: string | undefined;
  sectionId: string;
  includeDetails: number;
};

/** @internal */
export const GetLibraryDetailsRequest$outboundSchema: z.ZodType<
  GetLibraryDetailsRequest$Outbound,
  z.ZodTypeDef,
  GetLibraryDetailsRequest
> = z.object({
  accepts: shared.Accepts$outboundSchema.default(shared.Accepts.ApplicationXml),
  clientIdentifier: z.string().optional(),
  product: z.string().optional(),
  version: z.string().optional(),
  platform: z.string().optional(),
  platformVersion: z.string().optional(),
  device: z.string().optional(),
  model: z.string().optional(),
  deviceVendor: z.string().optional(),
  deviceName: z.string().optional(),
  marketplace: z.string().optional(),
  sectionId: z.string(),
  includeDetails: shared.BoolInt$outboundSchema.default(shared.BoolInt.False),
}).transform((v) => {
  return remap$(v, {
    clientIdentifier: "Client-Identifier",
    product: "Product",
    version: "Version",
    platform: "Platform",
    platformVersion: "Platform-Version",
    device: "Device",
    model: "Model",
    deviceVendor: "Device-Vendor",
    deviceName: "Device-Name",
    marketplace: "Marketplace",
  });
});

export function getLibraryDetailsRequestToJSON(
  getLibraryDetailsRequest: GetLibraryDetailsRequest,
): string {
  return JSON.stringify(
    GetLibraryDetailsRequest$outboundSchema.parse(getLibraryDetailsRequest),
  );
}

/** @internal */
export const GetLibraryDetailsMediaContainer$inboundSchema: z.ZodType<
  GetLibraryDetailsMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  content: z.string().optional(),
  allowSync: z.boolean().optional(),
  art: z.string().optional(),
  Directory: z.array(shared.Metadata$inboundSchema).optional(),
  identifier: z.string().optional(),
  librarySectionID: z.number().int().optional(),
  mediaTagPrefix: z.string().optional(),
  mediaTagVersion: z.number().int().optional(),
  size: z.number().int().optional(),
  sortAsc: z.boolean().optional(),
  thumb: z.string().optional(),
  title1: z.string().optional(),
  viewGroup: z.string().optional(),
  viewMode: z.number().int().optional(),
}).transform((v) => {
  return remap$(v, {
    "Directory": "directory",
  });
});

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

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

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

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

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