sportradar-api 0.1.30 → 0.1.31
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 +2 -3
- data/README.md +12 -1
- data/lib/sportradar/api/nfl.rb +2 -1
- data/lib/sportradar/api/nfl/drive.rb +6 -0
- data/lib/sportradar/api/nfl/game.rb +12 -2
- data/lib/sportradar/api/nfl/play.rb +6 -1
- data/lib/sportradar/api/nfl/quarter.rb +4 -1
- data/lib/sportradar/api/nfl/scoring.rb +2 -1
- data/lib/sportradar/api/nfl/situation.rb +2 -1
- data/lib/sportradar/api/nfl/team.rb +2 -0
- data/lib/sportradar/api/version.rb +1 -1
- data/sportradar-api.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7e34ad09b3d05807d2b9bf75d587a084ae25587a
|
|
4
|
+
data.tar.gz: d074596c83b54498bff4637929195e313c7cc9df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 65b65aa2b214da9debe20d0daaadb58320f85a06fd5470d52a278d301145dd18c6c7db880c8d3c11cd7fba6ceceba35eed4e35d379208a0ed9e2af95b3890a36
|
|
7
|
+
data.tar.gz: 11fdc889e4ccbccf3b76055b79262323af2272a5aed9c8926b133458d03a464dfc173bd52a68ac54d08220edb1603b816ec70a67796fdb7f332ec20c1a1e21de
|
data/Gemfile.lock
CHANGED
|
@@ -3,7 +3,7 @@ PATH
|
|
|
3
3
|
specs:
|
|
4
4
|
sportradar-api (0.1.30)
|
|
5
5
|
activesupport
|
|
6
|
-
httparty (>= 0.
|
|
6
|
+
httparty (>= 0.14.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
@@ -42,8 +42,7 @@ GEM
|
|
|
42
42
|
guard-compat (~> 1.2)
|
|
43
43
|
minitest (>= 3.0)
|
|
44
44
|
hashdiff (0.3.0)
|
|
45
|
-
httparty (0.
|
|
46
|
-
json (~> 1.8)
|
|
45
|
+
httparty (0.14.0)
|
|
47
46
|
multi_xml (>= 0.5.2)
|
|
48
47
|
i18n (0.7.0)
|
|
49
48
|
json (1.8.3)
|
data/README.md
CHANGED
|
@@ -76,7 +76,7 @@ Create `.env` for environment variables. Follow the `.env.sample` for guidance.
|
|
|
76
76
|
|
|
77
77
|
http://developer.sportradar.us/page/Live_Game_Simulation
|
|
78
78
|
|
|
79
|
-
Soccer
|
|
79
|
+
### Soccer
|
|
80
80
|
|
|
81
81
|
```
|
|
82
82
|
sim = Sportradar::Api::Soccer.new('na', 't', true)
|
|
@@ -84,6 +84,17 @@ summary = sim.match_summary(sim.simulation_match)
|
|
|
84
84
|
boxscore = sim.match_boxscore(sim.simulation_match)
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
+
### NFL
|
|
88
|
+
|
|
89
|
+
It's possible to find the current simulation game:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
Sportradar::Api::Nfl.new('o').active_simulation
|
|
93
|
+
=>
|
|
94
|
+
https://api.sportradar.us/nfl-sim1/games/f45b4a31-b009-4039-8394-42efbc6d5532/boxscore.xml
|
|
95
|
+
Live Game: Green Bay Packers vs Minnesota Vikings. Q2 00:08. game_id='f45b4a31-b009-4039-8394-42efbc6d5532'
|
|
96
|
+
```
|
|
97
|
+
|
|
87
98
|
## Development
|
|
88
99
|
|
|
89
100
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/sportradar/api/nfl.rb
CHANGED
|
@@ -105,8 +105,9 @@ module Sportradar
|
|
|
105
105
|
game = simulation_games.lazy.map {|game_id| game_boxscore game_id }.find{ |game| game.status == 'inprogress'}
|
|
106
106
|
if game
|
|
107
107
|
puts "Live Game: #{game.summary.home.full_name} vs #{game.summary.away.full_name}. Q#{game.quarter} #{game.clock}. game_id='#{game.id}'"
|
|
108
|
+
game
|
|
108
109
|
else
|
|
109
|
-
"No active simulation"
|
|
110
|
+
puts "No active simulation"
|
|
110
111
|
end
|
|
111
112
|
end
|
|
112
113
|
|
|
@@ -30,6 +30,12 @@ module Sportradar
|
|
|
30
30
|
elsif response["plays"]["play"].is_a?(Hash)
|
|
31
31
|
@plays = [ Sportradar::Api::Nfl::Play.new(response["plays"]["play"]) ]
|
|
32
32
|
end
|
|
33
|
+
elsif response["play"]
|
|
34
|
+
if response["play"].is_a?(Array)
|
|
35
|
+
@plays = response["play"].map {|play| Sportradar::Api::Nfl::Play.new play }
|
|
36
|
+
elsif response["play"].is_a?(Hash)
|
|
37
|
+
@plays = [ Sportradar::Api::Nfl::Play.new(response["play"]) ]
|
|
38
|
+
end
|
|
33
39
|
end
|
|
34
40
|
end
|
|
35
41
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Sportradar
|
|
2
2
|
module Api
|
|
3
3
|
class Nfl::Game < Data
|
|
4
|
-
attr_accessor :response, :id, :status, :reference, :number, :scheduled, :entry_mode, :venue, :home, :away, :broadcast, :number, :attendance, :utc_offset, :weather, :clock, :quarter, :summary, :situation, :last_event, :scoring, :scoring_drives
|
|
4
|
+
attr_accessor :response, :id, :status, :reference, :number, :scheduled, :entry_mode, :venue, :home, :away, :broadcast, :number, :attendance, :utc_offset, :weather, :clock, :quarter, :summary, :situation, :last_event, :scoring, :scoring_drives, :quarters
|
|
5
5
|
|
|
6
6
|
def initialize(data)
|
|
7
7
|
@response = data
|
|
@@ -19,7 +19,11 @@ module Sportradar
|
|
|
19
19
|
@utc_offset = data["utc_offset"]
|
|
20
20
|
@weather = data["weather"]
|
|
21
21
|
@clock = data["clock"]
|
|
22
|
-
|
|
22
|
+
if data["quarter"]
|
|
23
|
+
@quarter = data["quarter"][0]
|
|
24
|
+
quarter_data = data["quarter"][1].is_a?(Hash) ? [ data["quarter"][1] ] : data["quarter"][1]
|
|
25
|
+
@quarters = quarter_data&.map { |hash| Sportradar::Api::Nfl::Quarter.new(hash) }
|
|
26
|
+
end
|
|
23
27
|
@summary = Sportradar::Api::Nfl::Summary.new data["summary"] if data["summary"]
|
|
24
28
|
@situation = Sportradar::Api::Nfl::Situation.new data["situation"] if data["situation"]
|
|
25
29
|
@last_event = Sportradar::Api::Nfl::Event.new data["last_event"]["event"] if data["last_event"] && data["last_event"]["event"]
|
|
@@ -36,6 +40,12 @@ module Sportradar
|
|
|
36
40
|
def current_score
|
|
37
41
|
"#{summary.home.points}-#{summary.away.points}" if summary
|
|
38
42
|
end
|
|
43
|
+
def drives
|
|
44
|
+
quarters&.flat_map(&:drives)
|
|
45
|
+
end
|
|
46
|
+
def plays
|
|
47
|
+
drives&.flat_map(&:plays)
|
|
48
|
+
end
|
|
39
49
|
|
|
40
50
|
private
|
|
41
51
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Sportradar
|
|
2
2
|
module Api
|
|
3
3
|
class Nfl::Play < Data
|
|
4
|
-
attr_accessor :response, :id, :sequence, :reference, :clock, :home_points, :away_points, :type, :play_clock, :wall_clock, :start_situation, :end_situation, :description, :alt_description, :statistics, :score, :scoring_play
|
|
4
|
+
attr_accessor :response, :id, :sequence, :reference, :clock, :home_points, :away_points, :type, :play_clock, :wall_clock, :start_situation, :end_situation, :description, :alt_description, :statistics, :score, :scoring_play, :team_id, :player_id
|
|
5
5
|
|
|
6
6
|
def initialize(data)
|
|
7
7
|
@response = data
|
|
@@ -10,6 +10,7 @@ module Sportradar
|
|
|
10
10
|
@clock = data["clock"]
|
|
11
11
|
@description = data["description"]
|
|
12
12
|
@end_situation = Sportradar::Api::Nfl::Situation.new data["end_situation"] if data["end_situation"]
|
|
13
|
+
@team_id = end_situation.team_id if end_situation
|
|
13
14
|
@home_points = data["home_points"]
|
|
14
15
|
@id = data["id"]
|
|
15
16
|
@play_clock = data["play_clock"]
|
|
@@ -19,6 +20,10 @@ module Sportradar
|
|
|
19
20
|
@sequence = data["sequence"]
|
|
20
21
|
@start_situation = Sportradar::Api::Nfl::Situation.new data["start_situation"] if data["start_situation"]
|
|
21
22
|
@statistics = OpenStruct.new data["statistics"] if data["statistics"] # TODO Implement statistics?
|
|
23
|
+
if @statistics
|
|
24
|
+
play_stats = @statistics.penalty || @statistics.rush || @statistics.return || @statistics.receive
|
|
25
|
+
@player_id = play_stats.dig('player', 'id') if play_stats
|
|
26
|
+
end
|
|
22
27
|
@type = data["type"]
|
|
23
28
|
@wall_clock = data["wall_clock"]
|
|
24
29
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Sportradar
|
|
2
2
|
module Api
|
|
3
3
|
class Nfl::Quarter < Data
|
|
4
|
-
attr_accessor :response, :id, :number, :sequence, :home_points, :away_points
|
|
4
|
+
attr_accessor :response, :id, :number, :sequence, :home_points, :away_points, :drives
|
|
5
5
|
|
|
6
6
|
def initialize(data)
|
|
7
7
|
@response = data
|
|
@@ -9,7 +9,10 @@ module Sportradar
|
|
|
9
9
|
@number = data["number"]
|
|
10
10
|
@sequence = data["sequence"]
|
|
11
11
|
@home_points = data["home_points"]
|
|
12
|
+
# @home_points = response['scoring']['home']['points'] # from play_by_play
|
|
12
13
|
@away_points = data["away_points"]
|
|
14
|
+
# @away_points = response['scoring']['away']['points'] # from play_by_play
|
|
15
|
+
@drives = data.dig("play_by_play", 'drive')&.map{ |drive| Sportradar::Api::Nfl::Drive.new drive }
|
|
13
16
|
end
|
|
14
17
|
|
|
15
18
|
end
|
|
@@ -5,7 +5,8 @@ module Sportradar
|
|
|
5
5
|
|
|
6
6
|
def initialize(data)
|
|
7
7
|
@response = data
|
|
8
|
-
@quarters = data['quarter'].map { |quarter| Sportradar::Api::Nfl::Quarter.new quarter} if data['quarter']
|
|
8
|
+
# @quarters = data['quarter'].map { |quarter| Sportradar::Api::Nfl::Quarter.new quarter} if data['quarter']
|
|
9
|
+
# this is causing a problem in some scenarios, receiving ['1', 'id-hash']
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def final
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Sportradar
|
|
2
2
|
module Api
|
|
3
3
|
class Nfl::Situation < Data
|
|
4
|
-
attr_accessor :response, :clock, :down, :yfd, :possession, :location
|
|
4
|
+
attr_accessor :response, :clock, :down, :yfd, :possession, :location, :team_id
|
|
5
5
|
|
|
6
6
|
def initialize(data)
|
|
7
7
|
@response = data
|
|
@@ -10,6 +10,7 @@ module Sportradar
|
|
|
10
10
|
@yfd = data["yfd"]
|
|
11
11
|
@possession = OpenStruct.new data["possession"] if data["possession"]
|
|
12
12
|
@location = OpenStruct.new data["location"] if data["location"]
|
|
13
|
+
@team_id = possession.id if possession
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
end
|
|
@@ -3,6 +3,8 @@ module Sportradar
|
|
|
3
3
|
class Nfl::Team < Data
|
|
4
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, :wins, :losses, :ties, :win_pct, :rank
|
|
5
5
|
|
|
6
|
+
alias :score :points
|
|
7
|
+
|
|
6
8
|
def initialize(data)
|
|
7
9
|
@response = data
|
|
8
10
|
@id = data["id"]
|
data/sportradar-api.gemspec
CHANGED
|
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
|
38
38
|
spec.add_development_dependency "simplecov"
|
|
39
39
|
spec.add_development_dependency "minitest-focus"
|
|
40
40
|
spec.add_development_dependency "dotenv"
|
|
41
|
-
spec.add_dependency "httparty", ">= 0.
|
|
41
|
+
spec.add_dependency "httparty", ">= 0.14.0"
|
|
42
42
|
spec.add_dependency "activesupport"
|
|
43
43
|
|
|
44
44
|
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.
|
|
4
|
+
version: 0.1.31
|
|
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
|
+
date: 2016-08-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -184,14 +184,14 @@ dependencies:
|
|
|
184
184
|
requirements:
|
|
185
185
|
- - ">="
|
|
186
186
|
- !ruby/object:Gem::Version
|
|
187
|
-
version: 0.
|
|
187
|
+
version: 0.14.0
|
|
188
188
|
type: :runtime
|
|
189
189
|
prerelease: false
|
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
|
191
191
|
requirements:
|
|
192
192
|
- - ">="
|
|
193
193
|
- !ruby/object:Gem::Version
|
|
194
|
-
version: 0.
|
|
194
|
+
version: 0.14.0
|
|
195
195
|
- !ruby/object:Gem::Dependency
|
|
196
196
|
name: activesupport
|
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -307,3 +307,4 @@ signing_key:
|
|
|
307
307
|
specification_version: 4
|
|
308
308
|
summary: Sportradar API client
|
|
309
309
|
test_files: []
|
|
310
|
+
has_rdoc:
|