/*
 * 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 {
  collectExtraKeys as collectExtraKeys$,
  safeParse,
} from "../../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export enum TypeResponse {
  Intro = "intro",
  Commercial = "commercial",
  Bookmark = "bookmark",
  Resume = "resume",
  Credit = "credit",
}

/**
 * `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 PostResponses200MediaContainer = {
  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;
  color?: string | undefined;
  endTimeOffset?: number | undefined;
  id?: number | undefined;
  startTimeOffset?: number | undefined;
  title?: string | undefined;
  type?: TypeResponse | undefined;
  additionalProperties?: { [k: string]: any } | undefined;
};

/**
 * OK
 */
export type PostResponses200 = {
  mediaContainer?: PostResponses200MediaContainer | undefined;
};

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

/** @internal */
export const PostResponses200MediaContainer$inboundSchema: z.ZodType<
  PostResponses200MediaContainer,
  z.ZodTypeDef,
  unknown
> = collectExtraKeys$(
  z.object({
    identifier: z.string().optional(),
    offset: z.number().int().optional(),
    size: z.number().int().optional(),
    totalSize: z.number().int().optional(),
    color: z.string().optional(),
    endTimeOffset: z.number().int().optional(),
    id: z.number().int().optional(),
    startTimeOffset: z.number().int().optional(),
    title: z.string().optional(),
    type: TypeResponse$inboundSchema.optional(),
  }).catchall(z.any()),
  "additionalProperties",
  true,
);

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

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

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