sportradar-api 0.1.25 → 0.1.26

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
  SHA1:
3
- metadata.gz: ab8909c00d8d501e955fa4177760b6fca26364e6
4
- data.tar.gz: 25a0737f80a930197e26831d251b99046b9b9591
3
+ metadata.gz: a8152d88570a153230df0842c30f947da8afbbe2
4
+ data.tar.gz: b38e08d450f80f5c68f6b8474ec95163b1e526f7
5
5
  SHA512:
6
- metadata.gz: baa0a432521806957749cc7d304f43c65b459cc4a51607aa6c018a32b5b0f02c3812a98361617f531296a75e450c117a58303c766171113c3f306008c1e29c6f
7
- data.tar.gz: c895e2cabe8def8896b0d56a99734228dc81d8dcb800562e9a23a7d290256c2e7155642b82084887fbd341fbd6fcbc3309cbfd069dad19719b4f2a79035bc4d1
6
+ metadata.gz: c3e59f66dc5d98d494873fd122b75bed923804d423f94060c443be228f02efe93d3e07ea5c867a7d948b2df254967925274a0211a962e2bde4373e452e1bd1cb
7
+ data.tar.gz: f316981383a33e70238c1d48c27f50fd0c907a2148aaff2891073a4ef308391acfbb4412a0837873df74d88b6c65f190b50b1d0f79e68cb32d9bdd26186f5f04
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportradar-api (0.1.25)
4
+ sportradar-api (0.1.26)
5
5
  activesupport
6
6
  httparty (>= 0.13.3)
7
7
 
data/README.md CHANGED
@@ -17,7 +17,8 @@ Our goal is to incrementally integrate with them. **Contributions are welcome**
17
17
 
