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,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
class Configuration
|
6
|
+
# Sports
|
7
|
+
AVAILABLE_SPORTS = [:soccer, :basketball]
|
8
|
+
|
9
|
+
# APIs
|
10
|
+
AVAILABLE_APIS = [
|
11
|
+
# Soccer
|
12
|
+
:football_data_org, :apifootball_com, :api_football_com,
|
13
|
+
# Basketball
|
14
|
+
:api_basketball_com
|
15
|
+
]
|
16
|
+
|
17
|
+
AVAILABLE_SPORT_API = {
|
18
|
+
soccer: [:football_data_org, :apifootball_com, :api_football_com],
|
19
|
+
basketball: [:api_basketball_com]
|
20
|
+
}
|
21
|
+
|
22
|
+
class << self
|
23
|
+
|
24
|
+
attr_accessor :api_token, :api_base_url,
|
25
|
+
:header_token_name, :header_additional
|
26
|
+
|
27
|
+
def configure
|
28
|
+
raise "You need to configure sports-butler first, see readme." unless block_given?
|
29
|
+
|
30
|
+
yield self
|
31
|
+
|
32
|
+
@api_token ||= default_api_hash
|
33
|
+
@api_base_url ||= default_api_hash
|
34
|
+
|
35
|
+
@header_token_name ||= set_header_token_name
|
36
|
+
@header_additional ||= {}
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_api_hash
|
41
|
+
{ soccer: {}, basketball: {} }
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_header_token_name
|
45
|
+
{
|
46
|
+
soccer: {
|
47
|
+
football_data_org: 'X-Auth-Token',
|
48
|
+
api_football_com: 'x-apisports-key'
|
49
|
+
},
|
50
|
+
basketball: {
|
51
|
+
api_basketball_com: 'x-apisports-key'
|
52
|
+
}
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def invalid_config?(sport, api_name)
|
57
|
+
Configuration.api_token[sport][api_name].blank? ||
|
58
|
+
!Configuration.valid_sport_api?(sport, api_name)
|
59
|
+
end
|
60
|
+
|
61
|
+
def http_party_url(path, sport, api_name)
|
62
|
+
case api_name
|
63
|
+
when :apifootball_com
|
64
|
+
"#{Configuration.api_base_url[sport][api_name]}?#{path}&APIkey=#{Configuration.api_token[sport][api_name]}"
|
65
|
+
else
|
66
|
+
"#{Configuration.api_base_url[sport][api_name]}/#{path}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def http_party_url_suffix(url, sport, api_name)
|
71
|
+
case api_name
|
72
|
+
when :apifootball_com
|
73
|
+
"#{url}&APIkey=#{Configuration.api_token[sport][api_name]}"
|
74
|
+
else
|
75
|
+
"#{url}"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def http_party_headers(sport, api_name)
|
80
|
+
result = case api_name
|
81
|
+
|
82
|
+
# SOCCER
|
83
|
+
when :apifootball_com
|
84
|
+
{}
|
85
|
+
when :football_data_org, :api_football_com
|
86
|
+
{ Configuration.header_token_name[sport][api_name] => Configuration.api_token[sport][api_name] }
|
87
|
+
|
88
|
+
# BASKETBALL
|
89
|
+
when :api_basketball_com
|
90
|
+
{ Configuration.header_token_name[sport][api_name] => Configuration.api_token[sport][api_name] }
|
91
|
+
end
|
92
|
+
|
93
|
+
result.merge!(Configuration.header_additional)
|
94
|
+
result
|
95
|
+
end
|
96
|
+
|
97
|
+
def valid_sport_api?(sport, api_name)
|
98
|
+
AVAILABLE_SPORT_API[sport]&.any?{|name| name == api_name}
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Sports
|
3
|
+
module Butler
|
4
|
+
class Endpoints
|
5
|
+
require 'sports/butler/shared/all_sports'
|
6
|
+
require 'sports/butler/shared/api_coms'
|
7
|
+
|
8
|
+
include Sports::Butler::Shared::AllSports
|
9
|
+
include Sports::Butler::Shared::ApiComs
|
10
|
+
|
11
|
+
attr_accessor :sport, :api_name, :api
|
12
|
+
|
13
|
+
def initialize(sport:, api_name:, api:)
|
14
|
+
@sport = sport
|
15
|
+
@api_name = api_name
|
16
|
+
@api = api
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_path(_action)
|
20
|
+
path
|
21
|
+
end
|
22
|
+
|
23
|
+
def error_missing_endpoint_method(meth)
|
24
|
+
"The method '#{meth}' is not available for endpoint '#{self.class.name.demodulize}' in API #{self.api_name}."
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# param names
|
29
|
+
def filters_by_match(id)
|
30
|
+
{ id: id }
|
31
|
+
end
|
32
|
+
|
33
|
+
def filters_by_team(team_id)
|
34
|
+
{ team: team_id }
|
35
|
+
end
|
36
|
+
|
37
|
+
def filters_by_id(id)
|
38
|
+
{ id: id }
|
39
|
+
end
|
40
|
+
|
41
|
+
def filters_by_player(id)
|
42
|
+
{ player: id }
|
43
|
+
end
|
44
|
+
|
45
|
+
def filters_by_competition(id)
|
46
|
+
{ competition_id: id }
|
47
|
+
end
|
48
|
+
|
49
|
+
def filters_by_competition_and_year(id, year)
|
50
|
+
{ league: id, season: year }
|
51
|
+
end
|
52
|
+
|
53
|
+
def filters_search_by_name(name)
|
54
|
+
{ name: name }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
module Sports
|
2
|
+
module Butler
|
3
|
+
module Shared
|
4
|
+
module AllSports
|
5
|
+
|
6
|
+
def all(filters: {})
|
7
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
8
|
+
|
9
|
+
api.get(path: build_path(path), filters: filters)
|
10
|
+
api
|
11
|
+
end
|
12
|
+
|
13
|
+
def by_name(name: , filters: {})
|
14
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
15
|
+
|
16
|
+
filters.merge!({ name: name })
|
17
|
+
api.get(path: build_path(path), filters: filters)
|
18
|
+
api
|
19
|
+
end
|
20
|
+
|
21
|
+
def by_country_name(country_name: , filters: {})
|
22
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
23
|
+
|
24
|
+
filters.merge!({ country: country_name })
|
25
|
+
api.get(path: build_path(path), filters: filters)
|
26
|
+
api
|
27
|
+
end
|
28
|
+
|
29
|
+
def by_id(id: , filters: {})
|
30
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
31
|
+
|
32
|
+
filters.merge!(filters_by_id(id))
|
33
|
+
api.get(path: build_path(path), filters: filters)
|
34
|
+
api
|
35
|
+
end
|
36
|
+
|
37
|
+
def by_match(match_id: , filters: {})
|
38
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
39
|
+
|
40
|
+
filters.merge!(filters_by_match(match_id))
|
41
|
+
api.get(path: build_path(path), filters: filters)
|
42
|
+
api
|
43
|
+
end
|
44
|
+
|
45
|
+
def by_country(country_id: , filters: {})
|
46
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
47
|
+
|
48
|
+
filters.merge!({ country_id: country_id })
|
49
|
+
api.get(path: build_path(path), filters: filters)
|
50
|
+
api
|
51
|
+
end
|
52
|
+
|
53
|
+
def by_competition(competition_id:, filters: {})
|
54
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
55
|
+
|
56
|
+
filters.merge!(filters_by_competition(competition_id))
|
57
|
+
api.get(path: build_path(path), filters: filters)
|
58
|
+
api
|
59
|
+
end
|
60
|
+
|
61
|
+
def search_by_name(name:, filters: {})
|
62
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
63
|
+
|
64
|
+
filters.merge!(filters_search_by_name(name))
|
65
|
+
api.get(path: build_path(path), filters: filters)
|
66
|
+
api
|
67
|
+
end
|
68
|
+
|
69
|
+
def by_player(player_id:, filters: {})
|
70
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
71
|
+
|
72
|
+
filters.merge!(filters_by_player(player_id))
|
73
|
+
api.get(path: build_path(path), filters: filters)
|
74
|
+
api
|
75
|
+
end
|
76
|
+
|
77
|
+
def by_team(team_id:, filters: {})
|
78
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
79
|
+
|
80
|
+
filters.merge!(filters_by_team(team_id))
|
81
|
+
api.get(path: build_path(path), filters: filters)
|
82
|
+
api
|
83
|
+
end
|
84
|
+
|
85
|
+
def by_coach(coach_id:, filters: {})
|
86
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
87
|
+
|
88
|
+
filters.merge!({ coach: coach_id })
|
89
|
+
api.get(path: build_path(path), filters: filters)
|
90
|
+
api
|
91
|
+
end
|
92
|
+
|
93
|
+
def by_id_and_season(id:, season:, filters: {})
|
94
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
95
|
+
|
96
|
+
filters.merge!({ id: id, season: season })
|
97
|
+
api.get(path: build_path(path), filters: filters)
|
98
|
+
api
|
99
|
+
end
|
100
|
+
|
101
|
+
def by_competition_and_year(competition_id:, year:, filters: {})
|
102
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
103
|
+
|
104
|
+
filters.merge!(filters_by_competition_and_year(competition_id, year))
|
105
|
+
api.get(path: build_path(path), filters: filters)
|
106
|
+
api
|
107
|
+
end
|
108
|
+
|
109
|
+
def by_teams(team_id:, second_team_id:, filters: {})
|
110
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
111
|
+
|
112
|
+
filters.merge!(filters_by_teams(team_id, second_team_id))
|
113
|
+
api.get(path: build_path(path), filters: filters)
|
114
|
+
api
|
115
|
+
end
|
116
|
+
|
117
|
+
def by_competition_and_season(competition_id:, season:, filters: {})
|
118
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
119
|
+
|
120
|
+
filters.merge!({ league: competition_id, season: season })
|
121
|
+
api.get(path: build_path(path), filters: filters)
|
122
|
+
api
|
123
|
+
end
|
124
|
+
|
125
|
+
def by_team_and_season(team_id:, season:, filters: {})
|
126
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
127
|
+
|
128
|
+
filters.merge!({ team: team_id, season: season })
|
129
|
+
api.get(path: build_path(path), filters: filters)
|
130
|
+
api
|
131
|
+
end
|
132
|
+
|
133
|
+
def by_team_and_range(team_id:, from:, to:, filters: {})
|
134
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
135
|
+
|
136
|
+
filters.merge!({ team_id: team_id, from: from, to: to })
|
137
|
+
api.get(path: build_path(path), filters: filters)
|
138
|
+
api
|
139
|
+
end
|
140
|
+
|
141
|
+
def by_competition_and_range(competition_id:, from:, to:, filters: {})
|
142
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
143
|
+
|
144
|
+
filters.merge!(filters_by_competition_and_range(competition_id, from, to))
|
145
|
+
api.get(path: build_path(path), filters: filters)
|
146
|
+
api
|
147
|
+
end
|
148
|
+
|
149
|
+
def by_season(season:, filters: {})
|
150
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
151
|
+
|
152
|
+
filters.merge!({ season: season })
|
153
|
+
api.get(path: build_path(path), filters: filters)
|
154
|
+
api
|
155
|
+
end
|
156
|
+
|
157
|
+
def by_code(code: , filters: {})
|
158
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
159
|
+
|
160
|
+
filters.merge!({ code: code })
|
161
|
+
api.get(path: build_path(path), filters: filters)
|
162
|
+
api
|
163
|
+
end
|
164
|
+
|
165
|
+
def by_competition_and_team_and_season(competition_id:, team_id:, season: , filters: {})
|
166
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
167
|
+
|
168
|
+
filters.merge!({ league: competition_id, team: team_id, season: season })
|
169
|
+
api.get(path: build_path(path), filters: filters)
|
170
|
+
api
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Sports
|
2
|
+
module Butler
|
3
|
+
module Shared
|
4
|
+
module ApiComs
|
5
|
+
|
6
|
+
def leagues(filters: {})
|
7
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
8
|
+
|
9
|
+
filters.merge!({ type: 'league' })
|
10
|
+
api.get(path: build_path(path), filters: filters)
|
11
|
+
api
|
12
|
+
end
|
13
|
+
|
14
|
+
def cups(filters: {})
|
15
|
+
return error_missing_endpoint_method(__method__) unless available_endpoint_methods.include?(__method__)
|
16
|
+
|
17
|
+
filters.merge!({ type: 'cup' })
|
18
|
+
api.get(path: build_path(path), filters: filters)
|
19
|
+
api
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'sports/butler/base'
|
3
|
+
|
4
|
+
module Sports
|
5
|
+
module Butler
|
6
|
+
class Soccer < Sports::Butler::Base
|
7
|
+
|
8
|
+
ENDPOINTS = [
|
9
|
+
:countries,
|
10
|
+
:competitions,
|
11
|
+
:matches,
|
12
|
+
:teams,
|
13
|
+
:players,
|
14
|
+
:head_to_head,
|
15
|
+
:lineups,
|
16
|
+
:odds,
|
17
|
+
:scorers,
|
18
|
+
:standings,
|
19
|
+
:coachs,
|
20
|
+
:injuries,
|
21
|
+
:predictions,
|
22
|
+
:sidelineds,
|
23
|
+
:statistics,
|
24
|
+
:timezones,
|
25
|
+
:transfers,
|
26
|
+
:trophies,
|
27
|
+
:venues
|
28
|
+
]
|
29
|
+
|
30
|
+
def initialize(sport:, api_name:)
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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 Competitions < Sports::Butler::SoccerApi::Competitions
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:all, :by_id, :search_by_name, :by_country_name, :seasons, :leagues, :cups]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:leagues
|
14
|
+
end
|
15
|
+
|
16
|
+
def seasons(filters: {})
|
17
|
+
api.get(path: "#{path}/seasons", filters: filters)
|
18
|
+
api
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
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, :by_name, :search_by_name]
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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 HeadToHead < Sports::Butler::SoccerApi::HeadToHead
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_teams]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
'fixtures/headtohead'
|
14
|
+
end
|
15
|
+
|
16
|
+
def filters_by_teams(team_id, second_team_id)
|
17
|
+
{ h2h: "#{team_id}-#{second_team_id}" }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
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
|
+
'fixtures/lineups'
|
10
|
+
end
|
11
|
+
|
12
|
+
def filters_by_match(id)
|
13
|
+
{ fixture: id }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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 Matches < Sports::Butler::SoccerApi::Matches
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_id, :by_competition_and_year, :all]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:fixtures
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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 Odds < Sports::Butler::SoccerApi::Odds
|
8
|
+
def path
|
9
|
+
:odds
|
10
|
+
end
|
11
|
+
|
12
|
+
def filters_by_match(id)
|
13
|
+
{ fixture: id }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
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
|
+
|
9
|
+
def available_endpoint_methods
|
10
|
+
[:by_id_and_season]
|
11
|
+
end
|
12
|
+
|
13
|
+
def path
|
14
|
+
:players
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
1
|
@@ -0,0 +1,19 @@
|
|
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_and_year]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
'players/topscorers'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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 Statistics < Sports::Butler::SoccerApi::Statistics
|
8
|
+
def path
|
9
|
+
'fixtures/statistics'
|
10
|
+
end
|
11
|
+
|
12
|
+
def filters_by_match(id)
|
13
|
+
{ fixture: id }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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 Teams < Sports::Butler::SoccerApi::Teams
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_id, :by_name]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:teams
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|