Class: XmlSoccer
- Inherits:
-
Object
- Object
- XmlSoccer
- Defined in:
- lib/xml_soccer.rb,
lib/xml_soccer/version.rb
Constant Summary collapse
- DEMO =
"Demo"
- FULL =
"Full"
- DEMO_URL =
"http://www.xmlsoccer.com/FootballDataDemo.asmx?WSDL"
- FULL_URL =
"http://www.xmlsoccer.com/FootballData.asmx?WSDL"
- VERSION =
"0.0.6"
Instance Method Summary collapse
- #check_api_key ⇒ Object
- #earliest_match_date_by_league(league: nil) ⇒ Object
- #fixture(fixture_id: nil) ⇒ Object
- #fixtures_by_date(start_date: nil, end_date: nil) ⇒ Object
- #fixtures_by_date_and_league(league: nil, start_date: nil, end_date: nil) ⇒ Object
- #fixtures_by_date_and_team(team: nil, start_date: nil, end_date: nil) ⇒ Object
- #fixtures_by_league_and_season(league: nil, season: nil) ⇒ Object
- #historic_match(match_id: nil) ⇒ Object
- #historic_match_by_fixture(fixture_id: nil) ⇒ Object
- #historic_matches_by_league_and_date(league: nil, start_date: nil, end_date: nil) ⇒ Object
- #historic_matches_by_league_and_season(league: nil, season: nil) ⇒ Object
- #historic_matches_by_team_and_date(team: nil, start_date: nil, end_date: nil) ⇒ Object
- #historic_matches_by_teams_and_date(team_1: nil, team_2: nil, start_date: nil, end_date: nil) ⇒ Object
-
#initialize(options = {}) ⇒ XmlSoccer
constructor
A new instance of XmlSoccer.
- #league_standings_by_season(league: nil, season: nil) ⇒ Object
- #leagues ⇒ Object
- #live_scores ⇒ Object
- #live_scores_by_league(league: nil) ⇒ Object
- #odds_by_fixture(fixture_id: nil) ⇒ Object
- #player(player_id: nil) ⇒ Object
- #players_by_team(team_id: nil) ⇒ Object
- #team(team: nil) ⇒ Object
- #teams ⇒ Object
- #teams_in_league_by_season(league: nil, season: nil) ⇒ Object
- #top_scorers_by_league_and_season(league: nil, season: nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ XmlSoccer
Returns a new instance of XmlSoccer.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/xml_soccer.rb', line 15 def initialize(={}) @api_key = [:api_key] case .fetch(:api_type, XmlSoccer::DEMO) when DEMO then base_url = DEMO_URL when FULL then base_url = FULL_URL end @client = Savon.client(wsdl: base_url) end |
Instance Method Details
#check_api_key ⇒ Object
161 162 163 164 |
# File 'lib/xml_soccer.rb', line 161 def check_api_key response = client.call(:check_api_key, message: {"ApiKey" => api_key}) [{ string: response.body[:check_api_key_response][:check_api_key_result] }] end |
#earliest_match_date_by_league(league: nil) ⇒ Object
121 122 123 124 125 |
# File 'lib/xml_soccer.rb', line 121 def earliest_match_date_by_league(league: nil) call_api(method: "get_earliest_match_date_per_league", message: {"league" => league}, key: :league_information) end |
#fixture(fixture_id: nil) ⇒ Object
44 45 46 47 |
# File 'lib/xml_soccer.rb', line 44 def fixture(fixture_id: nil) call_api(method: "get_fixture_match_by_id", message: { "Id" => fixture_id }, key: :match) end |
#fixtures_by_date(start_date: nil, end_date: nil) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/xml_soccer.rb', line 49 def fixtures_by_date(start_date: nil, end_date: nil) call_api(method: "get_fixtures_by_date_interval", message: {"startDateString" => start_date.strftime("%Y-%m-%d"), "endDateString" => end_date.strftime("%Y-%m-%d")}, key: :match) end |
#fixtures_by_date_and_league(league: nil, start_date: nil, end_date: nil) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/xml_soccer.rb', line 56 def fixtures_by_date_and_league(league: nil, start_date: nil, end_date: nil) call_api(method: "get_fixtures_by_date_interval_and_league", message: {"league" => league, "startDateString" => start_date.strftime("%Y-%m-%d"), "endDateString" => end_date.strftime("%Y-%m-%d")}, key: :match) end |
#fixtures_by_date_and_team(team: nil, start_date: nil, end_date: nil) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/xml_soccer.rb', line 64 def fixtures_by_date_and_team(team: nil, start_date: nil, end_date: nil) call_api(method: "get_fixtures_by_date_interval_and_team", message: {"teamId" => team, "startDateString" => start_date.strftime("%Y-%m-%d"), "endDateString" => end_date.strftime("%Y-%m-%d")}, key: :match) end |
#fixtures_by_league_and_season(league: nil, season: nil) ⇒ Object
72 73 74 75 76 |
# File 'lib/xml_soccer.rb', line 72 def fixtures_by_league_and_season(league: nil, season: nil) call_api(method: "get_fixtures_by_league_and_season", message: {"league" => league, "seasonDateString" => season}, key: :match) end |
#historic_match(match_id: nil) ⇒ Object
84 85 86 87 88 |
# File 'lib/xml_soccer.rb', line 84 def historic_match(match_id: nil) call_api(method: "get_historic_matches_by_id", message: {"Id" => match_id}, key: :match) end |
#historic_match_by_fixture(fixture_id: nil) ⇒ Object
78 79 80 81 82 |
# File 'lib/xml_soccer.rb', line 78 def historic_match_by_fixture(fixture_id: nil) call_api(method: "get_historic_matches_by_fixture_match_id", message: {"Id" => fixture_id}, key: :match) end |
#historic_matches_by_league_and_date(league: nil, start_date: nil, end_date: nil) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/xml_soccer.rb', line 90 def historic_matches_by_league_and_date(league: nil, start_date: nil, end_date: nil) call_api(method: "get_historic_matches_by_league_and_date_interval", message: {"league" => league, "startDateString" => start_date.strftime("%Y-%m-%d"), "endDateString" => end_date.strftime("%Y-%m-%d")}, key: :match) end |
#historic_matches_by_league_and_season(league: nil, season: nil) ⇒ Object
98 99 100 101 102 |
# File 'lib/xml_soccer.rb', line 98 def historic_matches_by_league_and_season(league: nil, season: nil) call_api(method: "get_historic_matches_by_league_and_season", message: {"league" => league, "seasonDateString" => season}, key: :match) end |
#historic_matches_by_team_and_date(team: nil, start_date: nil, end_date: nil) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/xml_soccer.rb', line 104 def historic_matches_by_team_and_date(team: nil, start_date: nil, end_date: nil) call_api(method: "get_historic_matches_by_team_and_date_interval", message: {"teamId" => team, "startDateString" => start_date.strftime("%Y-%m-%d"), "endDateString" => end_date.strftime("%Y-%m-%d")}, key: :match) end |
#historic_matches_by_teams_and_date(team_1: nil, team_2: nil, start_date: nil, end_date: nil) ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/xml_soccer.rb', line 112 def historic_matches_by_teams_and_date(team_1: nil, team_2: nil, start_date: nil, end_date: nil) call_api(method: "get_historic_matches_by_teams_and_date_interval", message: {"team1Id" => team_1, "team2Id" => team_2, "startDateString" => start_date.strftime("%Y-%m-%d"), "endDateString" => end_date.strftime("%Y-%m-%d")}, key: :match) end |
#league_standings_by_season(league: nil, season: nil) ⇒ Object
127 128 129 130 131 |
# File 'lib/xml_soccer.rb', line 127 def league_standings_by_season(league: nil, season: nil) call_api(method: "get_league_standings_by_season", message: {"league" => league, "seasonDateString" => season}, key: :team_league_standing) end |
#leagues ⇒ Object
26 27 28 |
# File 'lib/xml_soccer.rb', line 26 def leagues call_api(method: "get_all_leagues", key: :league) end |
#live_scores ⇒ Object
133 134 135 |
# File 'lib/xml_soccer.rb', line 133 def live_scores call_api(method: "get_live_score", key: :match) end |
#live_scores_by_league(league: nil) ⇒ Object
137 138 139 |
# File 'lib/xml_soccer.rb', line 137 def live_scores_by_league(league: nil) call_api(method: "get_live_score_by_league", message: {"league" => league}, key: :match) end |
#odds_by_fixture(fixture_id: nil) ⇒ Object
155 156 157 158 159 |
# File 'lib/xml_soccer.rb', line 155 def odds_by_fixture(fixture_id: nil) call_api(method: "get_odds_by_fixture_match_id", message: {"fixtureMatch_Id" => fixture_id}, key: :odds) end |
#player(player_id: nil) ⇒ Object
151 152 153 |
# File 'lib/xml_soccer.rb', line 151 def player(player_id: nil) call_api(method: "get_player_by_id", message: {"playerId" => player_id}, key: :player) end |
#players_by_team(team_id: nil) ⇒ Object
147 148 149 |
# File 'lib/xml_soccer.rb', line 147 def players_by_team(team_id: nil) call_api(method: "get_players_by_team", message: {"teamId" => team_id}, key: :player) end |
#team(team: nil) ⇒ Object
40 41 42 |
# File 'lib/xml_soccer.rb', line 40 def team(team: nil) call_api(method: "get_team", message: {"team" => team}, key: :team) end |
#teams ⇒ Object
30 31 32 |
# File 'lib/xml_soccer.rb', line 30 def teams call_api(method: "get_all_teams", key: :team) end |
#teams_in_league_by_season(league: nil, season: nil) ⇒ Object
34 35 36 37 38 |
# File 'lib/xml_soccer.rb', line 34 def teams_in_league_by_season(league: nil, season: nil) call_api(method: "get_all_teams_by_league_and_season", message: {"league" => league, "seasonDateString" => season}, key: :team) end |
#top_scorers_by_league_and_season(league: nil, season: nil) ⇒ Object
141 142 143 144 145 |
# File 'lib/xml_soccer.rb', line 141 def top_scorers_by_league_and_season(league: nil, season: nil) call_api(method: "get_top_scorers_by_league_and_season", message: {"league" => league, "seasonDateString" => season}, key: :topscorer) end |