sportradar-api 0.10.5 → 0.10.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68dd35e2be4d4e5d3c95d5cebdc12080dcf6a554
4
- data.tar.gz: c97663e4dc043c89347da0de558cf44926b0ac45
3
+ metadata.gz: b22a0a7a406d1e9334db57e47c9f22cc1d722441
4
+ data.tar.gz: b46dfcead44339f9d5c37b6eb947f7d661ef4015
5
5
  SHA512:
6
- metadata.gz: e67f0c4d7e60601eaa9c040ff11081b5c0714c93a747e9cbfa36a84f7c4acbfd46aa90ff8cf79cfa259665c987e9d3f2364170869419e10158c327740b575802
7
- data.tar.gz: 224af3b46e774b33269f9cfa42e1c64ccc06fdda45790d8a395c83091504b2b1ff0533099d17d47e637566d0e90e88998457b5c26921e3eecb4d890973e093c3
6
+ metadata.gz: 0121db5a08f0f80fe5df0bb73abc15cea485150f69e492d17621ca5624c42e917a0bcf1523c1307bc48c8dfc3ad80c6da07cfc140445b7cd25e3416ffe1f6155
7
+ data.tar.gz: ca20ff2d455c33c9e108208dbf39ac417d411844c2fb7028cb00bfaf0d15ae2fbd408ce27878b55008bd1c83af824836a71aa7dd8b6552c4e22517ef0bce0183
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportradar-api (0.10.5)
4
+ sportradar-api (0.10.7)
5
5
  activesupport
6
6
  httparty (>= 0.14.0)
7
7
 
@@ -17,7 +17,7 @@ GEM
17
17
  codeclimate-test-reporter (0.6.0)
18
18
  simplecov (>= 0.7.1, < 1.0.0)
19
19
  coderay (1.1.1)
20
- concurrent-ruby (1.0.4)
20
+ concurrent-ruby (1.0.5)
21
21
  coveralls (0.8.15)
22
22
  json (>= 1.8, < 3)
23
23
  simplecov (~> 0.12.0)
@@ -118,6 +118,25 @@ module Sportradar
118
118
  @teams_hash[@away_id] || @away
119
119
  end
120
120
 
121
+ def leading_team_id
122
+ return nil if score.values.uniq.size == 1
123
+ score.max_by(&:last).first
124
+ end
125
+ def leading_team
126
+ @teams_hash[leading_team_id] || (@away_id == leading_team_id && away) || (@home_id == leading_team_id && home)
127
+ end
128
+ def team(team_id)
129
+ @teams_hash[team_id]
130
+ end
131
+ def assign_home(team)
132
+ @home_id = team.id
133
+ @teams_hash[team.id] = team
134
+ end
135
+ def assign_away(team)
136
+ @away_id = team.id
137
+ @teams_hash[team.id] = team
138
+ end
139
+
121
140
  def box
122
141
  @box ||= get_box
123
142
  end
@@ -16,9 +16,11 @@ module Sportradar
16
16
  @year = data.dig('season', 'year')
17
17
  @type = data.dig('season', 'type')
18
18
 
19
- @games_hash = {}
19
+ @games_hash = {}
20
+ @series_hash = {}
20
21
 
21
- update_games(data['games'])
22
+ update_games(data['games']) if data['games']
23
+ update_series(data['series']) if data['series']
22
24
  end
23
25
 
24
26
  def games
@@ -29,6 +31,14 @@ module Sportradar
29
31
  create_data(@games_hash, data, klass: Game, api: @api, season: self)
30
32
  end
31
33
 
34
+ def series
35
+ @series_hash.values
36
+ end
37
+
38
+ def update_series(data)
39
+ create_data(@series_hash, data, klass: Series, api: @api, season: self)
40
+ end
41
+
32
42
  end
33
43
  end
34
44
  end
@@ -0,0 +1,59 @@
1
+ module Sportradar
2
+ module Api
3
+ module Basketball
4
+ class Nba
5
+ class Series < Basketball::Season
6
+ attr_accessor :response, :id, :status, :title, :round, :start_date
7
+ alias :name :title
8
+
9
+ def initialize(data, **opts)
10
+ @response = data
11
+ @api = opts[:api]
12
+
13
+ @id = data['id']
14
+ @games_hash = {}
15
+ @participants_hash = {}
16
+
17
+ update(data, **opts)
18
+ end
19
+
20
+ def update(data, **opts)
21
+ @title = data['title'] if data['title']
22
+ @round = data['round'] if data['round']
23
+ @status = data['status'] if data['status']
24
+ @start_date = data['start_date'] if data['start_date']
25
+
26
+
27
+ update_games(data['games']) if data['games']
28
+ update_participantss(data['participantss']) if data['participantss']
29
+ end
30
+
31
+ def games
32
+ @games_hash.values
33
+ end
34
+
35
+ def update_games(data)
36
+ create_data(@games_hash, data, klass: Game, api: @api, series: self)
37
+ end
38
+
39
+ def participants
40
+ @participants_hash.values
41
+ end
42
+
43
+ def update_participants(data)
44
+ create_data(@participants_hash, data, klass: Team, api: @api, series: self)
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ __END__
54
+
55
+ sd = sr.daily_schedule;
56
+ sr = Sportradar::Api::Basketball::Nba.new
57
+ ss = sr.standings;
58
+ ss = sr.schedule;
59
+ ss = sr.schedule(2015, 'pst)');
@@ -29,6 +29,15 @@ module Sportradar
29
29
  end
30
30
  end
31
31
 
32
+ def series_schedule(season_year = default_year)
33
+ response = get request_url("series/#{season_year}/pst/schedule")
34
+ if response.success?
35
+ Sportradar::Api::Basketball::Nba::Season.new(response.to_h, api: self)
36
+ else
37
+ @error = response
38
+ end
39
+ end
40
+
32
41
  def league_hierarchy
33
42
  response = get request_url("league/hierarchy")
34
43
  if response.success?
@@ -13,6 +13,7 @@ require_relative 'basketball/nba/hierarchy'
13
13
  require_relative 'basketball/nba/conference'
14
14
  require_relative 'basketball/nba/division'
15
15
  require_relative 'basketball/nba/season'
16
+ require_relative 'basketball/nba/series'
16
17
  require_relative 'basketball/nba/schedule'
17
18
  require_relative 'basketball/nba/game'
18
19
  require_relative 'basketball/nba/team'
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.10.5"
3
+ VERSION = "0.10.7"
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.10.5
4
+ version: 0.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-28 00:00:00.000000000 Z
11
+ date: 2017-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -254,6 +254,7 @@ files:
254
254
  - lib/sportradar/api/basketball/nba/schedule.rb
255
255
  - lib/sportradar/api/basketball/nba/scoring.rb
256
256
  - lib/sportradar/api/basketball/nba/season.rb
257
+ - lib/sportradar/api/basketball/nba/series.rb
257
258
  - lib/sportradar/api/basketball/nba/team.rb
258
259
  - lib/sportradar/api/basketball/ncaamb.rb
259
260
  - lib/sportradar/api/basketball/ncaamb/bracket.rb