sports-butler 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/lib/sports/butler/api.rb +91 -0
- data/lib/sports/butler/api_base.rb +19 -0
- data/lib/sports/butler/base.rb +137 -0
- data/lib/sports/butler/basketball.rb +26 -0
- data/lib/sports/butler/basketball_api/api_basketball_com/competitions.rb +19 -0
- data/lib/sports/butler/basketball_api/api_basketball_com/countries.rb +19 -0
- data/lib/sports/butler/basketball_api/api_basketball_com/matches.rb +13 -0
- data/lib/sports/butler/basketball_api/api_basketball_com/odds.rb +17 -0
- data/lib/sports/butler/basketball_api/api_basketball_com/seasons.rb +13 -0
- data/lib/sports/butler/basketball_api/api_basketball_com/standings.rb +12 -0
- data/lib/sports/butler/basketball_api/api_basketball_com/statistics.rb +12 -0
- data/lib/sports/butler/basketball_api/api_basketball_com/teams.rb +20 -0
- data/lib/sports/butler/basketball_api/api_basketball_com/timezones.rb +13 -0
- data/lib/sports/butler/basketball_api/base.rb +14 -0
- data/lib/sports/butler/basketball_api/competitions.rb +11 -0
- data/lib/sports/butler/basketball_api/countries.rb +14 -0
- data/lib/sports/butler/basketball_api/matches.rb +18 -0
- data/lib/sports/butler/basketball_api/odds.rb +18 -0
- data/lib/sports/butler/basketball_api/seasons.rb +18 -0
- data/lib/sports/butler/basketball_api/standings.rb +18 -0
- data/lib/sports/butler/basketball_api/statistics.rb +18 -0
- data/lib/sports/butler/basketball_api/teams.rb +18 -0
- data/lib/sports/butler/basketball_api/timezones.rb +18 -0
- data/lib/sports/butler/configuration.rb +103 -0
- data/lib/sports/butler/endpoints.rb +58 -0
- data/lib/sports/butler/shared/all_sports.rb +175 -0
- data/lib/sports/butler/shared/api_coms.rb +24 -0
- data/lib/sports/butler/soccer.rb +36 -0
- data/lib/sports/butler/soccer_api/api_football_com/coachs.rb +12 -0
- data/lib/sports/butler/soccer_api/api_football_com/competitions.rb +24 -0
- data/lib/sports/butler/soccer_api/api_football_com/countries.rb +17 -0
- data/lib/sports/butler/soccer_api/api_football_com/head_to_head.rb +23 -0
- data/lib/sports/butler/soccer_api/api_football_com/injuries.rb +12 -0
- data/lib/sports/butler/soccer_api/api_football_com/lineups.rb +19 -0
- data/lib/sports/butler/soccer_api/api_football_com/matches.rb +19 -0
- data/lib/sports/butler/soccer_api/api_football_com/odds.rb +19 -0
- data/lib/sports/butler/soccer_api/api_football_com/players.rb +21 -0
- data/lib/sports/butler/soccer_api/api_football_com/predictions.rb +12 -0
- data/lib/sports/butler/soccer_api/api_football_com/scorers.rb +19 -0
- data/lib/sports/butler/soccer_api/api_football_com/sidelineds.rb +13 -0
- data/lib/sports/butler/soccer_api/api_football_com/standings.rb +15 -0
- data/lib/sports/butler/soccer_api/api_football_com/statistics.rb +19 -0
- data/lib/sports/butler/soccer_api/api_football_com/teams.rb +19 -0
- data/lib/sports/butler/soccer_api/api_football_com/timezones.rb +13 -0
- data/lib/sports/butler/soccer_api/api_football_com/transfers.rb +14 -0
- data/lib/sports/butler/soccer_api/api_football_com/trophies.rb +12 -0
- data/lib/sports/butler/soccer_api/api_football_com/venues.rb +12 -0
- data/lib/sports/butler/soccer_api/apifootball_com/competitions.rb +25 -0
- data/lib/sports/butler/soccer_api/apifootball_com/countries.rb +25 -0
- data/lib/sports/butler/soccer_api/apifootball_com/head_to_head.rb +27 -0
- data/lib/sports/butler/soccer_api/apifootball_com/lineups.rb +19 -0
- data/lib/sports/butler/soccer_api/apifootball_com/matches.rb +39 -0
- data/lib/sports/butler/soccer_api/apifootball_com/odds.rb +24 -0
- data/lib/sports/butler/soccer_api/apifootball_com/players.rb +33 -0
- data/lib/sports/butler/soccer_api/apifootball_com/predictions.rb +19 -0
- data/lib/sports/butler/soccer_api/apifootball_com/scorers.rb +27 -0
- data/lib/sports/butler/soccer_api/apifootball_com/standings.rb +24 -0
- data/lib/sports/butler/soccer_api/apifootball_com/statistics.rb +23 -0
- data/lib/sports/butler/soccer_api/apifootball_com/teams.rb +27 -0
- data/lib/sports/butler/soccer_api/base.rb +22 -0
- data/lib/sports/butler/soccer_api/coachs.rb +18 -0
- data/lib/sports/butler/soccer_api/competitions.rb +14 -0
- data/lib/sports/butler/soccer_api/countries.rb +14 -0
- data/lib/sports/butler/soccer_api/football_data_org/base.rb +20 -0
- data/lib/sports/butler/soccer_api/football_data_org/competitions.rb +22 -0
- data/lib/sports/butler/soccer_api/football_data_org/countries.rb +43 -0
- data/lib/sports/butler/soccer_api/football_data_org/head_to_head.rb +28 -0
- data/lib/sports/butler/soccer_api/football_data_org/lineups.rb +32 -0
- data/lib/sports/butler/soccer_api/football_data_org/matches.rb +58 -0
- data/lib/sports/butler/soccer_api/football_data_org/odds.rb +26 -0
- data/lib/sports/butler/soccer_api/football_data_org/players.rb +23 -0
- data/lib/sports/butler/soccer_api/football_data_org/scorers.rb +20 -0
- data/lib/sports/butler/soccer_api/football_data_org/standings.rb +16 -0
- data/lib/sports/butler/soccer_api/football_data_org/teams.rb +19 -0
- data/lib/sports/butler/soccer_api/head_to_head.rb +14 -0
- data/lib/sports/butler/soccer_api/injuries.rb +18 -0
- data/lib/sports/butler/soccer_api/lineups.rb +18 -0
- data/lib/sports/butler/soccer_api/matches.rb +14 -0
- data/lib/sports/butler/soccer_api/odds.rb +18 -0
- data/lib/sports/butler/soccer_api/players.rb +14 -0
- data/lib/sports/butler/soccer_api/predictions.rb +18 -0
- data/lib/sports/butler/soccer_api/scorers.rb +14 -0
- data/lib/sports/butler/soccer_api/sidelineds.rb +18 -0
- data/lib/sports/butler/soccer_api/standings.rb +18 -0
- data/lib/sports/butler/soccer_api/statistics.rb +14 -0
- data/lib/sports/butler/soccer_api/teams.rb +18 -0
- data/lib/sports/butler/soccer_api/timezones.rb +18 -0
- data/lib/sports/butler/soccer_api/transfers.rb +18 -0
- data/lib/sports/butler/soccer_api/trophies.rb +18 -0
- data/lib/sports/butler/soccer_api/venues.rb +18 -0
- data/lib/sports/butler/utility.rb +96 -0
- data/lib/sports/butler/version.rb +18 -0
- data/lib/sports/butler.rb +48 -0
- metadata +195 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class Competitions < Sports::Butler::SoccerApi::Competitions
|
8
|
+
|
9
|
+
def available_endpoint_methods
|
10
|
+
[:all, :by_country]
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def build_path(action)
|
15
|
+
"action=#{action}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def path
|
19
|
+
:get_leagues
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class Countries < Sports::Butler::SoccerApi::Countries
|
8
|
+
|
9
|
+
def available_endpoint_methods
|
10
|
+
[:all]
|
11
|
+
end
|
12
|
+
|
13
|
+
def path
|
14
|
+
:get_countries
|
15
|
+
end
|
16
|
+
|
17
|
+
def build_path(action)
|
18
|
+
"action=#{action}"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class HeadToHead < Sports::Butler::SoccerApi::HeadToHead
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_teams]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:get_H2H
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_path(action)
|
17
|
+
"action=#{action}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def filters_by_teams(team_id, second_team_id)
|
21
|
+
{ firstTeamId: team_id, secondTeamId: second_team_id }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class Lineups < Sports::Butler::SoccerApi::Lineups
|
8
|
+
def path
|
9
|
+
:get_lineups
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_path(action)
|
13
|
+
"action=#{action}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class Matches < Sports::Butler::SoccerApi::Matches
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_id, :by_competition_and_year, :by_team_and_range, :by_competition_and_range]
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_path(action)
|
13
|
+
"action=#{action}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def path
|
17
|
+
:get_events
|
18
|
+
end
|
19
|
+
|
20
|
+
def by_competition_and_year(competition_id:, year:, filters: {})
|
21
|
+
from = "#{year}-01-01"
|
22
|
+
to = "#{year}-12-31"
|
23
|
+
filters.merge!({ league_id: competition_id, from: from, to: to })
|
24
|
+
api.get(path: build_path(path), filters: filters)
|
25
|
+
api
|
26
|
+
end
|
27
|
+
|
28
|
+
def filters_by_id(id)
|
29
|
+
{ match_id: id }
|
30
|
+
end
|
31
|
+
|
32
|
+
def filters_by_competition_and_range(competition_id, from, to)
|
33
|
+
{ league_id: competition_id, from: from, to: to }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class Odds < Sports::Butler::SoccerApi::Odds
|
8
|
+
def path
|
9
|
+
:get_odds
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_path(action)
|
13
|
+
"action=#{action}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def filters_by_match(id)
|
17
|
+
{ match_id: id }
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class Players < Sports::Butler::SoccerApi::Players
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_id, :by_name]
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_path(action)
|
13
|
+
"action=#{action}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def path
|
17
|
+
:get_players
|
18
|
+
end
|
19
|
+
|
20
|
+
def by_name(name: , filters: {})
|
21
|
+
filters.merge!({ player_name: name })
|
22
|
+
api.get(path: build_path(path), filters: filters)
|
23
|
+
api
|
24
|
+
end
|
25
|
+
|
26
|
+
def filters_by_id(id)
|
27
|
+
{ player_id: id }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class Predictions < Sports::Butler::SoccerApi::Predictions
|
8
|
+
def path
|
9
|
+
:get_predictions
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_path(action)
|
13
|
+
"action=#{action}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class Scorers < Sports::Butler::SoccerApi::Scorers
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_competition]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:get_topscorers
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_path(action)
|
17
|
+
"action=#{action}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def filters_by_competition(id)
|
21
|
+
{ league_id: id }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class Standings < Sports::Butler::SoccerApi::Standings
|
8
|
+
|
9
|
+
def build_path(action)
|
10
|
+
"action=#{action}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def path
|
14
|
+
:get_standings
|
15
|
+
end
|
16
|
+
|
17
|
+
def filters_by_competition(id)
|
18
|
+
{ league_id: id }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class Statistics < Sports::Butler::SoccerApi::Statistics
|
8
|
+
def path
|
9
|
+
:get_statistics
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_path(action)
|
13
|
+
"action=#{action}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def filters_by_match(id)
|
17
|
+
{ match_id: id }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module ApifootballCom
|
7
|
+
class Teams < Sports::Butler::SoccerApi::Teams
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_id]
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_path(action)
|
13
|
+
"action=#{action}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def path
|
17
|
+
:get_teams
|
18
|
+
end
|
19
|
+
|
20
|
+
def filters_by_id(id)
|
21
|
+
{ team_id: id }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "sports/butler/endpoints"
|
3
|
+
|
4
|
+
module Sports
|
5
|
+
module Butler
|
6
|
+
module SoccerApi
|
7
|
+
class Base < Sports::Butler::Endpoints
|
8
|
+
def method_missing(method, *args, &block)
|
9
|
+
return error_missing_endpoint_method(method)
|
10
|
+
end
|
11
|
+
|
12
|
+
def not_found_result(*params)
|
13
|
+
error_message("#{params.join(', ')} could not be found.")
|
14
|
+
end
|
15
|
+
|
16
|
+
def error_message(error)
|
17
|
+
{ message: error }.with_indifferent_access
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'sports/butler/soccer_api/base'
|
3
|
+
|
4
|
+
module Sports
|
5
|
+
module Butler
|
6
|
+
module SoccerApi
|
7
|
+
class Coachs < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_id, :search_by_name, :by_team]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:coachs
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module FootballDataOrg
|
7
|
+
module Base
|
8
|
+
def path_with_id(id)
|
9
|
+
"#{path}/#{id}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def api_with_id(id, filters)
|
13
|
+
api.get(path: path_with_id(id), filters: filters)
|
14
|
+
api
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module FootballDataOrg
|
7
|
+
class Competitions < Sports::Butler::SoccerApi::Competitions
|
8
|
+
require 'sports/butler/soccer_api/football_data_org/base'
|
9
|
+
include Sports::Butler::SoccerApi::FootballDataOrg::Base
|
10
|
+
|
11
|
+
def available_endpoint_methods
|
12
|
+
[:all, :by_id]
|
13
|
+
end
|
14
|
+
|
15
|
+
def by_id(id:, filters: {})
|
16
|
+
api_with_id(id, filters)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module FootballDataOrg
|
7
|
+
class Countries < Sports::Butler::SoccerApi::Countries
|
8
|
+
require 'sports/butler/soccer_api/football_data_org/base'
|
9
|
+
include Sports::Butler::SoccerApi::FootballDataOrg::Base
|
10
|
+
|
11
|
+
def available_endpoint_methods
|
12
|
+
[:all, :by_name, :by_id]
|
13
|
+
end
|
14
|
+
|
15
|
+
def path
|
16
|
+
:areas
|
17
|
+
end
|
18
|
+
|
19
|
+
def by_id(id:, filters: {})
|
20
|
+
api_with_id(id, filters)
|
21
|
+
end
|
22
|
+
|
23
|
+
def by_name(name:, _filters: {})
|
24
|
+
api = all
|
25
|
+
|
26
|
+
return api if api.parsed_response.is_a?(Hash) &&
|
27
|
+
api.parsed_response.with_indifferent_access.dig('message')
|
28
|
+
|
29
|
+
country = api.parsed_response['areas'].detect { |area| area['name'] == name }
|
30
|
+
|
31
|
+
if country
|
32
|
+
by_id(id: country['id'])
|
33
|
+
else
|
34
|
+
api.parsed_response = not_found_result(name)
|
35
|
+
api
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module FootballDataOrg
|
7
|
+
class HeadToHead < Sports::Butler::SoccerApi::HeadToHead
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_match]
|
10
|
+
end
|
11
|
+
|
12
|
+
def by_match(match_id:, filters: {})
|
13
|
+
api.get(path: "#{path}/#{match_id}", filters: filters)
|
14
|
+
response = api.response.parsed_response
|
15
|
+
|
16
|
+
if response.is_a?(Hash) && response.with_indifferent_access.dig(:head2head)
|
17
|
+
api.parsed_response = response['head2head']
|
18
|
+
else
|
19
|
+
api.parsed_response = response
|
20
|
+
end
|
21
|
+
|
22
|
+
api
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module FootballDataOrg
|
7
|
+
class Lineups < Sports::Butler::SoccerApi::Lineups
|
8
|
+
|
9
|
+
def by_match(match_id:, filters: {})
|
10
|
+
api.get(path: "#{path}/#{match_id}", filters: filters)
|
11
|
+
response = api.response.parsed_response
|
12
|
+
|
13
|
+
if response.is_a?(Hash) && response.with_indifferent_access.dig(:match) &&
|
14
|
+
response['match'].with_indifferent_access.dig(:homeTeam) &&
|
15
|
+
response['match'].with_indifferent_access.dig(:awayTeam)
|
16
|
+
|
17
|
+
lineups = {}
|
18
|
+
lineups['homeTeam'] = response['match']['homeTeam']
|
19
|
+
lineups['awayTeam'] = response['match']['awayTeam']
|
20
|
+
|
21
|
+
api.parsed_response = lineups
|
22
|
+
else
|
23
|
+
api.parsed_response = response
|
24
|
+
end
|
25
|
+
|
26
|
+
api
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module FootballDataOrg
|
7
|
+
class Matches < Sports::Butler::SoccerApi::Matches
|
8
|
+
require 'sports/butler/soccer_api/football_data_org/base'
|
9
|
+
include Sports::Butler::SoccerApi::FootballDataOrg::Base
|
10
|
+
|
11
|
+
STATUS_FINISHED = 'FINISHED'
|
12
|
+
STATUS_SCHEDULED = 'SCHEDULED'
|
13
|
+
|
14
|
+
def available_endpoint_methods
|
15
|
+
[
|
16
|
+
:by_id, :all, :by_competition, :by_competition_and_year, :by_team, :by_team_and_status,
|
17
|
+
:by_team_finished, :by_team_scheduled
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
def by_id(id:, filters: {})
|
22
|
+
api_with_id(id, filters)
|
23
|
+
end
|
24
|
+
|
25
|
+
def by_competition(competition_id:, filters: {})
|
26
|
+
api.get(path: "competitions/#{competition_id}/#{path}", filters: filters)
|
27
|
+
api
|
28
|
+
end
|
29
|
+
|
30
|
+
def by_competition_and_year(competition_id:, year:, filters: {})
|
31
|
+
filters.merge!({ season: year })
|
32
|
+
api.get(path: "competitions/#{competition_id}/#{path}", filters: filters)
|
33
|
+
api
|
34
|
+
end
|
35
|
+
|
36
|
+
def by_team(team_id:, filters: {})
|
37
|
+
api.get(path: "teams/#{team_id}/#{path}", filters: filters)
|
38
|
+
api
|
39
|
+
end
|
40
|
+
|
41
|
+
def by_team_and_status(team_id:, status:, filters: {})
|
42
|
+
filters.merge!({ status: status })
|
43
|
+
api.get(path: "teams/#{team_id}/#{path}", filters: filters)
|
44
|
+
api
|
45
|
+
end
|
46
|
+
|
47
|
+
def by_team_finished(team_id:, filters: {})
|
48
|
+
by_team_and_status(team_id: team_id, status: STATUS_FINISHED, filters: filters)
|
49
|
+
end
|
50
|
+
|
51
|
+
def by_team_scheduled(team_id:, filters: {})
|
52
|
+
by_team_and_status(team_id: team_id, status: STATUS_SCHEDULED, filters: filters)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module FootballDataOrg
|
7
|
+
class Odds < Sports::Butler::SoccerApi::Odds
|
8
|
+
def by_match(match_id:, filters: {})
|
9
|
+
api.get(path: "#{path}/#{match_id}", filters: filters)
|
10
|
+
response = api.response.parsed_response
|
11
|
+
|
12
|
+
if response.is_a?(Hash) && response.with_indifferent_access.dig(:match) &&
|
13
|
+
response['match'].with_indifferent_access.dig(:odds)
|
14
|
+
api.parsed_response = response['match']['odds']
|
15
|
+
else
|
16
|
+
api.parsed_response = response
|
17
|
+
end
|
18
|
+
|
19
|
+
api
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|