lib/sportradar/api/soccer.rb in sportradar-api-0.1.38 vs lib/sportradar/api/soccer.rb in sportradar-api-0.9.0

- old
+ new

@@ -9,68 +9,112 @@ @access_level = access_level end def schedule response = get request_url("matches/schedule") - Sportradar::Api::Soccer::Schedule.new response + if response.success? + Sportradar::Api::Soccer::Schedule.new response + else + response + end end # date = Date.parse('2016-07-17') def daily_schedule(date = Date.today) response = get request_url("matches/#{date_path(date)}/schedule") - Sportradar::Api::Soccer::Schedule.new response + if response.success? + Sportradar::Api::Soccer::Schedule.new response + else + response + end end def daily_summary(date = Date.today) response = get request_url("matches/#{date_path(date)}/summary") - Sportradar::Api::Soccer::Summary.new response + if response.success? + Sportradar::Api::Soccer::Summary.new response + else + response + end end def daily_boxscore(date = Date.today) response = get request_url("matches/#{date_path(date)}/boxscore") - Sportradar::Api::Soccer::Boxscore.new response + if response.success? + Sportradar::Api::Soccer::Boxscore.new response + else + response + end end # match_id = "357607e9-87cd-4848-b53e-0485d9c1a3bc" def match_summary(match_id) check_simulation(match_id) response = get request_url("matches/#{match_id}/summary") - Sportradar::Api::Soccer::Summary.new response + if response.success? + Sportradar::Api::Soccer::Summary.new response + else + response + end end # match_id = "357607e9-87cd-4848-b53e-0485d9c1a3bc" def match_boxscore(match_id) check_simulation(match_id) response = get request_url("matches/#{match_id}/boxscore") - Sportradar::Api::Soccer::Boxscore.new response + if response.success? + Sportradar::Api::Soccer::Boxscore.new response + else + response + end end # team_id = "b78b9f61-0697-4347-a1b6-b7685a130eb1" def team_profile(team_id) response = get request_url("teams/#{team_id}/profile") - Sportradar::Api::Soccer::Team.new response["profile"]["team"] if response.success? + if response.success? && response["profile"] && response["profile"]["team"] + Sportradar::Api::Soccer::Team.new response["profile"]["team"] + else + response + end end # player_id = "2aeacd39-3f9c-42af-957e-9df8573973c4" def player_profile(player_id) response = get request_url("players/#{player_id}/profile") - Sportradar::Api::Soccer::Player.new response["profile"]["player"] if response.success? && response["profile"] && response["profile"]["player"] + if response.success? && response["profile"] && response["profile"]["player"] + Sportradar::Api::Soccer::Player.new response["profile"]["player"] + else + response + end end def player_rankings response = get request_url("players/leader") - Sportradar::Api::Soccer::Ranking.new response["leaders"] if response.success? && response["leaders"] + if response.success? && response["leaders"] + Sportradar::Api::Soccer::Ranking.new response["leaders"] + else + response + end end def team_hierarchy response = get request_url("teams/hierarchy") - Sportradar::Api::Soccer::Hierarchy.new response["hierarchy"] if response.success? && response["hierarchy"] + if response.success? && response["hierarchy"] + Sportradar::Api::Soccer::Hierarchy.new response["hierarchy"] + else + response + end end def team_standings response = get request_url("teams/standing") - Sportradar::Api::Soccer::Standing.new response["standings"] if response.success? && response["standings"] + if response.success? + Sportradar::Api::Soccer::Standing.new response["standings"] + else + response + end end def simulation_match "22653ed5-0b2c-4e30-b10c-c6d51619b52b" end