18
18
  [Current API Versions](http://developer.sportradar.us/api_gallery)
19
19
 
20
- 🙋 = Basic Api wrapped
20
+ 🙋 = Basic API wrapped/object mapping in progress
21
+ ✅ = API implemented and wrapped in proper objects
21
22
 
22
23
  | API | Version | Docs | Implemented? | Priority |
23
24
  | --- | --- | --- | --- | --- |
@@ -30,11 +31,11 @@ Our goal is to incrementally integrate with them. **Contributions are welcome**
30
31
  | Golf | 2 | [📚](http://developer.sportradar.us/docs/Golf_API) | - | - |
31
32
  | NASCAR | 3 | [📚](http://developer.sportradar.us/page/NASCAR_Official) | - | - |
32
33
  | Odds | 1 | [📚](http://developer.sportradar.us/docs/Odds_API) | 🙋 | 👍 |
33
- | Content | 3 | [📚](http://developer.sportradar.us/docs/Content_API) | 🙋 | 👍 |
34
- | Images | 2 | [📚](http://developer.sportradar.us/docs/Images_API) | 🙋 | 👍 |
35
- | Live Images | 1 | [📚](http://developer.sportradar.us/docs/Live_Images_API) | 🙋 | 👍 |
34
+ | Content | 3 | [📚](http://developer.sportradar.us/docs/Content_API) | | 👍 |
35
+ | Images | 2 | [📚](http://developer.sportradar.us/docs/Images_API) | | 👍 |
36
+ | Live Images | 1 | [📚](http://developer.sportradar.us/docs/Live_Images_API) | | 👍 |
36
37
  | Olympics | 2 | [📚](http://developer.sportradar.us/docs/Olympics_API_v2) | - | - |
37
- | Soccer | 2 | [📚](http://developer.sportradar.us/docs/Soccer_API) | 🙋️ | 👍 |
38
+ | Soccer | 2 | [📚](http://developer.sportradar.us/docs/Soccer_API) | ✅️ | 👍 |
38
39
  | NCAAWB | 3 | [📚](http://developer.sportradar.us/docs/read/NCAA_Womens_Basketball) | - | - |
39
40
  | MMA | 1 | [📚](http://developer.sportradar.us/docs/MMA_API) | - | - |
40
41
  | Cricket | 1 | [📚](http://developer.sportradar.us/docs/cricket_API) | - | - |
@@ -44,6 +45,7 @@ Our goal is to incrementally integrate with them. **Contributions are welcome**
44
45
  | Rugby | 1 | [📚](http://developer.sportradar.us/docs/Rugby_API) | - | - |
45
46
  | Tennis | 1 | [📚](http://developer.sportradar.us/docs/Tennis_API) | - | - |
46
47
  | ESPORTS | 1 | [📚](http://developer.sportradar.us/docs/ESPORTS_API) | - | - |
48
+ | Simulation APIs | 1 | [📚](http://developer.sportradar.us/page/Live_Game_Simulation) | 🙋 | 👍|
47
49
 
48
50
  ## Installation
49
51
 
@@ -1,7 +1,7 @@
1
1
  module Sportradar
2
2
  module Api
3
3
  class Nfl < Request
4
- attr_accessor :league, :access_level
4
+ attr_accessor :league, :access_level, :simulation
5
5
 
6
6
  def initialize( access_level = "ot")
7
7
  @league = "nfl"
@@ -33,16 +33,19 @@ module Sportradar
33
33
  # past_game_id = "0141a0a5-13e5-4b28-b19f-0c3923aaef6e"
34
34
  # future_game_id = "28290722-4ceb-4a4c-a4e5-1f9bec7283b3"
35
35
  def game_boxscore(game_id)
36
+ check_simulation(game_id)
36
37
  response = get request_url("games/#{ game_id }/boxscore")
37
38
  Sportradar::Api::Nfl::Game.new response["game"] if response.success? && response["game"] # mostly done, just missing play statistics
38
39
  end
39
40
 
40
41
  def game_roster(game_id)
42
+ check_simulation(game_id)
41
43
  response = get request_url("games/#{ game_id }/roster")
42
44
  Sportradar::Api::Nfl::Game.new response["game"] if response.success? && response["game"]
43
45
  end
44
46
 
45
47
  def game_statistics(game_id)
48
+ check_simulation(game_id)
46
49
  response = get request_url("games/#{ game_id }/statistics")
47
50
  Sportradar::Api::Nfl::Game.new response["game"] if response.success? && response["game"]
48
51
  ## Need to properly implement statistics
@@ -89,10 +92,35 @@ module Sportradar
89
92
  Sportradar::Api::Nfl::Changelog.new response["league"]["changelog"] if response.success? && response["league"] && response["league"]["changelog"]
90
93
  end
91
94
 
95
+ def simulation_matches
96
+ [
97
+ "f45b4a31-b009-4039-8394-42efbc6d5532",
98
+ "5a7042cb-fe7a-4838-b93f-6b8c167ec384",
99
+ "7f761bb5-7963-43ea-a01b-baf4f5d50fe3"
100
+ ]
101
+ end
102
+
103
+ def active_simulation_match
104
+ game = simulation_matches.lazy.map {|game_id| game_boxscore game_id }.find{ |game| game.status == 'inprogress'}
105
+ if game
106
+ puts "Live Game: #{game.summary.home.full_name} vs #{game.summary.away.full_name}. Q#{game.quarter} #{game.clock}. game_id='#{game.id}'"
107
+ else
108
+ "No active simulation"
109
+ end
110
+ end
111
+
92
112
  private
93
113
 
114
+ def check_simulation(game_id)
115
+ @simulation = true if simulation_matches.include?(game_id)
116
+ end
117
+
94
118
  def request_url(path)
95
- "/nfl-#{access_level}#{version}/#{path}"
119
+ if simulation
120
+ "/nfl-sim1/#{path}"
121
+ else
122
+ "/nfl-#{access_level}#{version}/#{path}"
123
+ end
96
124
  end
97
125
 
98
126
  def api_key
@@ -30,8 +30,10 @@ module Sportradar
30
30
  @home = Sportradar::Api::Nfl::Team.new data["home"] if data["home"]
31
31
  @away = Sportradar::Api::Nfl::Team.new data["away"] if data["away"]
32
32
  @broadcast = Sportradar::Api::Nfl::Broadcast.new data["broadcast"] if data["broadcast"]
33
+ end
33
34
 
34
-
35
+ def current_score
36
+ "#{summary.home.points}-#{summary.away.points}" if summary
35
37
  end
36
38
 
37
39
  private
@@ -1,7 +1,7 @@
1
1
  module Sportradar
2
2
  module Api
3
3
  class Nfl::Team < Data
4
- attr_accessor :response, :id, :name, :alias, :game_number, :defense, :special_teams, :offense, :players, :statistics, :team_records, :player_records, :market, :franchise, :venue, :hierarchy, :coaches, :players
4
+ attr_accessor :response, :id, :name, :alias, :game_number, :defense, :special_teams, :offense, :players, :statistics, :team_records, :player_records, :market, :franchise, :venue, :hierarchy, :coaches, :players, :used_timeouts, :remaining_timeouts, :points
5
5
 
6
6
 
7
7
  def initialize(data)
@@ -11,6 +11,12 @@ module Sportradar
11
11
  @alias = data["alias"]
12
12
  @game_number = data["game_number"]
13
13
  @market = data["market"]
14
+
15
+ # These come from boxscore summary
16
+ @used_timeouts = data["used_timeouts"]
17
+ @remaining_timeouts = data["remaining_timeouts"]
18
+ @points = data["points"]
19
+
14
20
  @franchise = Sportradar::Api::Nfl::Franchise.new data["franchise"] if data["franchise"]
15
21
  @venue = Sportradar::Api::Nfl::Venue.new data["venue"] if data["venue"]
16
22
  @hierarchy = Sportradar::Api::Nfl::Hierarchy.new data["hierarchy"] if data["hierarchy"]
@@ -26,6 +32,10 @@ module Sportradar
26
32
  set_coaches
27
33
  end
28
34
 
35
+ def full_name
36
+ [market, name].join(' ')
37
+ end
38
+
29
39
  private
30
40
 
31
41
  def set_players
@@ -2,12 +2,11 @@ module Sportradar
2
2
  module Api
3
3
  class Soccer < Request
4
4
  attr_accessor :league, :access_level, :simulation
5
- def initialize(league = "na", access_level = "t", simulation = false)
5
+ def initialize(league = "na", access_level = "t")
6
6
  raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level
7
7
  raise Sportradar::Api::Error::InvalidLeague unless allowed_leagues.include? league
8
8
  @league = league
9
9
  @access_level = access_level
10
- @simulation = simulation
11
10
  end
12
11
 
13
12
  def schedule
@@ -34,12 +33,14 @@ module Sportradar
34
33
 
35
34
  # match_id = "357607e9-87cd-4848-b53e-0485d9c1a3bc"
36
35
  def match_summary(match_id)
36
+ check_simulation(match_id)
37
37
  response = get request_url("matches/#{match_id}/summary")
38
38
  Sportradar::Api::Soccer::Summary.new response
39
39
  end
40
40
 
41
41
  # match_id = "357607e9-87cd-4848-b53e-0485d9c1a3bc"
42
42
  def match_boxscore(match_id)
43
+ check_simulation(match_id)
43
44
  response = get request_url("matches/#{match_id}/boxscore")
44
45
  Sportradar::Api::Soccer::Boxscore.new response
45
46
  end
@@ -77,6 +78,10 @@ module Sportradar
77
78
 
78
79
  private
79
80
 
81
+ def check_simulation(match_id)
82
+ @simulation = true if match_id == simulation_match
83
+ end
84
+
80
85
  def request_url(path)
81
86
  if simulation
82
87
  "/soccer-sim2/wc/#{path}"
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.1.25"
3
+ VERSION = "0.1.26"
4
4
  end
5
5
  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.1.25
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-11 00:00:00.000000000 Z
11
+ date: 2016-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler