/*
 * 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";

export type GetMetadataChildrenRequest = {
  /**
   * the id of the library item to return the children of.
   */
  ratingKey: number;
  /**
   * Adds additional elements to the response. Supported types are (Stream)
   *
   * @remarks
   */
  includeElements?: string | undefined;
};

export type GetMetadataChildrenDirectory = {
  leafCount?: number | undefined;
  thumb?: string | undefined;
  viewedLeafCount?: number | undefined;
  key?: string | undefined;
  title?: string | undefined;
};

export type GetMetadataChildrenMetadata = {
  ratingKey?: string | undefined;
  key?: string | undefined;
  parentRatingKey?: string | undefined;
  guid?: string | undefined;
  parentGuid?: string | undefined;
  parentStudio?: string | undefined;
  type?: string | undefined;
  title?: string | undefined;
  parentKey?: string | undefined;
  parentTitle?: string | undefined;
  summary?: string | undefined;
  index?: number | undefined;
  parentIndex?: number | undefined;
  viewCount?: number | undefined;
  lastViewedAt?: number | undefined;
  parentYear?: number | undefined;
  thumb?: string | undefined;
  art?: string | undefined;
  parentThumb?: string | undefined;
  parentTheme?: string | undefined;
  leafCount?: number | undefined;
  viewedLeafCount?: number | undefined;
  addedAt?: number | undefined;
  updatedAt?: number | undefined;
  userRating?: number | undefined;
  skipCount?: number | undefined;
  lastRatedAt?: number | undefined;
};

export type GetMetadataChildrenMediaContainer = {
  size?: number | undefined;
  allowSync?: boolean | undefined;
  art?: string | undefined;
  identifier?: string | undefined;
  key?: string | undefined;
  librarySectionID?: number | undefined;
  librarySectionTitle?: string | undefined;
  librarySectionUUID?: string | undefined;
  mediaTagPrefix?: string | undefined;
  mediaTagVersion?: number | undefined;
  nocache?: boolean | undefined;
  parentIndex?: number | undefined;
  parentTitle?: string | undefined;
  parentYear?: number | undefined;
  summary?: string | undefined;
  theme?: string | undefined;
  thumb?: string | undefined;
  title1?: string | undefined;
  title2?: string | undefined;
  viewGroup?: string | undefined;
  viewMode?: number | undefined;
  directory?: Array<GetMetadataChildrenDirectory> | undefined;
  metadata?: Array<GetMetadataChildrenMetadata> | undefined;
};

/**
 * The children of the library item.
 */
export type GetMetadataChildrenResponseBody = {
  mediaContainer?: GetMetadataChildrenMediaContainer | undefined;
};

export type GetMetadataChildrenResponse = {
  /**
   * 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;
  /**
   * The children of the library item.
   */
  object?: GetMetadataChildrenResponseBody | undefined;
};

/** @internal */
export const GetMetadataChildrenRequest$inboundSchema: z.ZodType<
  GetMetadataChildrenRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  ratingKey: z.number(),
  includeElements: z.string().optional(),
});

/** @internal */
export type GetMetadataChildrenRequest$Outbound = {
  ratingKey: number;
  includeElements?: string | undefined;
};

/** @internal */
export const GetMetadataChildrenRequest$outboundSchema: z.ZodType<
  GetMetadataChildrenRequest$Outbound,
  z.ZodTypeDef,
  GetMetadataChildrenRequest
> = z.object({
  ratingKey: z.number(),
  includeElements: z.string().optional(),
});

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

export function getMetadataChildrenRequestToJSON(
  getMetadataChildrenRequest: GetMetadataChildrenRequest,
): string {
  return JSON.stringify(
    GetMetadataChildrenRequest$outboundSchema.parse(getMetadataChildrenRequest),
  );
}

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

/** @internal */
export const GetMetadataChildrenDirectory$inboundSchema: z.ZodType<
  GetMetadataChildrenDirectory,
  z.ZodTypeDef,
  unknown
> = z.object({
  leafCount: z.number().int().optional(),
  thumb: z.string().optional(),
  viewedLeafCount: z.number().int().optional(),
  key: z.string().optional(),
  title: z.string().optional(),
});

/** @internal */
export type GetMetadataChildrenDirectory$Outbound = {
  leafCount?: number | undefined;
  thumb?: string | undefined;
  viewedLeafCount?: number | undefined;
  key?: string | undefined;
  title?: string | undefined;
};

/** @internal */
export const GetMetadataChildrenDirectory$outboundSchema: z.ZodType<
  GetMetadataChildrenDirectory$Outbound,
  z.ZodTypeDef,
  GetMetadataChildrenDirectory
> = z.object({
  leafCount: z.number().int().optional(),
  thumb: z.string().optional(),
  viewedLeafCount: z.number().int().optional(),
  key: z.string().optional(),
  title: z.string().optional(),
});

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

