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

import * as z from "zod/v3";
import { safeParse } from "../../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * A variety of extra information about a metadata item is included as tags. These tags use their own element names such as `Genre`, `Writer`, `Directory`, and `Role`. Individual tag types may introduce their own extra attributes.
 *
 * @remarks
 */
export type Tag = {
  /**
   * Measure of the confidence of an automatic tag
   */
  confidence?: number | undefined;
  context?: string | undefined;
  /**
   * A filter parameter that can be used to query for more content that matches this tag value.
   */
  filter?: string | undefined;
  id?: number | undefined;
  /**
   * The rating key (Media ID) of this media item. Note: Although this is always an integer, it is represented as a string in the API.
   */
  ratingKey?: string | undefined;
  /**
   * The role this actor played
   */
  role?: string | undefined;
  /**
   * The value of the tag (the name)
   */
  tag: string;
  /**
   * Plex identifier for this tag which can be used to fetch additional information from plex.tv
   */
  tagKey?: string | undefined;
  tagType?: number | undefined;
  thumb?: string | undefined;
};

/** @internal */
export const Tag$inboundSchema: z.ZodType<Tag, z.ZodTypeDef, unknown> = z
  .object({
    confidence: z.number().optional(),
    context: z.string().optional(),
    filter: z.string().optional(),
    id: z.number().int().optional(),
    ratingKey: z.string().optional(),
    role: z.string().optional(),
    tag: z.string(),
    tagKey: z.string().optional(),
    tagType: z.number().int().optional(),
    thumb: z.string().optional(),
  });

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