sportradar-api 0.13.24 → 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 +18 -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 +5 -5
- 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/team.rb +1 -1
- data/lib/sportradar/api/images.rb +14 -9
- 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 +9 -9
- data/lib/sportradar/api/soccer/competition.rb +305 -0
- data/lib/sportradar/api/soccer/match.rb +22 -8
- data/lib/sportradar/api/soccer/player.rb +16 -4
- data/lib/sportradar/api/soccer/season.rb +49 -14
- data/lib/sportradar/api/soccer/team.rb +3 -0
- 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,54 +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)
|
|
51
38
|
concurrent-ruby (~> 1.0)
|
|
52
39
|
json (2.1.0)
|
|
53
|
-
listen (3.1.5)
|
|
54
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
55
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
|
56
|
-
ruby_dep (~> 1.2)
|
|
57
|
-
lumberjack (1.0.12)
|
|
58
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)
|
|
59
44
|
minitest (5.10.2)
|
|
60
45
|
minitest-focus (1.1.2)
|
|
61
46
|
minitest (>= 4, < 6)
|
|
62
47
|
multi_xml (0.6.0)
|
|
63
|
-
nenv (0.3.0)
|
|
64
|
-
notiffany (0.1.1)
|
|
65
|
-
nenv (~> 0.1)
|
|
66
|
-
shellany (~> 0.0)
|
|
67
48
|
pry (0.10.4)
|
|
68
49
|
coderay (~> 1.1.0)
|
|
69
50
|
method_source (~> 0.8.1)
|
|
70
51
|
slop (~> 3.4)
|
|
71
52
|
public_suffix (2.0.5)
|
|
72
53
|
rake (10.5.0)
|
|
73
|
-
rb-fsevent (0.9.8)
|
|
74
|
-
rb-inotify (0.9.10)
|
|
75
|
-
ffi (>= 0.5.0, < 2)
|
|
76
|
-
ruby_dep (1.5.0)
|
|
77
54
|
safe_yaml (1.0.4)
|
|
78
|
-
shellany (0.0.1)
|
|
79
55
|
simplecov (0.12.0)
|
|
80
56
|
docile (~> 1.1.0)
|
|
81
57
|
json (>= 1.8, < 3)
|
|
@@ -85,15 +61,15 @@ GEM
|
|
|
85
61
|
term-ansicolor (1.6.0)
|
|
86
62
|
tins (~> 1.0)
|
|
87
63
|
thor (0.19.4)
|
|
88
|
-
thread_safe (0.3.6)
|
|
89
64
|
tins (1.14.0)
|
|
90
|
-
tzinfo (
|
|
91
|
-
|
|
65
|
+
tzinfo (2.0.4)
|
|
66
|
+
concurrent-ruby (~> 1.0)
|
|
92
67
|
vcr (3.0.3)
|
|
93
68
|
webmock (3.0.1)
|
|
94
69
|
addressable (>= 2.3.6)
|
|
95
70
|
crack (>= 0.3.2)
|
|
96
71
|
hashdiff
|
|
72
|
+
zeitwerk (2.5.4)
|
|
97
73
|
|
|
98
74
|
PLATFORMS
|
|
99
75
|
ruby
|
|
@@ -103,8 +79,6 @@ DEPENDENCIES
|
|
|
103
79
|
codeclimate-test-reporter
|
|
104
80
|
coveralls
|
|
105
81
|
dotenv
|
|
106
|
-
guard
|
|
107
|
-
guard-minitest
|
|
108
82
|
minitest (~> 5.0)
|
|
109
83
|
minitest-focus
|
|
110
84
|
pry
|
|
@@ -115,4 +89,4 @@ DEPENDENCIES
|
|
|
115
89
|
webmock
|
|
116
90
|
|
|
117
91
|
BUNDLED WITH
|
|
118
|
-
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'))
|
|
@@ -27,9 +27,9 @@ module Sportradar
|
|
|
27
27
|
end
|
|
28
28
|
def default_access_level
|
|
29
29
|
if (ENV['SPORTRADAR_ENV_MLB'] || ENV['SPORTRADAR_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
|
|
30
|
-
'
|
|
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
|
|
|
@@ -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
|
|
@@ -136,6 +138,8 @@ module Sportradar
|
|
|
136
138
|
'ap_premium'
|
|
137
139
|
elsif usat_premium
|
|
138
140
|
'usat_premium'
|
|
141
|
+
elsif ['nba', 'nhl'].include?(sport)
|
|
142
|
+
'getty_premium'
|
|
139
143
|
else
|
|
140
144
|
'usat'
|
|
141
145
|
# REUTERS IS JUST FOR SOCCER sport == 'mlb' ? 'usat' : 'reuters'
|
|
@@ -143,11 +147,12 @@ module Sportradar
|
|
|
143
147
|
end
|
|
144
148
|
|
|
145
149
|
def version
|
|
146
|
-
if uses_v3_api? || nfl_premium || usat_premium
|
|
147
|
-
|
|
148
|
-
elsif uses_v2_api?
|
|
149
|
-
|
|
150
|
-
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
|
|
151
156
|
end
|
|
152
157
|
|
|
153
158
|
def image_type
|
|
@@ -175,7 +180,7 @@ module Sportradar
|
|
|
175
180
|
end
|
|
176
181
|
|
|
177
182
|
def v3_api_sports
|
|
178
|
-
['mlb', 'soccer', 'cricket', 'f1', 'rugby', 'tennis', 'ncaafb',
|
|
183
|
+
['mlb', 'soccer', 'cricket', 'f1', 'rugby', 'tennis', 'ncaafb', 'nba' ]
|
|
179
184
|
end
|
|
180
185
|
|
|
181
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
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Odds
|
|
4
|
+
class BookMarket < Data
|
|
5
|
+
attr_accessor :response, :id, :book_id, :book_name, :removed, :external_sport_event_id, :external_market_id
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def initialize(data, **opts)
|
|
9
|
+
@response = data
|
|
10
|
+
@api = opts[:api]
|
|
11
|
+
|
|
12
|
+
@id = data['external_market_id']
|
|
13
|
+
@market = opts[:market]
|
|
14
|
+
@outcomes_hash = {}
|
|
15
|
+
|
|
16
|
+
update(data, **opts)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def outcomes
|
|
20
|
+
@outcomes_hash.values
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def update(data, **opts)
|
|
24
|
+
@book_id = data['id'] if data['id'] # "sr:book:17324",
|
|
25
|
+
@book_name = data['name'] if data['name'] # "MGM",
|
|
26
|
+
@removed = data['removed'] if data['removed'] # false,
|
|
27
|
+
@external_sport_event_id = data['external_sport_event_id'] if data['external_sport_event_id'] # "12959106",
|
|
28
|
+
@external_market_id = data['external_market_id'] if data['external_market_id'] # "773486499",
|
|
29
|
+
|
|
30
|
+
create_data(@outcomes_hash, data['outcomes'], klass: Outcome, api: @api) if data['outcomes']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|