export function getMetadataChildrenDirectoryToJSON(
  getMetadataChildrenDirectory: GetMetadataChildrenDirectory,
): string {
  return JSON.stringify(
    GetMetadataChildrenDirectory$outboundSchema.parse(
      getMetadataChildrenDirectory,
    ),
  );
}

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

/** @internal */
export const GetMetadataChildrenMetadata$inboundSchema: z.ZodType<
  GetMetadataChildrenMetadata,
  z.ZodTypeDef,
  unknown
> = z.object({
  ratingKey: z.string().optional(),
  key: z.string().optional(),
  parentRatingKey: z.string().optional(),
  guid: z.string().optional(),
  parentGuid: z.string().optional(),
  parentStudio: z.string().optional(),
  type: z.string().optional(),
  title: z.string().optional(),
  parentKey: z.string().optional(),
  parentTitle: z.string().optional(),
  summary: z.string().optional(),
  index: z.number().int().optional(),
  parentIndex: z.number().int().optional(),
  viewCount: z.number().int().optional(),
  lastViewedAt: z.number().int().optional(),
  parentYear: z.number().int().optional(),
  thumb: z.string().optional(),
  art: z.string().optional(),
  parentThumb: z.string().optional(),
  parentTheme: z.string().optional(),
  leafCount: z.number().int().optional(),
  viewedLeafCount: z.number().int().optional(),
  addedAt: z.number().int().optional(),
  updatedAt: z.number().int().optional(),
  userRating: z.number().int().optional(),
  skipCount: z.number().int().optional(),
  lastRatedAt: z.number().int().optional(),
});

/** @internal */
export type GetMetadataChildrenMetadata$Outbound = {
  ratingKey?: string | undefined;
  key?: string | undefined;
  parentRatingKey?: string | undefined;
  guid?: string | undefined;
  parentGuid?: string | undefined;
  parentStudio?: string | undefined;
  type?: string | undefined;
  title?: string | undefined;
  parentKey?: string | undefined;
  parentTitle?: string | undefined;
  summary?: string | undefined;
  index?: number | undefined;
  parentIndex?: number | undefined;
  viewCount?: number | undefined;
  lastViewedAt?: number | undefined;
  parentYear?: number | undefined;
  thumb?: string | undefined;
  art?: string | undefined;
  parentThumb?: string | undefined;
  parentTheme?: string | undefined;
  leafCount?: number | undefined;
  viewedLeafCount?: number | undefined;
  addedAt?: number | undefined;
  updatedAt?: number | undefined;
  userRating?: number | undefined;
  skipCount?: number | undefined;
  lastRatedAt?: number | undefined;
};

/** @internal */
export const GetMetadataChildrenMetadata$outboundSchema: z.ZodType<
  GetMetadataChildrenMetadata$Outbound,
  z.ZodTypeDef,
  GetMetadataChildrenMetadata
> = z.object({
  ratingKey: z.string().optional(),
  key: z.string().optional(),
  parentRatingKey: z.string().optional(),
  guid: z.string().optional(),
  parentGuid: z.string().optional(),
  parentStudio: z.string().optional(),
  type: z.string().optional(),
  title: z.string().optional(),
  parentKey: z.string().optional(),
  parentTitle: z.string().optional(),
  summary: z.string().optional(),
  index: z.number().int().optional(),
  parentIndex: z.number().int().optional(),
  viewCount: z.number().int().optional(),
  lastViewedAt: z.number().int().optional(),
  parentYear: z.number().int().optional(),
  thumb: z.string().optional(),
  art: z.string().optional(),
  parentThumb: z.string().optional(),
  parentTheme: z.string().optional(),
  leafCount: z.number().int().optional(),
  viewedLeafCount: z.number().int().optional(),
  addedAt: z.number().int().optional(),
  updatedAt: z.number().int().optional(),
  userRating: z.number().int().optional(),
  skipCount: z.number().int().optional(),
  lastRatedAt: 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 GetMetadataChildrenMetadata$ {
  /** @deprecated use `GetMetadataChildrenMetadata$inboundSchema` instead. */
  export const inboundSchema = GetMetadataChildrenMetadata$inboundSchema;
  /** @deprecated use `GetMetadataChildrenMetadata$outboundSchema` instead. */
  export const outboundSchema = GetMetadataChildrenMetadata$outboundSchema;
  /** @deprecated use `GetMetadataChildrenMetadata$Outbound` instead. */
  export type Outbound = GetMetadataChildrenMetadata$Outbound;
}

export function getMetadataChildrenMetadataToJSON(
  getMetadataChildrenMetadata: GetMetadataChildrenMetadata,
): string {
  return JSON.stringify(
    GetMetadataChildrenMetadata$outboundSchema.parse(
      getMetadataChildrenMetadata,
    ),
  );
}

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

/** @internal */
export const GetMetadataChildrenMediaContainer$inboundSchema: z.ZodType<
  GetMetadataChildrenMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  size: z.number().int().optional(),
  allowSync: z.boolean().optional(),
  art: z.string().optional(),
  identifier: z.string().optional(),
  key: z.string().optional(),
  librarySectionID: z.number().int().optional(),
  librarySectionTitle: z.string().optional(),
  librarySectionUUID: z.string().optional(),
  mediaTagPrefix: z.string().optional(),
  mediaTagVersion: z.number().int().optional(),
  nocache: z.boolean().optional(),
  parentIndex: z.number().int().optional(),
  parentTitle: z.string().optional(),
  parentYear: z.number().int().optional(),
  summary: z.string().optional(),
  theme: z.string().optional(),
  thumb: z.string().optional(),
  title1: z.string().optional(),
  title2: z.string().optional(),
  viewGroup: z.string().optional(),
  viewMode: z.number().int().optional(),
  Directory: z.array(z.lazy(() => GetMetadataChildrenDirectory$inboundSchema))
    .optional(),
  Metadata: z.array(z.lazy(() => GetMetadataChildrenMetadata$inboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "Directory": "directory",
    "Metadata": "metadata",
  });
});

