Example #1
0
        //Pass Null for any values not needed
        public List <TeamScheduleResult> get(string sport, string teamId, string season, string since, string until, string order)
        {
            string jsonStr, url = "";
            List <TeamScheduleResult> scheduleResult = null;

            NameValueCollection queryParameters = new NameValueCollection();

            using (var client = new GZipWebClient(_apiKey, _userAgentName, true))
            {
                if (_alternateDomain == null)
                {
                    url = "https://erikberg.com/" + sport + "/results/" + teamId + ".json";
                }
                else
                {
                    url = "https://" + _alternateDomain + "/" + sport + "/results/" + teamId + ".json";
                }

                if (season != null)
                {
                    queryParameters.Add("season", season);
                }
                if (since != null)
                {
                    queryParameters.Add("since", since);
                }
                if (until != null)
                {
                    queryParameters.Add("until", until);
                }
                if (order != null)
                {
                    queryParameters.Add("order", order);
                }

                if (queryParameters.Count > 0)
                {
                    url += RequestHelpers.ToQueryString(queryParameters);
                }

                jsonStr        = client.DownloadString(url);
                scheduleResult = JsonConvert.DeserializeObject <List <XMLStats.TeamScheduleResult> >(jsonStr);

                return(scheduleResult);
            }
        }
        //Pass Null for any values not needed
        public NBABoxScore get(DateTime eventDate, string visitingTeam, string homeTeam)
        {
            string      jsonStr, url = "";
            NBABoxScore scheduleResult = null;

            using (var client = new GZipWebClient(_apiKey, _userAgentName, true))
            {
                if (_alternateDomain == null)
                {
                    url = "https://erikberg.com/nba/boxscore/" + eventDate.ToString("yyyyMMdd") + "-" + visitingTeam + "-at-" + homeTeam + ".json";
                }
                else
                {
                    url = "https://" + _alternateDomain + "/nba/boxscore/" + eventDate.ToString("yyyyMMdd") + "-" + visitingTeam + "-at-" + homeTeam + ".json";
                }

                jsonStr        = client.DownloadString(url);
                scheduleResult = JsonConvert.DeserializeObject <NBABoxScore>(jsonStr);

                return(scheduleResult);
            }
        }
Example #3
0
        //Pass Null for any values not needed
        public MLBBoxScore get(string _eventId)
        {
            string      jsonStr, url = "";
            MLBBoxScore scheduleResult = null;


            using (var client = new GZipWebClient(_apiKey, _userAgentName, true))
            {
                if (_alternateDomain == null)
                {
                    url = "https://erikberg.com/mlb/boxscore/" + _eventId + ".json";
                }
                else
                {
                    url = "https://" + _alternateDomain + "/mlb/boxscore/" + _eventId + ".json";
                }

                jsonStr        = client.DownloadString(url);
                scheduleResult = JsonConvert.DeserializeObject <MLBBoxScore>(jsonStr);

                return(scheduleResult);
            }
        }
Example #4
0
        public EventList get(string sport, DateTime date)
        {
            string              jsonStr, url = "";
            EventList           eventResult     = null;
            NameValueCollection queryParameters = new NameValueCollection();

            using (var client = new GZipWebClient(_apiKey, _userAgentName, true))
            {
                if (_alternateDomain == null)
                {
                    url = "https://erikberg.com/events.json";
                }
                else
                {
                    url = "https://" + _alternateDomain + "/events.json";
                }

                if (sport != null)
                {
                    queryParameters.Add("sport", sport);
                }
                if (date != null)
                {
                    queryParameters.Add("date", date.ToString("yyyyMMdd"));
                }

                if (queryParameters.Count > 0)
                {
                    url += RequestHelpers.ToQueryString(queryParameters);
                }

                jsonStr     = client.DownloadString(url);
                eventResult = JsonConvert.DeserializeObject <EventList>(jsonStr);

                return(eventResult);
            }
        }