public List <Player> CreatePlayerListFromPlayersCollection(YahooPlayersCollection collection)
        {
            var players = collection.Players;

            List <Player> listOfPlayers = new List <Player>();

            // if just one player is returned in the collection, players.Player will be a JObject
            if (players.Player is JObject)
            {
                JObject playerJToken = (JObject)players.Player;
                Player  player       = JsonConvert.DeserializeObject <Player>(playerJToken.ToString());
                listOfPlayers.Add(player);
            }

            // if multiple players are returned in the collection, players.Player will be a JArray
            else
            {
                JArray playersJArray = (JArray)players.Player;
                int    playersCount  = playersJArray.Count;
                for (var counter = 0; counter < playersCount; counter++)
                {
                    var    playerJToken = playersJArray[counter];
                    Player player       = JsonConvert.DeserializeObject <Player>(playerJToken.ToString());
                    listOfPlayers.Add(player);
                }
            }
            // PrintPlayerInfoFromList(listOfPlayers);
            return(listOfPlayers);
        }
        public YahooPlayersCollection FilterByPositionAndStatusThenCreateInstance(string position, string status)
        {
            string leagueKey            = _yahooApiRequestController.GetTheGameIsTheGameLeagueKey();
            string uriPlayersCollection = _endPoints.PlayersCollectionForPositionAndStatus(leagueKey, position, status).EndPointUri;
            YahooPlayersCollection yPc  = CreatePlayersCollectionInstance(uriPlayersCollection);

            return(yPc);
        }
        public YahooPlayersCollection FilterByPlayerNameThenCreateInstance(string playerName)
        {
            string leagueKey            = _yahooApiRequestController.GetTheGameIsTheGameLeagueKey();
            string uriPlayersCollection = _endPoints.PlayersCollectionForPlayerName(leagueKey, playerName).EndPointUri;
            YahooPlayersCollection yPc  = CreatePlayersCollectionInstance(uriPlayersCollection);

            return(yPc);
        }
        private YahooPlayersCollection CreatePlayersCollectionInstance(string uriPlayersCollection)
        {
            JObject collectionJObject = _yahooApiRequestController.GenerateYahooResourceJObject(uriPlayersCollection);
            // _h.Dig(collectionJObject);

            JToken yahooPlayersCollectionToken = collectionJObject["fantasy_content"]["league"];

            string playersCollectionString = yahooPlayersCollectionToken.ToString();

            YahooPlayersCollection playersCollection = YahooPlayersCollection.FromJson(playersCollectionString);

            // PrintPlayerNameAndTeamName(playersCollectionString);
            return(playersCollection);
        }
        public void PrintPlayerNameAndTeamName(string PlayersCollectionString)
        {
            var playersCollection = YahooPlayersCollection.FromJson(PlayersCollectionString);
            // _h.Dig(playersCollection);

            List <Player> listOfPlayers = CreatePlayerListFromPlayersCollection(playersCollection);
            int           count         = listOfPlayers.Count;

            Console.WriteLine("---------------------------------------------");
            Console.WriteLine($"PLAYERS COLLECTION SEARCH || COUNT: {count}");
            Console.WriteLine("---------------------------------------------");

            foreach (var player in listOfPlayers)
            {
                Console.WriteLine(player.Name.Full);
                Console.WriteLine(player.EditorialTeamFullName);
                Console.WriteLine();
            }
            Console.WriteLine("---------------------------------------------");
            Console.WriteLine();
        }