sportradar-api 0.17.4 → 0.17.5.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5f42d83eacff90ed56c31c549c276a6836e9876e0703e3ea4864bea23b9ae43
4
- data.tar.gz: 56ad3cde33943d0fe4155c9dd44f757b4d98577912c4f5cecf0f3f644723f0d3
3
+ metadata.gz: baa0128f3db1c19f750c7be30d6c99e7962a60cf18d7edca8efb104126834dcc
4
+ data.tar.gz: 1a342baf45ebb6f364c139bc2e17061e21e33d15f9b1050b2b3b358525280480
5
5
  SHA512:
6
- metadata.gz: 6e987eb4aea1b86d63026fff8873d4cf016a49bcde7c009653279bbdb9a5ed9ef6d2756a9848e914d5cb59208f5fcaec947c3f13a8431af1b3a4f82e404ad47b
7
- data.tar.gz: a07583a6397240bffc8fbd8c4f02d5cecd38d2c95da30a117a336fe2c83ef8b9e3e96467fa94dd9cabda6f0ee569f4ae9466cf4615a59a1f9806565d16b9e4a1
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)
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.5.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)
@@ -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,13 @@
1
+ module Sportradar
2
+ module Api
3
+ module Odds
4
+ class PlayerOdds < Base
5
+
6
+ def self.api_base
7
+ 'oddscomparison-player-props'
8
+ end
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -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,9 @@
1
+ module Sportradar
2
+ module Api
3
+ module Odds
4
+ class PrematchOdds
5
+ #
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Sportradar
2
+ module Api
3
+ module Odds
4
+ class Probabilities
5
+ #
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ module Sportradar
2
+ module Api
3
+ module Odds
4
+ class RegularOdds
5
+ #
6
+
7
+ def self.api_base
8
+ "oddscomparison-#{package}"
9
+ end
10
+
11
+ def self.package
12
+ # read ENV
13
+ 'us'
14
+ end
15
+ end
16
+ end
17
+ end
18
+ 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
@@ -1,34 +1,25 @@
1
1
  module Sportradar
2
2
  module Api
3
- class Odds < Request
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'
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.17.4"
3
+ VERSION = "0.17.5.pre"
4
4
  end
5
5
  end
@@ -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: 1},
61
+ {api: :odds, version: 2},
62
62
  {api: :content, version: 3},
63
63
  {api: :images, version: 3},
64
64
  {api: :live_images, version: 1},
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
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-05-18 00:00:00.000000000 Z
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
@@ -439,9 +455,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
439
455
  version: '0'
440
456
  required_rubygems_version: !ruby/object:Gem::Requirement
441
457
  requirements:
442
- - - ">="
458
+ - - ">"
443
459
  - !ruby/object:Gem::Version
444
- version: '0'
460
+ version: 1.3.1
445
461
  requirements: []
446
462
  rubygems_version: 3.0.3.1
447
463
  signing_key: