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,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module FootballDataOrg
|
7
|
+
class Players < Sports::Butler::SoccerApi::Players
|
8
|
+
require 'sports/butler/soccer_api/football_data_org/base'
|
9
|
+
include Sports::Butler::SoccerApi::FootballDataOrg::Base
|
10
|
+
|
11
|
+
def available_endpoint_methods
|
12
|
+
[:by_id]
|
13
|
+
end
|
14
|
+
|
15
|
+
def by_id(id:, filters: {})
|
16
|
+
api_with_id(id, filters)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module FootballDataOrg
|
7
|
+
class Scorers < Sports::Butler::SoccerApi::Scorers
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_competition]
|
10
|
+
end
|
11
|
+
|
12
|
+
def by_competition(competition_id:, filters: {})
|
13
|
+
api.get(path: "competitions/#{competition_id}/#{path}", filters: filters)
|
14
|
+
api
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module FootballDataOrg
|
7
|
+
class Standings < Sports::Butler::SoccerApi::Standings
|
8
|
+
def by_competition(competition_id:, filters: {})
|
9
|
+
api.get(path: "competitions/#{competition_id}/#{path}", filters: filters)
|
10
|
+
api
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sports
|
4
|
+
module Butler
|
5
|
+
module SoccerApi
|
6
|
+
module FootballDataOrg
|
7
|
+
class Teams < Sports::Butler::SoccerApi::Teams
|
8
|
+
require 'sports/butler/soccer_api/football_data_org/base'
|
9
|
+
include Sports::Butler::SoccerApi::FootballDataOrg::Base
|
10
|
+
|
11
|
+
def by_id(id:, filters: {})
|
12
|
+
api_with_id(id, filters)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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 Injuries < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_competition_and_season, :by_match, :by_team_and_season]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:injuries
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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 Lineups < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_match]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:matches
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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 Odds < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_match]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:matches
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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 Predictions < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_match]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:predictions
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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 Sidelineds < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_player, :by_coach]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:sidelined
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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 Standings < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_competition]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:standings
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'sports/butler/soccer_api/base'
|
3
|
+
|
4
|
+
module Sports
|
5
|
+
module Butler
|
6
|
+
module SoccerApi
|
7
|
+
class Statistics < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_match]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
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 Teams < Sports::Butler::SoccerApi::Base
|
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
|
@@ -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 Timezones < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:all]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:timezone
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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 Transfers < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_player, :by_team]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:transfers
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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 Trophies < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_player, :by_coach]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:trophies
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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 Venues < Sports::Butler::SoccerApi::Base
|
8
|
+
def available_endpoint_methods
|
9
|
+
[:by_id]
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
:venues
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# requires / includes
|
3
|
+
require 'terminal-table'
|
4
|
+
require 'term/ansicolor'
|
5
|
+
include Term::ANSIColor
|
6
|
+
|
7
|
+
module Sports
|
8
|
+
module Butler
|
9
|
+
class Utility
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def endpoints
|
13
|
+
linebreak
|
14
|
+
|
15
|
+
Configuration::AVAILABLE_SPORT_API.each.with_index(1) do |(sport, api_names), idx|
|
16
|
+
|
17
|
+
print white, "#{idx}. SPORT: #{sport}\n"
|
18
|
+
puts "==============================\n"
|
19
|
+
puts "Endpoints for this Sport:\n\n"
|
20
|
+
|
21
|
+
all_endpoints = "Sports::Butler::#{sport.to_s.capitalize}::ENDPOINTS".constantize
|
22
|
+
all_endpoints.sort.each.with_index(1) do |endpoint, idx_endpoint|
|
23
|
+
row_hash = {}
|
24
|
+
row_hash[:available_endpoint_methods] = []
|
25
|
+
rows_apis = []
|
26
|
+
|
27
|
+
aliases = Sports::Butler::Base::ALIASES.map{ |key, value| key if value == endpoint }.compact
|
28
|
+
print white, "#{idx_endpoint}. #{endpoint} [ Aliases: #{aliases.present? ? aliases.join(', ') : '-'} ]\n"
|
29
|
+
|
30
|
+
# get all methods from all apis
|
31
|
+
api_names.each.with_index(1) do |api_name, _idx_api_name|
|
32
|
+
butler = Sports::Butler.new(sport: sport, api_name: api_name)
|
33
|
+
|
34
|
+
next unless butler.available_endpoints.include?(endpoint.to_s)
|
35
|
+
available_endpoint_methods = butler.send(endpoint).available_endpoint_methods
|
36
|
+
|
37
|
+
row_hash[:available_endpoint_methods] += available_endpoint_methods
|
38
|
+
row_hash[:available_endpoint_methods].uniq!
|
39
|
+
|
40
|
+
rows_apis << api_name
|
41
|
+
end
|
42
|
+
|
43
|
+
rows_meths = []
|
44
|
+
row_hash[:available_endpoint_methods].each.with_index(1) do |available_endpoint_method, idx_available|
|
45
|
+
yes_no = []
|
46
|
+
meth_params = []
|
47
|
+
api_names.each.with_index(1) do |api_name, _idx_api_name|
|
48
|
+
butler = Sports::Butler.new(sport: sport, api_name: api_name)
|
49
|
+
|
50
|
+
next unless butler.available_endpoints.include?(endpoint.to_s)
|
51
|
+
available_endpoint_methods = butler.send(endpoint).available_endpoint_methods
|
52
|
+
|
53
|
+
res = available_endpoint_methods.include?(available_endpoint_method) ? 'YES' : '-'
|
54
|
+
yes_no << res
|
55
|
+
|
56
|
+
if available_endpoint_methods.include?(available_endpoint_method)
|
57
|
+
params = butler.send(endpoint).method(available_endpoint_method).parameters
|
58
|
+
|
59
|
+
res = params.present? ? params : 'none'
|
60
|
+
meth_params << res
|
61
|
+
else
|
62
|
+
meth_params << '-'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
rows_meths << [available_endpoint_method] + yes_no
|
67
|
+
rows_meths << [''] + meth_params
|
68
|
+
rows_meths << :separator unless idx_available == row_hash[:available_endpoint_methods].size
|
69
|
+
end
|
70
|
+
|
71
|
+
table = Terminal::Table.new rows: rows_meths
|
72
|
+
table.title = "Endpoint #{endpoint} [#{sport}]"
|
73
|
+
table.headings = ['Method'] + rows_apis
|
74
|
+
|
75
|
+
print magenta, table
|
76
|
+
|
77
|
+
linebreak
|
78
|
+
linebreak
|
79
|
+
end
|
80
|
+
linebreak
|
81
|
+
end
|
82
|
+
linebreak
|
83
|
+
|
84
|
+
true
|
85
|
+
end
|
86
|
+
|
87
|
+
# output
|
88
|
+
def linebreak
|
89
|
+
puts "\n"
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Sports
|
3
|
+
module Butler
|
4
|
+
# Initial Release Version:
|
5
|
+
# November 2021
|
6
|
+
#
|
7
|
+
# Supported Sports:
|
8
|
+
# - Football (aka Soccer)
|
9
|
+
# - Basketball
|
10
|
+
#
|
11
|
+
# Supported APIs:
|
12
|
+
# - https://api-football.com (>= 1.0.0)
|
13
|
+
# - https://apifootball.com (>= 1.0.0)
|
14
|
+
# - https://www.football-data.org (>= 1.0.0)
|
15
|
+
# - https://api-basketball.com (>= 1.0.0)
|
16
|
+
VERSION = "1.0.0"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
require "sports/butler/utility"
|
5
|
+
require 'sports/butler/api'
|
6
|
+
require "sports/butler/version"
|
7
|
+
require "sports/butler/configuration"
|
8
|
+
require "sports/butler/soccer"
|
9
|
+
require "sports/butler/basketball"
|
10
|
+
|
11
|
+
module Sports
|
12
|
+
module Butler
|
13
|
+
|
14
|
+
DEFAULT_SPORT = :soccer
|
15
|
+
DEFAULT_API = :api_football_com
|
16
|
+
|
17
|
+
class << self
|
18
|
+
|
19
|
+
# Sports::Butler Object build
|
20
|
+
def new(sport: DEFAULT_SPORT, api_name: DEFAULT_API)
|
21
|
+
if Sports::Butler::Configuration.valid_sport_api?(sport, api_name)
|
22
|
+
"Sports::Butler::#{sport.to_s.capitalize}".constantize.new(sport: sport, api_name: api_name)
|
23
|
+
else
|
24
|
+
text_error_sport_api
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Sports::Butler direct API call without Endpoint Classes
|
29
|
+
def get(url:, sport: nil, api_name: nil, filters: {}, headers: {})
|
30
|
+
Api.get(url: url, sport: sport, api_name: api_name, filters: filters, headers: headers)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Sports::Butler show all endpoints in console output (info)
|
34
|
+
def show_endpoints
|
35
|
+
Sports::Butler::Utility.endpoints
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def text_error_sport_api
|
41
|
+
text = "Invalid sport / api parameter. "
|
42
|
+
text += "Available sports: #{Sports::Butler::Configuration::AVAILABLE_SPORTS.join(', ')}. "
|
43
|
+
text += "Available apis: #{Sports::Butler::Configuration::AVAILABLE_APIS.join(', ')}"
|
44
|
+
text
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|