/** @internal */
export type GetMetadataChildrenMediaContainer$Outbound = {
  size?: number | undefined;
  allowSync?: boolean | undefined;
  art?: string | undefined;
  identifier?: string | undefined;
  key?: string | undefined;
  librarySectionID?: number | undefined;
  librarySectionTitle?: string | undefined;
  librarySectionUUID?: string | undefined;
  mediaTagPrefix?: string | undefined;
  mediaTagVersion?: number | undefined;
  nocache?: boolean | undefined;
  parentIndex?: number | undefined;
  parentTitle?: string | undefined;
  parentYear?: number | undefined;
  summary?: string | undefined;
  theme?: string | undefined;
  thumb?: string | undefined;
  title1?: string | undefined;
  title2?: string | undefined;
  viewGroup?: string | undefined;
  viewMode?: number | undefined;
  Directory?: Array<GetMetadataChildrenDirectory$Outbound> | undefined;
  Metadata?: Array<GetMetadataChildrenMetadata$Outbound> | undefined;
};

/** @internal */
export const GetMetadataChildrenMediaContainer$outboundSchema: z.ZodType<
  GetMetadataChildrenMediaContainer$Outbound,
  z.ZodTypeDef,
  GetMetadataChildrenMediaContainer
> = z.object({
  size: z.number().int().optional(),
  allowSync: z.boolean().optional(),
  art: z.string().optional(),
  identifier: z.string().optional(),
  key: z.string().optional(),
  librarySectionID: z.number().int().optional(),
  librarySectionTitle: z.string().optional(),
  librarySectionUUID: z.string().optional(),
  mediaTagPrefix: z.string().optional(),
  mediaTagVersion: z.number().int().optional(),
  nocache: z.boolean().optional(),
  parentIndex: z.number().int().optional(),
  parentTitle: z.string().optional(),
  parentYear: z.number().int().optional(),
  summary: z.string().optional(),
  theme: z.string().optional(),
  thumb: z.string().optional(),
  title1: z.string().optional(),
  title2: z.string().optional(),
  viewGroup: z.string().optional(),
  viewMode: z.number().int().optional(),
  directory: z.array(z.lazy(() => GetMetadataChildrenDirectory$outboundSchema))
    .optional(),
  metadata: z.array(z.lazy(() => GetMetadataChildrenMetadata$outboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    directory: "Directory",
    metadata: "Metadata",
  });
});

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

export function getMetadataChildrenMediaContainerToJSON(
  getMetadataChildrenMediaContainer: GetMetadataChildrenMediaContainer,
): string {
  return JSON.stringify(
    GetMetadataChildrenMediaContainer$outboundSchema.parse(
      getMetadataChildrenMediaContainer,
    ),
  );
}

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

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

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

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

export function getMetadataChildrenResponseBodyToJSON(
  getMetadataChildrenResponseBody: GetMetadataChildrenResponseBody,
): string {
  return JSON.stringify(
    GetMetadataChildrenResponseBody$outboundSchema.parse(
      getMetadataChildrenResponseBody,
    ),
  );
}

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

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

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

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

export function getMetadataChildrenResponseToJSON(
  getMetadataChildrenResponse: GetMetadataChildrenResponse,
): string {
  return JSON.stringify(
    GetMetadataChildrenResponse$outboundSchema.parse(
      getMetadataChildrenResponse,
    ),
  );
}

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