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

/**
 * The user playing the content
 */
export type User = {
  /**
   * The username
   */
  title?: string | undefined;
  /**
   * The id of the user
   */
  id?: string | undefined;
  /**
   * Thumb image to display for the user
   */
  thumb?: string | undefined;
};

/** @internal */
export const User$inboundSchema: z.ZodType<User, z.ZodTypeDef, unknown> = z
  .object({
    title: z.string().optional(),
    id: z.string().optional(),
    thumb: z.string().optional(),
  });

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