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

/**
 * Information about the player being used for playback
 */
export type Player = {
  /**
   * The title of the client
   */
  title?: string | undefined;
  /**
   * The remote address
   */
  address?: string | undefined;
  /**
   * Indicating if the client is playing from the local LAN
   */
  local?: boolean | undefined;
  /**
   * The identifier of the client
   */
  machineIdentifier?: string | undefined;
  /**
   * The model of the client
   */
  model?: string | undefined;
  /**
   * The platform of the client
   */
  platform?: string | undefined;
  /**
   * The platformVersion of the client
   */
  platformVersion?: string | undefined;
  /**
   * The product name of the client
   */
  product?: string | undefined;
  /**
   * Indicating if the client is playing over a relay connection
   */
  relayed?: boolean | undefined;
  /**
   * The client's public address
   */
  remotePublicAddress?: string | undefined;
  /**
   * Indicating if the client is playing over HTTPS
   */
  secure?: boolean | undefined;
  /**
   * The client's last reported state
   */
  state?: string | undefined;
  /**
   * The id of the user
   */
  userID?: number | undefined;
  /**
   * The vendor of the client
   */
  vendor?: string | undefined;
  /**
   * The version of the client
   */
  version?: string | undefined;
};

/** @internal */
export const Player$inboundSchema: z.ZodType<Player, z.ZodTypeDef, unknown> = z
  .object({
    title: z.string().optional(),
    address: z.string().optional(),
    local: z.boolean().optional(),
    machineIdentifier: z.string().optional(),
    model: z.string().optional(),
    platform: z.string().optional(),
    platformVersion: z.string().optional(),
    product: z.string().optional(),
    relayed: z.boolean().optional(),
    remotePublicAddress: z.string().optional(),
    secure: z.boolean().optional(),
    state: z.string().optional(),
    userID: z.number().int().optional(),
    vendor: z.string().optional(),
    version: z.string().optional(),
  });

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