Пример #1
0
        public async Task<SoccerSeasonResult> SoccerSeasonsAsync()
        {
            string url = "http://api.football-data.org/v1/soccerseasons";

            using (var client = new FootDataHttpClient(AuthToken))
            {
                try
                {
                    var res =await  client.GetAsync(new Uri(url));

                    string responseString = await res.Content.ReadAsStringAsync();

                    // Sanity Check
                    if (string.IsNullOrEmpty(responseString) || res.StatusCode != HttpStatusCode.OK)
                    {
                        var err = JsonConvert.DeserializeObject<ErrorResult>(responseString);

                        return new SoccerSeasonResult { error = err.error };
                    }

                    var response = JsonConvert.DeserializeObject<SoccerSeason[]>(responseString);

                    return new SoccerSeasonResult
                    {
                        Seasons = response
                    };

                }
                catch (Exception ex)
                {
                    //Ignore..
                }
            }

            return null;
        }
Пример #2
0
        public PlayersResult Players(int idTeam)
        {
            string url = $"http://api.football-data.org/v1/teams/{idTeam}/players";

            using (var client = new FootDataHttpClient(AuthToken))
            {
                try
                {
                    var res = client.GetAsync(new Uri(url)).Result;

                    string responseString = res.Content.ReadAsStringAsync().Result;

                    // Sanity Check
                    if (string.IsNullOrEmpty(responseString) || res.StatusCode != HttpStatusCode.OK)
                    {
                        var err = JsonConvert.DeserializeObject<ErrorResult>(responseString);

                        return new PlayersResult { error = err.error };
                    }


                    var response = JsonConvert.DeserializeObject<PlayersResult>(responseString);

                    return response;

                }
                catch (Exception ex)
                {
                    //Ignore..
                }
            }

            return null;
        }
Пример #3
0
        public async  Task<FixturesResult> FixturesByTeamAsync(int idTeam, string timeFrame, string season, VenueEnum? venue = null)
        {
            string url = $"http://api.football-data.org/v1/teams/{idTeam}/fixtures?timeFrame={timeFrame}&season={season}&venue={venue}";

            using (var client = new FootDataHttpClient(AuthToken))
            {
                try
                {
                    var res = await client.GetAsync(new Uri(url));

                    string responseString = await res.Content.ReadAsStringAsync();

                    // Sanity Check
                    if (string.IsNullOrEmpty(responseString) || res.StatusCode != HttpStatusCode.OK)
                    {
                        var err = JsonConvert.DeserializeObject<ErrorResult>(responseString);

                        return new FixturesResult { error = err.error };
                    }

                    var response = JsonConvert.DeserializeObject<FixturesResult>(responseString);

                    return response;
                }
                catch (Exception ex)
                {
                    //Ignore..
                }
            }

            return null;
        }
Пример #4
0
        public async Task<FixtureDetailsResult> FixtureAsync(int idFixture, int head2Head)
        {
            string url = $"http://api.football-data.org/v1/fixtures/{idFixture}?head2head={head2Head}";

            using (var client = new FootDataHttpClient(AuthToken))
            {
                try
                {
                    var res = await client.GetAsync(new Uri(url));

                    string responseString = await res.Content.ReadAsStringAsync();

                    // Sanity Check
                    if (string.IsNullOrEmpty(responseString) || res.StatusCode != HttpStatusCode.OK)
                    {
                        var err = JsonConvert.DeserializeObject<ErrorResult>(responseString);

                        return new FixtureDetailsResult { error = err.error };
                    }


                    var response = JsonConvert.DeserializeObject<FixtureDetailsResult>(responseString);

                    return response;
                }
                catch (Exception ex)
                {
                    //Ignore..
                }
            }

            return null;
        }
Пример #5
0
        public FixturesResult Fixtures(string timeFrame, string league)
        {
            string url = $"http://api.football-data.org/v1/fixtures?timeFrame={timeFrame}&league={league}";

            using (var client = new FootDataHttpClient(AuthToken))
            {
                try
                {
                    var res = client.GetAsync(new Uri(url)).Result;

                    string responseString = res.Content.ReadAsStringAsync().Result;

                    // Sanity Check
                    if (string.IsNullOrEmpty(responseString) || res.StatusCode != HttpStatusCode.OK)
                    {
                        var err = JsonConvert.DeserializeObject<ErrorResult>(responseString);

                        return new FixturesResult { error = err.error };
                    }

                    var response = JsonConvert.DeserializeObject<FixturesResult>(responseString);

                    return response;
                }
                catch (Exception ex)
                {
                    //Ignore..
                }
            }

            return null;
        }
Пример #6
0
        public async Task<FixturesResult> FixturesAsync(int idSeason, int matchday, string timeFrame)
        {
            string p1 = "";
            if (matchday > 0)
                p1 = matchday + "";

            string url =
                $"http://api.football-data.org/v1/soccerseasons/{idSeason}/fixtures?matchday={p1}&timeFrame={timeFrame}";

            using (var client = new FootDataHttpClient(AuthToken))
            {
                try
                {
                    var res = await client.GetAsync(new Uri(url));

                    string responseString = await res.Content.ReadAsStringAsync();

                    // Sanity Check
                    if (string.IsNullOrEmpty(responseString) || res.StatusCode != HttpStatusCode.OK)
                    {
                        var err = JsonConvert.DeserializeObject<ErrorResult>(responseString);

                        return new FixturesResult {error = err.error};
                    }

                    var response = JsonConvert.DeserializeObject<FixturesResult>(responseString);

                    return response;

                }
                catch (Exception ex)
                {
                    //Ignore..
                }
            }

            return null;
        }
Пример #7
0
        public LeagueTableResult LeagueTable(int idSeason, int matchday)
        {
            string mDay = "";

            if (matchday > 0)
            {
                mDay = matchday + "";
            }

            string url = $"http://api.football-data.org/v1/soccerseasons/{idSeason}/leagueTable?matchday={mDay}";

            using (var client = new FootDataHttpClient(AuthToken))
            {
                try
                {
                    var res = client.GetAsync(new Uri(url)).Result;

                    string responseString = res.Content.ReadAsStringAsync().Result;

                    // Sanity Check
                    if (string.IsNullOrEmpty(responseString) || res.StatusCode != HttpStatusCode.OK)
                    {
                        var err = JsonConvert.DeserializeObject<ErrorResult>(responseString);

                        return new LeagueTableResult { error = err.error };
                    }


                    var response = JsonConvert.DeserializeObject<LeagueTableResult>(responseString);

                    return response;
                }
                catch (Exception ex)
                {
                    //Ignore..
                }
            }

            return null;
        }