コード例 #1
0
        // STATUS [ June 10, 2019 ] : this works
        /// <summary>
        ///     Instantiate multiple instances of yahoo player resource
        /// </summary>
        /// <param name="ListOfYahooPlayerIds">todo: describe ListOfYahooPlayerIds parameter on CreateListOfYahooPlayerResourceInstances</param>
        /// <example>
        ///     string rizzoId = "8868";
        ///     string goldschmidtId = "8967";
        ///     var playerIds = new List string
        ///     {
        ///         rizzoId,
        ///         goldschmidtId
        ///     };
        ///     var playerList = CreateListOfYahooPlayerResourceInstances(playerIds);
        /// </example>
        public List <YahooPlayerResource> CreateListOfYahooPlayerResourceInstances(List <string> ListOfYahooPlayerIds)
        {
            List <YahooPlayerResource> yahooPlayerResourceList = new List <YahooPlayerResource>();
            YahooPlayerResource        yahooPlayerResource     = new YahooPlayerResource();

            foreach (var id in ListOfYahooPlayerIds)
            {
                yahooPlayerResource = CreateYahooPlayerResourceInstances(id);
                yahooPlayerResourceList.Add(yahooPlayerResource);
            }

            // _h.Dig(yahooPlayerResourceList);
            return(yahooPlayerResourceList);
        }
コード例 #2
0
        // STATUS [ June 10, 2019 ] : this works
        /// <summary>
        ///     Instantiate new instance of yahoo player resource
        /// </summary>
        /// <param name="yahooPlayerId">
        ///     The Mlb players yahoo player id
        ///     Typically four or five numbers but fed to method as a string
        ///         E.g., "8967" instead of 8967
        /// </param>
        /// <remarks>
        ///     If you do not know the yahoo id, try the 'GetYahooPlayersIdFromPlayerName()' method to get it
        /// </remarks>
        /// <example>
        ///     var yahooPlayerResourceModel = CreateYahooPlayerResourceInstances("8967");
        /// </example>
        public YahooPlayerResource CreateYahooPlayerResourceInstances(string yahooPlayerId)
        {
            // string leagueKey = _yahooApiRequestController.GetTheGameIsTheGameLeagueKey();
            // Console.WriteLine($"YAHOO RESOURCE CONTROLLER > leagueKey: {leagueKey}");

            const string keyPrefix = "mlb.p.";
            string       playerKey = $"{keyPrefix}{yahooPlayerId}";

            // e.g., https://fantasysports.yahooapis.com/fantasy/v2/player/mlb.p.8967
            var uriPlayer = _endPoints.PlayerBaseEndPoint(playerKey).EndPointUri;

            JObject playerJObject = _yahooApiRequestController.GenerateYahooResourceJObject(uriPlayer);

            JToken playerResource       = playerJObject["fantasy_content"]["player"];
            string playerResourceString = playerResource.ToString();

            YahooPlayerResource yPlayerResource = JsonConvert.DeserializeObject <YahooPlayerResource>(playerResourceString);

            _helpers.Dig(yPlayerResource);

            return(yPlayerResource);
        }