sportradar-api 0.17.0.pre → 0.17.5.pre
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 +4 -4
- data/Gemfile.lock +3 -3
- data/lib/sportradar/api/baseball/game.rb +1 -0
- data/lib/sportradar/api/baseball/lineup.rb +8 -0
- data/lib/sportradar/api/images.rb +2 -2
- 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 +52 -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/match.rb +16 -0
- data/lib/sportradar/api/version.rb +1 -1
- data/lib/sportradar/api.rb +4 -2
- metadata +18 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: baa0128f3db1c19f750c7be30d6c99e7962a60cf18d7edca8efb104126834dcc
|
|
4
|
+
data.tar.gz: 1a342baf45ebb6f364c139bc2e17061e21e33d15f9b1050b2b3b358525280480
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 597526f4a1eacdcd0f1bb9f9ef37da58e1ee3f9e3fe354723f27963f5eaa8e4fff3d690fb4e9d0032dc10d30e45c0bebf679f9e03d6b8e5df736065ef5ec9eac
|
|
7
|
+
data.tar.gz: bf2c269d1f7a1f8870766886bed107663e0d447173a1efdbeec49effeb9149745c3e6ce191ea69f7214ea2f8fb0519dd819814c66602fdbc8d3a5cc8fcc2e5d1
|
data/Gemfile.lock
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
sportradar-api (0.17.
|
|
4
|
+
sportradar-api (0.17.5.pre)
|
|
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 (6.1.
|
|
11
|
+
activesupport (6.1.6)
|
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
13
13
|
i18n (>= 1.6, < 2)
|
|
14
14
|
minitest (>= 5.1)
|
|
@@ -19,7 +19,7 @@ GEM
|
|
|
19
19
|
codeclimate-test-reporter (1.0.8)
|
|
20
20
|
simplecov (<= 0.13)
|
|
21
21
|
coderay (1.1.1)
|
|
22
|
-
concurrent-ruby (1.1.
|
|
22
|
+
concurrent-ruby (1.1.10)
|
|
23
23
|
coveralls (0.8.19)
|
|
24
24
|
json (>= 1.8, < 3)
|
|
25
25
|
simplecov (~> 0.12.0)
|
|
@@ -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'))
|
|
@@ -24,7 +24,7 @@ module Sportradar
|
|
|
24
24
|
response = get request_url("#{league}/#{image_type}/players/manifest")
|
|
25
25
|
end
|
|
26
26
|
elsif nfl_premium || usat_premium || sport == 'ncaafb' || sport == 'nba'
|
|
27
|
-
year = Date.today.month < 8 ? Date.today.year - 1 : Date.today
|
|
27
|
+
year = Date.today.month < 8 ? Date.today.year - 1 : Date.today.year
|
|
28
28
|
response = get request_url("#{image_type}/players/#{year}/manifest")
|
|
29
29
|
else
|
|
30
30
|
response = get request_url("players/#{image_type}/manifests/all_assets")
|
|
@@ -137,7 +137,7 @@ module Sportradar
|
|
|
137
137
|
'ap_premium'
|
|
138
138
|
elsif usat_premium
|
|
139
139
|
'usat_premium'
|
|
140
|
-
elsif
|
|
140
|
+
elsif ['nba', 'nhl'].include?(sport)
|
|
141
141
|
'getty_premium'
|
|
142
142
|
else
|
|
143
143
|
'usat'
|
|
@@ -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=9jcc4ts95ukg6q86wfjjtr7e
|
|
48
|
+
https://api.sportradar.com/oddscomparison-player-props/trial/v2/en/competitions/sr:competition:234/players_props.json?api_key=9jcc4ts95ukg6q86wfjjtr7e
|
|
49
|
+
https://api.sportradar.com/oddscomparison-player-props/trial/v2/en/sports.xml?api_key=9jcc4ts95ukg6q86wfjjtr7e
|
|
@@ -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
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Odds
|
|
4
|
+
class Competition < Data
|
|
5
|
+
attr_accessor :response, :api, :id, :name, :gender, :markets, :futures, :player_props
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def initialize(data, **opts)
|
|
9
|
+
@response = data
|
|
10
|
+
@api = opts[:api]
|
|
11
|
+
@id = data['id']
|
|
12
|
+
|
|
13
|
+
@name = data['name']
|
|
14
|
+
@gender = data['gender']
|
|
15
|
+
@has_markets = data['markets'] # boolean
|
|
16
|
+
@has_futures = data['futures'] # boolean
|
|
17
|
+
@has_player_props = data['player_props'] # boolean
|
|
18
|
+
|
|
19
|
+
@sport_events_hash = {}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def update(data, **opts)
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def sport_events
|
|
27
|
+
@sport_events_hash.values
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def get_player_props
|
|
31
|
+
data = api.get_data(path_player_props)
|
|
32
|
+
create_data(@sport_events_hash, data["competition_sport_events_players_props"], klass: SportEvent, api: api)
|
|
33
|
+
data
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# url path helpers
|
|
37
|
+
def path_base
|
|
38
|
+
"competitions/#{id}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def path_player_props
|
|
42
|
+
"#{path_base}/players_props"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def path_player_props
|
|
46
|
+
"#{path_base}/players_props"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Odds
|
|
4
|
+
class Market < 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
|
+
@player = opts['player']
|
|
15
|
+
|
|
16
|
+
@book_markets_hash = {}
|
|
17
|
+
|
|
18
|
+
update(data, **opts)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def book_markets
|
|
22
|
+
@book_markets_hash.values
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def update(data, **opts)
|
|
26
|
+
create_data(@book_markets_hash, data['books'], klass: BookMarket, api: @api, market: self, player: @player) if data['books']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Odds
|
|
4
|
+
class Outcome < Data
|
|
5
|
+
attr_accessor :response, :id
|
|
6
|
+
attr_accessor :type, :odds_decimal, :odds_american, :odds_fraction, :open_odds_decimal, :open_odds_american, :open_odds_fraction, :total, :open_total, :external_outcome_id, :removed
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def initialize(data, **opts)
|
|
10
|
+
@response = data
|
|
11
|
+
@api = opts[:api]
|
|
12
|
+
|
|
13
|
+
@id = data['id']
|
|
14
|
+
|
|
15
|
+
update(data, **opts)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def update(data, **opts)
|
|
19
|
+
@type = data['type'] if data['type']
|
|
20
|
+
@odds_decimal = data['odds_decimal'] if data['odds_decimal']
|
|
21
|
+
@odds_american = data['odds_american'] if data['odds_american']
|
|
22
|
+
@odds_fraction = data['odds_fraction'] if data['odds_fraction']
|
|
23
|
+
@open_odds_decimal = data['open_odds_decimal'] if data['open_odds_decimal']
|
|
24
|
+
@open_odds_american = data['open_odds_american'] if data['open_odds_american']
|
|
25
|
+
@open_odds_fraction = data['open_odds_fraction'] if data['open_odds_fraction']
|
|
26
|
+
@total = data['total'] if data['total']
|
|
27
|
+
@open_total = data['open_total'] if data['open_total']
|
|
28
|
+
@external_outcome_id = data['external_outcome_id'] if data['external_outcome_id']
|
|
29
|
+
@removed = data['removed'] if data['removed']
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Odds
|
|
4
|
+
class Player < Data
|
|
5
|
+
attr_accessor :response, :api, :id
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def initialize(data, **opts)
|
|
9
|
+
@response = data
|
|
10
|
+
@api = opts[:api]
|
|
11
|
+
@id = data['id'] || data.dig('player', 'id')
|
|
12
|
+
|
|
13
|
+
@props_hash = {}
|
|
14
|
+
|
|
15
|
+
update(data['player']) if data['player']
|
|
16
|
+
update(data)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def update(data, **opts)
|
|
20
|
+
# @name ||= data['name'] if data['name']
|
|
21
|
+
|
|
22
|
+
create_data(@props_hash, data['markets'], klass: Player, api: api) if data['markets']
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Odds
|
|
4
|
+
class PlayerProp < Data
|
|
5
|
+
attr_accessor :response, :api, :id
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def initialize(data, **opts)
|
|
9
|
+
@response = data
|
|
10
|
+
@api = opts[:api]
|
|
11
|
+
@id = data.dig("player", "id")
|
|
12
|
+
|
|
13
|
+
@markets_hash = {}
|
|
14
|
+
|
|
15
|
+
update(data, **opts)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def markets
|
|
19
|
+
@markets_hash.values
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def update(data, **opts)
|
|
23
|
+
create_data(@markets_hash, data['markets'], klass: Market, api: api, player: data['player']) if data['markets']
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Odds
|
|
4
|
+
class Sport < Data
|
|
5
|
+
attr_accessor :response, :api, :id, :name, :type
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def initialize(data, **opts)
|
|
9
|
+
@response = data
|
|
10
|
+
@api = opts[:api]
|
|
11
|
+
|
|
12
|
+
@id = data['id']
|
|
13
|
+
@name = data['name']
|
|
14
|
+
@type = data['type']
|
|
15
|
+
|
|
16
|
+
@competitions_hash = {}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def update(data, **opts)
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def competitions
|
|
25
|
+
@competitions_hash.values
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def get_competitions
|
|
29
|
+
data = api.get_data(path_competitions);
|
|
30
|
+
create_data(@competitions_hash, data['competitions'], klass: Sport, api: api)
|
|
31
|
+
data
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# url path helpers
|
|
35
|
+
def path_base
|
|
36
|
+
"sports/#{id}"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def path_competitions
|
|
40
|
+
"#{path_base}/competitions"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Sportradar
|
|
2
|
+
module Api
|
|
3
|
+
module Odds
|
|
4
|
+
class SportEvent < Data
|
|
5
|
+
attr_accessor :response, :api, :id
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def initialize(data, **opts)
|
|
9
|
+
@response = data
|
|
10
|
+
@api = opts[:api]
|
|
11
|
+
@id = data['id'] || data.dig('sport_event', 'id')
|
|
12
|
+
|
|
13
|
+
@player_props_hash = {}
|
|
14
|
+
@player_markets_hash = {}
|
|
15
|
+
|
|
16
|
+
update(data)
|
|
17
|
+
# update(data['sport_event']) if data['sport_event']
|
|
18
|
+
# update(data['players_props']) if data['players_props']
|
|
19
|
+
# update(data['players_markets']) if data['players_markets']
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def player_props
|
|
23
|
+
@player_props_hash.values
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def player_markets
|
|
27
|
+
@player_markets_hash.values
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def update(data, **opts)
|
|
31
|
+
create_data(@player_props_hash, data['players_props'], klass: PlayerProp, api: api) if data['players_props']
|
|
32
|
+
create_data(@player_markets_hash, data['players_markets'], klass: Market, api: api) if data['players_markets']
|
|
33
|
+
rescue => e
|
|
34
|
+
binding.pry
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/sportradar/api/odds.rb
CHANGED
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
module Sportradar
|
|
2
2
|
module Api
|
|
3
|
-
|
|
4
|
-
attr_accessor :access_level
|
|
5
|
-
|
|
6
|
-
def initialize( access_level = 't')
|
|
7
|
-
raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level
|
|
8
|
-
@access_level = access_level
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def odds
|
|
12
|
-
get request_url, {format: 'none'}
|
|
13
|
-
end
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
def request_url(path = nil)
|
|
17
|
-
"/odds-#{access_level}#{version}"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def api_key
|
|
21
|
-
Sportradar::Api.api_key_params("odds")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def version
|
|
25
|
-
Sportradar::Api.version('odds')
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def allowed_access_levels
|
|
29
|
-
['p', 's', 'b', 't']
|
|
30
|
-
end
|
|
3
|
+
module Odds
|
|
31
4
|
|
|
32
5
|
end
|
|
33
6
|
end
|
|
34
7
|
end
|
|
8
|
+
|
|
9
|
+
require_relative 'odds/api'
|
|
10
|
+
|
|
11
|
+
require_relative 'odds/book'
|
|
12
|
+
require_relative 'odds/sport'
|
|
13
|
+
require_relative 'odds/competition'
|
|
14
|
+
require_relative 'odds/player'
|
|
15
|
+
require_relative 'odds/player_prop'
|
|
16
|
+
require_relative 'odds/sport_event'
|
|
17
|
+
require_relative 'odds/market'
|
|
18
|
+
require_relative 'odds/book_market'
|
|
19
|
+
require_relative 'odds/outcome'
|
|
20
|
+
|
|
21
|
+
require_relative 'odds/base'
|
|
22
|
+
require_relative 'odds/player_odds'
|
|
23
|
+
require_relative 'odds/regular_odds'
|
|
24
|
+
require_relative 'odds/prematch_odds'
|
|
25
|
+
require_relative 'odds/probabilities'
|
|
@@ -55,6 +55,7 @@ module Sportradar
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
@scheduled = Time.parse(data['scheduled']) if data['scheduled']
|
|
58
|
+
@scheduled = Time.parse(data['start_time']) if data['start_time']
|
|
58
59
|
@start_time_tbd = data['start_time_tbd'] if data.key?('start_time_tbd')
|
|
59
60
|
@status = data['status'] if data['status']
|
|
60
61
|
@match_status = data['match_status'] if data['match_status']
|
|
@@ -66,8 +67,10 @@ module Sportradar
|
|
|
66
67
|
|
|
67
68
|
@home_score = data['home_score'] if data['home_score']
|
|
68
69
|
@away_score = data['away_score'] if data['away_score']
|
|
70
|
+
@period = parse_period(data['match_status']) if data['match_status']
|
|
69
71
|
@period = data['period'] if data['period']
|
|
70
72
|
@match_time = data.dig('clock', 'match_time') if data.dig('clock', 'match_time')
|
|
73
|
+
@match_time = data.dig('clock', 'played') if data.dig('clock', 'played')
|
|
71
74
|
@stoppage_time = data.dig('clock', 'stoppage_time')
|
|
72
75
|
@ball_locations = data['ball_locations'] if data['ball_locations']
|
|
73
76
|
@winner_id = data['winner_id'] if data['winner_id']
|
|
@@ -128,6 +131,19 @@ module Sportradar
|
|
|
128
131
|
@match_status == "halftime"
|
|
129
132
|
end
|
|
130
133
|
|
|
134
|
+
def parse_period(status)
|
|
135
|
+
case status
|
|
136
|
+
when '1st_half', 'halftime'
|
|
137
|
+
1
|
|
138
|
+
when '2nd_half'
|
|
139
|
+
2
|
|
140
|
+
when 'overtime', '1st_extra'
|
|
141
|
+
3
|
|
142
|
+
when '2nd_extra'
|
|
143
|
+
4
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
131
147
|
def postponed?
|
|
132
148
|
'postponed' == status
|
|
133
149
|
end
|
data/lib/sportradar/api.rb
CHANGED
|
@@ -58,7 +58,7 @@ module Sportradar
|
|
|
58
58
|
{api: :ncaafb, version: 1},
|
|
59
59
|
{api: :golf, version: 2},
|
|
60
60
|
{api: :nascar, version: 3},
|
|
61
|
-
{api: :odds, version:
|
|
61
|
+
{api: :odds, version: 2},
|
|
62
62
|
{api: :content, version: 3},
|
|
63
63
|
{api: :images, version: 3},
|
|
64
64
|
{api: :live_images, version: 1},
|
|
@@ -85,7 +85,9 @@ module Sportradar
|
|
|
85
85
|
def self.api_key(api, access_level = 'trial')
|
|
86
86
|
ENV.fetch("SPORTRADAR_#{api.to_s.upcase.gsub('-', '_')}#{"_#{access_level.upcase}" if access_level != 'trial'}",
|
|
87
87
|
ENV.fetch("SPORTRADAR_#{api.to_s.upcase}_API_KEY",
|
|
88
|
-
"
|
|
88
|
+
ENV.fetch("SPORTRADAR_#{api.to_s.upcase}",
|
|
89
|
+
"api_key missing for #{api}"
|
|
90
|
+
)
|
|
89
91
|
)
|
|
90
92
|
)
|
|
91
93
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sportradar-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.17.
|
|
4
|
+
version: 0.17.5.pre
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Eggett
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-05-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -403,6 +403,22 @@ files:
|
|
|
403
403
|
- lib/sportradar/api/mma/score.rb
|
|
404
404
|
- lib/sportradar/api/mma/venue.rb
|
|
405
405
|
- lib/sportradar/api/odds.rb
|
|
406
|
+
- lib/sportradar/api/odds/README.md
|
|
407
|
+
- lib/sportradar/api/odds/api.rb
|
|
408
|
+
- lib/sportradar/api/odds/base.rb
|
|
409
|
+
- lib/sportradar/api/odds/book.rb
|
|
410
|
+
- lib/sportradar/api/odds/book_market.rb
|
|
411
|
+
- lib/sportradar/api/odds/competition.rb
|
|
412
|
+
- lib/sportradar/api/odds/market.rb
|
|
413
|
+
- lib/sportradar/api/odds/outcome.rb
|
|
414
|
+
- lib/sportradar/api/odds/player.rb
|
|
415
|
+
- lib/sportradar/api/odds/player_odds.rb
|
|
416
|
+
- lib/sportradar/api/odds/player_prop.rb
|
|
417
|
+
- lib/sportradar/api/odds/prematch_odds.rb
|
|
418
|
+
- lib/sportradar/api/odds/probabilities.rb
|
|
419
|
+
- lib/sportradar/api/odds/regular_odds.rb
|
|
420
|
+
- lib/sportradar/api/odds/sport.rb
|
|
421
|
+
- lib/sportradar/api/odds/sport_event.rb
|
|
406
422
|
- lib/sportradar/api/poll.rb
|
|
407
423
|
- lib/sportradar/api/request.rb
|
|
408
424
|
- lib/sportradar/api/soccer.rb
|