sportradar-api 0.13.10 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Gemfile.lock +19 -44
- data/lib/sportradar/api/baseball/game.rb +9 -0
- data/lib/sportradar/api/baseball/lineup.rb +8 -0
- data/lib/sportradar/api/baseball/mlb/api.rb +6 -6
- data/lib/sportradar/api/baseball/team.rb +1 -1
- data/lib/sportradar/api/basketball/game.rb +2 -1
- data/lib/sportradar/api/basketball/nba/api.rb +5 -5
- data/lib/sportradar/api/basketball/nba/player.rb +3 -1
- data/lib/sportradar/api/basketball/nba.rb +1 -0
- data/lib/sportradar/api/basketball/ncaamb/tournament.rb +2 -2
- data/lib/sportradar/api/basketball/ncaamb.rb +2 -2
- data/lib/sportradar/api/basketball/team.rb +2 -2
- data/lib/sportradar/api/images.rb +15 -12
- data/lib/sportradar/api/odds/README.md +49 -0
- data/lib/sportradar/api/odds/api.rb +60 -0
- data/lib/sportradar/api/odds/base.rb +77 -0
- data/lib/sportradar/api/odds/book.rb +23 -0
- data/lib/sportradar/api/odds/book_market.rb +38 -0
- data/lib/sportradar/api/odds/competition.rb +56 -0
- data/lib/sportradar/api/odds/market.rb +34 -0
- data/lib/sportradar/api/odds/outcome.rb +35 -0
- data/lib/sportradar/api/odds/player.rb +29 -0
- data/lib/sportradar/api/odds/player_odds.rb +13 -0
- data/lib/sportradar/api/odds/player_prop.rb +29 -0
- data/lib/sportradar/api/odds/prematch_odds.rb +9 -0
- data/lib/sportradar/api/odds/probabilities.rb +9 -0
- data/lib/sportradar/api/odds/regular_odds.rb +18 -0
- data/lib/sportradar/api/odds/sport.rb +47 -0
- data/lib/sportradar/api/odds/sport_event.rb +40 -0
- data/lib/sportradar/api/odds.rb +19 -28
- data/lib/sportradar/api/soccer/api.rb +10 -10
- data/lib/sportradar/api/soccer/competition.rb +305 -0
- data/lib/sportradar/api/soccer/match.rb +57 -16
- data/lib/sportradar/api/soccer/player.rb +64 -3
- data/lib/sportradar/api/soccer/season.rb +49 -14
- data/lib/sportradar/api/soccer/team.rb +20 -10
- data/lib/sportradar/api/soccer/tournament.rb +6 -3
- data/lib/sportradar/api/soccer.rb +36 -0
- data/lib/sportradar/api/version.rb +1 -1
- data/lib/sportradar/api.rb +12 -6
- data/sportradar-api.gemspec +0 -2
- metadata +23 -35
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 87396dd744b5483dc483ad40a2210588cfb0740a4492b95925c2bba0281428a6
|
|
4
|
+
data.tar.gz: e0ba45d5bf6a6fcf0bbd9d935c6fe798bd373bb1521422e5116394b4f3d67933
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d7af40902d848873622e44b07ba6d67885e080edca30648965be1193d2b0c12bc66f35258a6a7f5808de09d4f0cce5ae1afef725049d0149795ee23ba4633c2
|
|
7
|
+
data.tar.gz: da5f6b58bc802ca07951a31b53e91ad1f13b51bca5246bf244ec9d90b2d570e9103a49d407600a8c569292275be67b3d0afc91143276393ce78c510eea68e989
|
data/Gemfile.lock
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
sportradar-api (0.
|
|
4
|
+
sportradar-api (0.18.1)
|
|
5
5
|
activesupport
|
|
6
6
|
httparty (>= 0.14.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
activesupport (
|
|
11
|
+
activesupport (6.1.6)
|
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
13
|
-
i18n (
|
|
14
|
-
minitest (
|
|
15
|
-
tzinfo (~>
|
|
13
|
+
i18n (>= 1.6, < 2)
|
|
14
|
+
minitest (>= 5.1)
|
|
15
|
+
tzinfo (~> 2.0)
|
|
16
|
+
zeitwerk (~> 2.3)
|
|
16
17
|
addressable (2.5.1)
|
|
17
18
|
public_suffix (~> 2.0, >= 2.0.2)
|
|
18
19
|
codeclimate-test-reporter (1.0.8)
|
|
19
20
|
simplecov (<= 0.13)
|
|
20
21
|
coderay (1.1.1)
|
|
21
|
-
concurrent-ruby (1.
|
|
22
|
+
concurrent-ruby (1.1.10)
|
|
22
23
|
coveralls (0.8.19)
|
|
23
24
|
json (>= 1.8, < 3)
|
|
24
25
|
simplecov (~> 0.12.0)
|
|
@@ -28,53 +29,29 @@ GEM
|
|
|
28
29
|
crack (0.4.3)
|
|
29
30
|
safe_yaml (~> 1.0.0)
|
|
30
31
|
docile (1.1.5)
|
|
31
|
-
dotenv (2.
|
|
32
|
-
ffi (1.9.18)
|
|
33
|
-
formatador (0.2.5)
|
|
34
|
-
guard (2.14.1)
|
|
35
|
-
formatador (>= 0.2.4)
|
|
36
|
-
listen (>= 2.7, < 4.0)
|
|
37
|
-
lumberjack (~> 1.0)
|
|
38
|
-
nenv (~> 0.1)
|
|
39
|
-
notiffany (~> 0.0)
|
|
40
|
-
pry (>= 0.9.12)
|
|
41
|
-
shellany (~> 0.0)
|
|
42
|
-
thor (>= 0.18.1)
|
|
43
|
-
guard-compat (1.2.1)
|
|
44
|
-
guard-minitest (2.4.6)
|
|
45
|
-
guard-compat (~> 1.2)
|
|
46
|
-
minitest (>= 3.0)
|
|
32
|
+
dotenv (2.7.6)
|
|
47
33
|
hashdiff (0.3.4)
|
|
48
|
-
httparty (0.
|
|
34
|
+
httparty (0.20.0)
|
|
35
|
+
mime-types (~> 3.0)
|
|
49
36
|
multi_xml (>= 0.5.2)
|
|
50
|
-
i18n (
|
|
37
|
+
i18n (1.10.0)
|
|
38
|
+
concurrent-ruby (~> 1.0)
|
|
51
39
|
json (2.1.0)
|
|
52
|
-
listen (3.1.5)
|
|
53
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
54
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
|
55
|
-
ruby_dep (~> 1.2)
|
|
56
|
-
lumberjack (1.0.12)
|
|
57
40
|
method_source (0.8.2)
|
|
41
|
+
mime-types (3.4.1)
|
|
42
|
+
mime-types-data (~> 3.2015)
|
|
43
|
+
mime-types-data (3.2022.0105)
|
|
58
44
|
minitest (5.10.2)
|
|
59
45
|
minitest-focus (1.1.2)
|
|
60
46
|
minitest (>= 4, < 6)
|
|
61
47
|
multi_xml (0.6.0)
|
|
62
|
-
nenv (0.3.0)
|
|
63
|
-
notiffany (0.1.1)
|
|
64
|
-
nenv (~> 0.1)
|
|
65
|
-
shellany (~> 0.0)
|
|
66
48
|
pry (0.10.4)
|
|
67
49
|
coderay (~> 1.1.0)
|
|
68
50
|
method_source (~> 0.8.1)
|
|
69
51
|
slop (~> 3.4)
|
|
70
52
|
public_suffix (2.0.5)
|
|
71
53
|
rake (10.5.0)
|
|
72
|
-
rb-fsevent (0.9.8)
|
|
73
|
-
rb-inotify (0.9.10)
|
|
74
|
-
ffi (>= 0.5.0, < 2)
|
|
75
|
-
ruby_dep (1.5.0)
|
|
76
54
|
safe_yaml (1.0.4)
|
|
77
|
-
shellany (0.0.1)
|
|
78
55
|
simplecov (0.12.0)
|
|
79
56
|
docile (~> 1.1.0)
|
|
80
57
|
json (>= 1.8, < 3)
|
|
@@ -84,15 +61,15 @@ GEM
|
|
|
84
61
|
term-ansicolor (1.6.0)
|
|
85
62
|
tins (~> 1.0)
|
|
86
63
|
thor (0.19.4)
|
|
87
|
-
thread_safe (0.3.6)
|
|
88
64
|
tins (1.14.0)
|
|
89
|
-
tzinfo (
|
|
90
|
-
|
|
65
|
+
tzinfo (2.0.4)
|
|
66
|
+
concurrent-ruby (~> 1.0)
|
|
91
67
|
vcr (3.0.3)
|
|
92
68
|
webmock (3.0.1)
|
|
93
69
|
addressable (>= 2.3.6)
|
|
94
70
|
crack (>= 0.3.2)
|
|
95
71
|
hashdiff
|
|
72
|
+
zeitwerk (2.5.4)
|
|
96
73
|
|
|
97
74
|
PLATFORMS
|
|
98
75
|
ruby
|
|
@@ -102,8 +79,6 @@ DEPENDENCIES
|
|
|
102
79
|
codeclimate-test-reporter
|
|
103
80
|
coveralls
|
|
104
81
|
dotenv
|
|
105
|
-
guard
|
|
106
|
-
guard-minitest
|
|
107
82
|
minitest (~> 5.0)
|
|
108
83
|
minitest-focus
|
|
109
84
|
pry
|
|
@@ -114,4 +89,4 @@ DEPENDENCIES
|
|
|
114
89
|
webmock
|
|
115
90
|
|
|
116
91
|
BUNDLED WITH
|
|
117
|
-
1.
|
|
92
|
+
1.17.2
|
|
@@ -43,6 +43,10 @@ module Sportradar
|
|
|
43
43
|
{}
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
def period
|
|
47
|
+
@innings
|
|
48
|
+
end
|
|
49
|
+
|
|
46
50
|
def tied?
|
|
47
51
|
@score[away_id].to_i == @score[home_id].to_i
|
|
48
52
|
end
|
|
@@ -103,6 +107,7 @@ module Sportradar
|
|
|
103
107
|
end
|
|
104
108
|
|
|
105
109
|
def update(data, source: nil, **opts)
|
|
110
|
+
@response.merge!(data)
|
|
106
111
|
# via pbp
|
|
107
112
|
@status = data['status'] if data['status']
|
|
108
113
|
@coverage = data['coverage'] if data['coverage']
|
|
@@ -350,6 +355,10 @@ module Sportradar
|
|
|
350
355
|
}.freeze[self.count['inning_half']]
|
|
351
356
|
end
|
|
352
357
|
|
|
358
|
+
def clock
|
|
359
|
+
half_short
|
|
360
|
+
end
|
|
361
|
+
|
|
353
362
|
def postponed?
|
|
354
363
|
'postponed' == status
|
|
355
364
|
end
|
|
@@ -28,6 +28,14 @@ module Sportradar
|
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
def full_home
|
|
32
|
+
@home_team_lineup
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def full_away
|
|
36
|
+
@away_team_lineup
|
|
37
|
+
end
|
|
38
|
+
|
|
31
39
|
def update_from_lineup_event(data)
|
|
32
40
|
if data.dig('team_id') == game.home_id
|
|
33
41
|
update_home(data, data.dig('order'))
|
|
@@ -26,10 +26,10 @@ module Sportradar
|
|
|
26
26
|
'reg'
|
|
27
27
|
end
|
|
28
28
|
def default_access_level
|
|
29
|
-
if (ENV['
|
|
30
|
-
'
|
|
29
|
+
if (ENV['SPORTRADAR_ENV_MLB'] || ENV['SPORTRADAR_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
|
|
30
|
+
'production'
|
|
31
31
|
else
|
|
32
|
-
'
|
|
32
|
+
'trial'
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
@@ -40,11 +40,11 @@ module Sportradar
|
|
|
40
40
|
private
|
|
41
41
|
|
|
42
42
|
def request_url(path)
|
|
43
|
-
"/mlb
|
|
43
|
+
"/mlb/#{access_level}/v#{version}/en/#{path}"
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def api_key
|
|
47
|
-
if !['
|
|
47
|
+
if !['trial', 'sim'].include?(access_level)
|
|
48
48
|
Sportradar::Api.api_key_params('mlb', 'production')
|
|
49
49
|
elsif 'sim' == access_level
|
|
50
50
|
Sportradar::Api.api_key_params('mlb', 'simulation')
|
|
@@ -58,7 +58,7 @@ module Sportradar
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def allowed_access_levels
|
|
61
|
-
%w[
|
|
61
|
+
%w[production trial sim]
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def allowed_seasons
|
|
@@ -128,7 +128,7 @@ module Sportradar
|
|
|
128
128
|
"teams/#{ id }"
|
|
129
129
|
end
|
|
130
130
|
def path_base_stats(season_year = api.default_year, default_season = api.default_season)
|
|
131
|
-
"
|
|
131
|
+
"seasons/#{season_year}/#{default_season}/teams/#{id}"
|
|
132
132
|
end
|
|
133
133
|
def path_roster
|
|
134
134
|
"#{ path_base }/profile"
|
|
@@ -2,7 +2,7 @@ module Sportradar
|
|
|
2
2
|
module Api
|
|
3
3
|
module Basketball
|
|
4
4
|
class Game < Data
|
|
5
|
-
attr_accessor :response, :id, :title, :home_id, :away_id, :score, :status, :coverage, :scheduled, :venue, :broadcast, :clock, :duration, :attendance, :team_stats, :player_stats, :changes, :media_timeouts
|
|
5
|
+
attr_accessor :response, :id, :title, :home_id, :away_id, :score, :status, :coverage, :time_zone, :scheduled, :venue, :broadcast, :clock, :duration, :attendance, :team_stats, :player_stats, :changes, :media_timeouts
|
|
6
6
|
|
|
7
7
|
attr_accessor :period
|
|
8
8
|
@all_hash = {}
|
|
@@ -94,6 +94,7 @@ module Sportradar
|
|
|
94
94
|
@away = team_class.new(data['away'], api: api, game: self) if data['away']
|
|
95
95
|
@title = data['title'] || @title || (home && away && "#{home.full_name} vs #{away.full_name}")
|
|
96
96
|
|
|
97
|
+
@time_zone = data.dig("time_zones", "venue") if data.dig("time_zones", "venue")
|
|
97
98
|
@duration = data['duration'] if data['duration']
|
|
98
99
|
@clock = data['clock'] if data['clock']
|
|
99
100
|
@attendance = data['attendance'] if data['attendance']
|
|
@@ -22,9 +22,9 @@ module Sportradar
|
|
|
22
22
|
end
|
|
23
23
|
def default_access_level
|
|
24
24
|
if (ENV['SPORTRADAR_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
|
|
25
|
-
'
|
|
25
|
+
'production'
|
|
26
26
|
else
|
|
27
|
-
'
|
|
27
|
+
'trial'
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -35,11 +35,11 @@ module Sportradar
|
|
|
35
35
|
private
|
|
36
36
|
|
|
37
37
|
def request_url(path)
|
|
38
|
-
"/nba
|
|
38
|
+
"/nba/#{access_level}/v#{version}/en/#{path}"
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def api_key
|
|
42
|
-
if !['
|
|
42
|
+
if !['trial', 'sim'].include?(access_level) || (access_level == 'sim' && default_access_level == 'production')
|
|
43
43
|
Sportradar::Api.api_key_params('nba', 'production')
|
|
44
44
|
else
|
|
45
45
|
Sportradar::Api.api_key_params('nba')
|
|
@@ -51,7 +51,7 @@ module Sportradar
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def allowed_access_levels
|
|
54
|
-
%w[
|
|
54
|
+
%w[production trial sim]
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def allowed_seasons
|
|
@@ -3,7 +3,7 @@ module Sportradar
|
|
|
3
3
|
module Basketball
|
|
4
4
|
class Nba
|
|
5
5
|
class Player < Data
|
|
6
|
-
attr_accessor :response, :id, :number, :full_name, :first_name, :last_name, :position, :birth_place, :college, :height, :weight, :averages, :totals, :draft, :stats
|
|
6
|
+
attr_accessor :response, :id, :number, :full_name, :first_name, :last_name, :position, :birth_place, :college, :height, :weight, :averages, :totals, :draft, :stats, :team, :not_playing_reason, :not_playing_description
|
|
7
7
|
# @all_hash = {}
|
|
8
8
|
# def self.new(data, **opts)
|
|
9
9
|
# existing = @all_hash[data['id']]
|
|
@@ -57,6 +57,8 @@ module Sportradar
|
|
|
57
57
|
@experience = data['experience'] if data['experience'] # "3",
|
|
58
58
|
@birth_place = data['birth_place'].gsub(',,', ', ') if data['birth_place'] # "Benin City,, NGA",
|
|
59
59
|
@updated = data['updated'] if data['updated'] # "2016-07-08T12:11:59+00:00",
|
|
60
|
+
@not_playing_reason = data['not_playing_reason'] if data['not_playing_reason'] # "Inactive - Injury/Illness"
|
|
61
|
+
@not_playing_description = data['not_playing_description'] if data['not_playing_description'] # "Left Ankle; Sprain"
|
|
60
62
|
|
|
61
63
|
# NBA specific below
|
|
62
64
|
|
|
@@ -91,7 +91,7 @@ module Sportradar
|
|
|
91
91
|
|
|
92
92
|
# summary
|
|
93
93
|
def get_summary
|
|
94
|
-
data = api.get_data(path_summary)
|
|
94
|
+
data = api.get_data(path_summary).to_h
|
|
95
95
|
ingest_summary(data)
|
|
96
96
|
end
|
|
97
97
|
def queue_summary
|
|
@@ -105,7 +105,7 @@ module Sportradar
|
|
|
105
105
|
|
|
106
106
|
# schedule
|
|
107
107
|
def get_schedule
|
|
108
|
-
data = api.get_data(path_schedule)
|
|
108
|
+
data = api.get_data(path_schedule).to_h
|
|
109
109
|
ingest_schedule(data)
|
|
110
110
|
end
|
|
111
111
|
def queue_schedule
|
|
@@ -115,7 +115,7 @@ module Sportradar
|
|
|
115
115
|
{url: url, headers: headers, params: options, timeout: timeout, callback: method(:ingest_roster)}
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
def get_season_stats(year =
|
|
118
|
+
def get_season_stats(year = api.default_year)
|
|
119
119
|
data = api.get_data(path_season_stats(year)).to_h
|
|
120
120
|
ingest_season_stats(data)
|
|
121
121
|
end
|
|
@@ -132,7 +132,7 @@ module Sportradar
|
|
|
132
132
|
"teams/#{ id }"
|
|
133
133
|
end
|
|
134
134
|
def path_base_stats(season_year = api.default_year, default_season = api.default_season)
|
|
135
|
-
"
|
|
135
|
+
"seasons/#{season_year}/#{default_season}/teams/#{id}"
|
|
136
136
|
end
|
|
137
137
|
def path_roster
|
|
138
138
|
"#{ path_base }/profile"
|
|
@@ -3,7 +3,7 @@ module Sportradar
|
|
|
3
3
|
module Api
|
|
4
4
|
class Images < Request
|
|
5
5
|
attr_accessor :sport, :league, :access_level, :nfl_premium, :usat_premium, :event_id, :date, :live_image_request
|
|
6
|
-
def initialize( sport, access_level: 't', league: nil, nfl_premium: false, usat_premium: false, event_id: nil, date: nil )
|
|
6
|
+
def initialize( sport, access_level: 't', league: nil, nfl_premium: false, usat_premium: false, event_id: nil, date: nil, year: nil )
|
|
7
7
|
raise Sportradar::Api::Error::InvalidSport unless allowed_sports.include? sport
|
|
8
8
|
@sport = sport
|
|
9
9
|
raise Sportradar::Api::Error::InvalidLeague unless soccer_leagues.include?(league) || league.nil?
|
|
@@ -12,6 +12,7 @@ module Sportradar
|
|
|
12
12
|
@usat_premium = usat_premium
|
|
13
13
|
@event_id = event_id
|
|
14
14
|
@date = date.strftime("%Y/%m/%d") if date
|
|
15
|
+
@year = year
|
|
15
16
|
raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level
|
|
16
17
|
@access_level = access_level
|
|
17
18
|
end
|
|
@@ -23,8 +24,9 @@ module Sportradar
|
|
|
23
24
|
else
|
|
24
25
|
response = get request_url("#{league}/#{image_type}/players/manifest")
|
|
25
26
|
end
|
|
26
|
-
elsif nfl_premium || usat_premium || sport == 'ncaafb'
|
|
27
|
-
|
|
27
|
+
elsif nfl_premium || usat_premium || sport == 'ncaafb' || sport == 'nba'
|
|
28
|
+
request_year = @year || (Date.today.month < 8 ? Date.today.year - 1 : Date.today.year)
|
|
29
|
+
response = get request_url("#{image_type}/players/#{request_year}/manifest")
|
|
28
30
|
else
|
|
29
31
|
response = get request_url("players/#{image_type}/manifests/all_assets")
|
|
30
32
|
end
|
|
@@ -39,7 +41,6 @@ module Sportradar
|
|
|
39
41
|
# Coach Manifests
|
|
40
42
|
|
|
41
43
|
def coach_manifests
|
|
42
|
-
raise Sportradar::Api::Error::InvalidLeague unless league.nil?
|
|
43
44
|
response = get request_url("coaches/#{image_type}/manifests/all_assets")
|
|
44
45
|
if response.success? && response["assetlist"]
|
|
45
46
|
Sportradar::Api::Images::AssetList.new response["assetlist"]
|
|
@@ -50,7 +51,6 @@ module Sportradar
|
|
|
50
51
|
alias_method :all_coaches, :coach_manifests
|
|
51
52
|
|
|
52
53
|
def venue_manifests
|
|
53
|
-
raise Sportradar::Api::Error::InvalidLeague unless league.nil?
|
|
54
54
|
if version == 3
|
|
55
55
|
response = get request_url("venues/manifest")
|
|
56
56
|
else
|
|
@@ -97,7 +97,7 @@ module Sportradar
|
|
|
97
97
|
private
|
|
98
98
|
|
|
99
99
|
def request_url(path)
|
|
100
|
-
"/#{sport}-images-#{access_level}#{version}/#{provider}/#{path}"
|
|
100
|
+
"/#{sport}-images-#{access_level}#{version}/#{provider}/#{( league + '/') if league}#{path}"
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
def api_key
|
|
@@ -138,6 +138,8 @@ module Sportradar
|
|
|
138
138
|
'ap_premium'
|
|
139
139
|
elsif usat_premium
|
|
140
140
|
'usat_premium'
|
|
141
|
+
elsif ['nba', 'nhl'].include?(sport)
|
|
142
|
+
'getty_premium'
|
|
141
143
|
else
|
|
142
144
|
'usat'
|
|
143
145
|
# REUTERS IS JUST FOR SOCCER sport == 'mlb' ? 'usat' : 'reuters'
|
|
@@ -145,11 +147,12 @@ module Sportradar
|
|
|
145
147
|
end
|
|
146
148
|
|
|
147
149
|
def version
|
|
148
|
-
if uses_v3_api? || nfl_premium || usat_premium
|
|
149
|
-
|
|
150
|
-
elsif uses_v2_api?
|
|
151
|
-
|
|
152
|
-
end
|
|
150
|
+
# if uses_v3_api? || nfl_premium || usat_premium || sport == 'nba'
|
|
151
|
+
# 3
|
|
152
|
+
# elsif uses_v2_api?
|
|
153
|
+
# Sportradar::Api.version('images')
|
|
154
|
+
# end
|
|
155
|
+
3
|
|
153
156
|
end
|
|
154
157
|
|
|
155
158
|
def image_type
|
|
@@ -177,7 +180,7 @@ module Sportradar
|
|
|
177
180
|
end
|
|
178
181
|
|
|
179
182
|
def v3_api_sports
|
|
180
|
-
['mlb', 'soccer', 'cricket', 'f1', 'rugby', 'tennis', 'ncaafb',
|
|
183
|
+
['mlb', 'soccer', 'cricket', 'f1', 'rugby', 'tennis', 'ncaafb', 'nba' ]
|
|
181
184
|
end
|
|
182
185
|
|
|
183
186
|
def soccer_leagues
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Some snippets
|
|
2
|
+
|
|
3
|
+
```ruby
|
|
4
|
+
|
|
5
|
+
odds = Sportradar::Api::Odds::PlayerOdds.new
|
|
6
|
+
data = odds.get_books
|
|
7
|
+
data = odds.get_sports
|
|
8
|
+
data = odds.get_event_mappings
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
sport = odds.sports.first
|
|
12
|
+
sport.get_competitions
|
|
13
|
+
comp = sport.competitions.first
|
|
14
|
+
|
|
15
|
+
api = Sportradar::Api::Odds::PlayerOdds.api
|
|
16
|
+
comp = Sportradar::Api::Odds::Competition.new({'id' => 'sr:competition:234'}, api: api)
|
|
17
|
+
data = comp.get_player_props
|
|
18
|
+
comp.sport_events
|
|
19
|
+
event = comp.sport_events.first
|
|
20
|
+
|
|
21
|
+
odds = Sportradar::Api::Odds::PlayerOdds.new
|
|
22
|
+
data = odds.get_sports
|
|
23
|
+
sport = odds.sports.first
|
|
24
|
+
sport.get_competitions
|
|
25
|
+
comp = sport.competitions.first
|
|
26
|
+
|
|
27
|
+
event = comp.sport_events.first
|
|
28
|
+
event.player_props
|
|
29
|
+
event.response
|
|
30
|
+
prop = event.player_props.first
|
|
31
|
+
prop.markets.count
|
|
32
|
+
market = prop.markets.first
|
|
33
|
+
market.response
|
|
34
|
+
market.name
|
|
35
|
+
bm = market.book_markets.first
|
|
36
|
+
outcome = bm.outcomes.first
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# {"id"=>"sr:competition:8", "name"=>"LaLiga", "gender"=>"men", "markets"=>true, "futures"=>false, "player_props"=>true, "category"=>{"id"=>"sr:category:32", "name"=>"Spain", "country_code"=>"ESP"}},
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
# Some links
|
|
45
|
+
|
|
46
|
+
https://api.sportradar.com/oddscomparison-player-props/trial/v2/en/books.xml?api_key=
|
|
47
|
+
https://api.sportradar.com/oddscomparison-player-props/trial/v2/en/sports/sr:sport:1/competitions.xml?api_key=
|
|
48
|
+
https://api.sportradar.com/oddscomparison-player-props/trial/v2/en/competitions/sr:competition:234/players_props.json?api_key=
|
|
49
|
+
https://api.sportradar.com/oddscomparison-player-props/trial/v2/en/sports.xml?api_key=
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Odds
|
|
4
|
+
class Api < Request
|
|
5
|
+
attr_accessor :access_level, :language_code, :error, :base_path
|
|
6
|
+
|
|
7
|
+
def initialize(base_path: base_path, access_level: default_access_level, language_code: 'en', **args)
|
|
8
|
+
@language_code = language_code
|
|
9
|
+
@access_level = access_level
|
|
10
|
+
@base_path = base_path
|
|
11
|
+
raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? @access_level
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def default_season
|
|
15
|
+
'reg'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def default_access_level
|
|
19
|
+
if (ENV['SPORTRADAR_ODDS_ENV'] || ENV['SPORTRADAR_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
|
|
20
|
+
'production'
|
|
21
|
+
else
|
|
22
|
+
'trial'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def content_format
|
|
27
|
+
'json'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def inspect
|
|
31
|
+
self.class.name
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def request_url(path)
|
|
37
|
+
"/#{base_path}/#{access_level}/v#{version}/#{language_code}/#{path}"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def api_key
|
|
41
|
+
if !['trial', 'sim'].include?(access_level) || (access_level == 'sim' && default_access_level == 'production')
|
|
42
|
+
Sportradar::Api.api_key_params("odds", 'production')
|
|
43
|
+
else
|
|
44
|
+
Sportradar::Api.api_key_params("odds")
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def version
|
|
49
|
+
Sportradar::Api.version('odds')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def allowed_access_levels
|
|
53
|
+
%w[production trial]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Odds
|
|
4
|
+
class Base < Data
|
|
5
|
+
attr_reader :api
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
@api = self.class.api
|
|
9
|
+
@books_hash = {}
|
|
10
|
+
@sports_hash = {}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def books
|
|
14
|
+
@books_hash.values
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def sports
|
|
18
|
+
@sports_hash.values
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def get_books
|
|
22
|
+
data = api.get_data(path_books);
|
|
23
|
+
create_data(@books_hash, data['books'], klass: Book, api: api)
|
|
24
|
+
data
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def get_sports
|
|
28
|
+
data = api.get_data(path_sports);
|
|
29
|
+
create_data(@sports_hash, data['sports'], klass: Sport, api: api)
|
|
30
|
+
data
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def get_event_mappings
|
|
34
|
+
data = api.get_data(path_event_mappings)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def get_player_mappings
|
|
38
|
+
data = api.get_data(path_player_mappings)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def get_competitor_mappings
|
|
42
|
+
data = api.get_data(path_competitor_mappings)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# url path helpers
|
|
46
|
+
def path_base
|
|
47
|
+
""
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def path_books
|
|
51
|
+
"books"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def path_sports
|
|
55
|
+
"sports"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def path_event_mappings
|
|
59
|
+
'sport_events/mappings'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def path_player_mappings
|
|
63
|
+
'players/mappings'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def path_competitor_mappings
|
|
67
|
+
'competitors/mappings'
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.api
|
|
71
|
+
Api.new(base_path: api_base)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Odds
|
|
4
|
+
class Book < Data
|
|
5
|
+
attr_accessor :response, :id, :name
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def initialize(data, **opts)
|
|
9
|
+
@response = data
|
|
10
|
+
@api = opts[:api]
|
|
11
|
+
|
|
12
|
+
@id = data['id']
|
|
13
|
+
@name = data['name']
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def update(data, **opts)
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|