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);
        }
        public async Task <PlayersResult> PlayersAsync(int idTeam)
        {
            string url = $"http://api.football-data.org/v1/teams/{idTeam}/players";

            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 PlayersResult {
                            error = err.error
                        });
                    }


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

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

            return(null);
        }
        public TeamsResult Teams(int idSeason)
        {
            string url = $"http://api.football-data.org/v1/soccerseasons/{idSeason}/teams";

            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 TeamsResult {
                            error = err.error
                        });
                    }


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

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

            return(null);
        }
        public FixtureDetailsResult Fixture(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 = 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 FixtureDetailsResult {
                            error = err.error
                        });
                    }


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

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

            return(null);
        }
Exemple #5
0
        public SoccerSeason GetCustomSeason(string url)
        {
            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 SoccerSeason());
                    }

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

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

            return(null);
        }
Exemple #6
0
        public FixturesResult GetFixtures(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)
                {
                    //Ignore..
                }
            }

            return(null);
        }
        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);
        }
        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);
        }
Exemple #9
0
        public async Task <SoccerSeasonResult> GetSoccerSeasonsAsync(string customUrl = null)
        {
            string url = customUrl != null ? customUrl : "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)
                {
                    //Ignore..
                }
            }

            return(null);
        }