sportradar-api 0.11.0 → 0.11.1

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: 8dc1a28470e8251e6d07c0a558e1fd4c9477cbb2
4
- data.tar.gz: b8b597bd550858c7a6ed853e49eb4be966b0ca06
3
+ metadata.gz: 16cb3b28febfcd41fd83739b56120b115bee1c41
4
+ data.tar.gz: 7105f0331b5807f152f920e9fb2322880ba7f567
5
5
  SHA512:
6
- metadata.gz: a939bf7829663306244b1fc49d6be654d6b94a80323c3c0f52d2faa8b94a7ab96df47968e57e3868c86444aeaa09b40cec734517596f7b3a589ef374e74fb142
7
- data.tar.gz: 40ae8b1e37e659dc5dfcacef0a110cab3ff81cf0ba664d8634e178bb3d489fb0f5398f94b38d7e0458e36de66ce16e3def548171cdf4e87a987d40ec207b6466
6
+ metadata.gz: 4c9e3b04058b82c88fd4b4fd67ec1698c71f4d8df0489f2b03c7231768b8be869a2878f8b3cdfc307c16f676e420d864ff2fc45658237578c7abcdad4d83e1dd
7
+ data.tar.gz: aa210eb3b481ad666f9277f665f4cd762ea0db1748ccfd6cd1ccdf5098b3601dd265e861a232fa5e51f7df1b9ec99c4bcad6d32c9ab543e896bab9eaf8d46660
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportradar-api (0.11.0)
4
+ sportradar-api (0.11.1)
5
5
  activesupport
6
6
  httparty (>= 0.14.0)
7
7
 
@@ -114,4 +114,4 @@ DEPENDENCIES
114
114
  webmock
115
115
 
116
116
  BUNDLED WITH
117
- 1.15.1
117
+ 1.15.3
data/README.md CHANGED
@@ -91,11 +91,13 @@ boxscore = sim.match_boxscore(sim.simulation_match)
91
91
  It's possible to use simulation games from Sportradar. This allows you to see what data looks like during a game (including non game APIs), useful for development during the offseason.
92
92
 
93
93
  ```
94
- Sportradar::Api::Football::Nfl.simulations # => returns array of simulation games. Only 1 is inprogress at a time
95
- Sportradar::Api::Football::Nfl.simulation # => returns Sportradar::Api::Football::Nfl instance with a sim api. useful for mid season stats, standings, etc
94
+ sims = Sportradar::Api::Football::Nfl.simulations # => returns array of simulation games. Only 1 is inprogress at a time
95
+ sims.each(&:get_pbp).detect(&:started?)
96
+ nfl = Sportradar::Api::Football::Nfl.simulation # => returns Sportradar::Api::Football::Nfl instance with a sim api. useful for mid season stats, standings, etc
96
97
 
97
- Sportradar::Api::Football::Ncaafb.simulations # => returns array of simulation games. Only 1 is inprogress at a time
98
- Sportradar::Api::Football::Ncaafb.simulation # => returns Sportradar::Api::Football::Ncaafb instance with a sim api. useful for mid season stats, standings, etc
98
+ sims = Sportradar::Api::Football::Ncaafb.simulations # => returns array of simulation games. Only 1 is inprogress at a time
99
+ sims.each(&:get_pbp).detect(&:started?)
100
+ ncaafb = Sportradar::Api::Football::Ncaafb.simulation # => returns Sportradar::Api::Football::Ncaafb instance with a sim api. useful for mid season stats, standings, etc
99
101
  ```
100
102
 
101
103
  ## Development
@@ -100,7 +100,7 @@ module Sportradar
100
100
  end
101
101
 
102
102
  def self.api_key(api, access_level = 'trial')
103
- ENV.fetch("SPORTRADAR_#{api.to_s.upcase.gsub('-', '_')}#{'_PRODUCTION' if access_level == 'production'}", "api_key missing for #{api}")
103
+ ENV.fetch("SPORTRADAR_#{api.to_s.upcase.gsub('-', '_')}#{"_#{access_level.upcase}" if access_level != 'trial'}", "api_key missing for #{api}")
104
104
  end
105
105
 
106
106
  def self.version(api)
@@ -1,3 +1,28 @@
1
1
  # Sportradar Baseball
2
2
 
3
3
  ![API Reference](http://developer.sportradar.com/files/MLBv6SVG.svg)
4
+
5
+ *Currently, only MLB is supported.*
6
+
7
+ ## MLB
8
+
9
+ Get started with official MLB api v6:
10
+
11
+ ```ruby
12
+ mlb = Sportradar::Api::Baseball::Mlb::Hierarchy.new
13
+ res = mlb.get_daily_summary # => res is the raw response from Sportradar. `mlb` now has game summaries to interact with
14
+ res = mlb.get_hierarchy # => res is the raw response from Sportradar. `mlb` now has leagues/divisions/teams to interact with
15
+ mlb.leagues.count # => 2
16
+ mlb.divisions.count # => 6
17
+ mlb.teams.count # => 30
18
+ res = mlb.get_schedule # => res is the raw response from Sportradar. `mlb` now has games to interact with
19
+ mlb.games.count # => 2430
20
+
21
+ game = mlb.games.sample # => Sportradar::Api::Baseball::Game
22
+ data = game.get_pbp # => data is raw response from Sportradar. `game` now has innings/half innings/atbats/pitches to interact with
23
+ game.innings.count # => 10 (Sportradar has an inning #0, representing starting lineups)
24
+ game.half_innings.count # => 20 (if the game went the full 9 innings)
25
+ data = game.get_summary # => data is raw response from Sportradar. `game` now statistical information to interact with
26
+ game.count # `count` contains information about the current game state, such as balls/strikes to current batter, current inning, and outs
27
+ ```
28
+
@@ -431,6 +431,12 @@ module Sportradar
431
431
  def api
432
432
  @api || Sportradar::Api::Baseball::Mlb.new
433
433
  end
434
+
435
+ def sim!
436
+ @api = api.sim!
437
+ self
438
+ end
439
+
434
440
  end
435
441
  end
436
442
  end
@@ -10,6 +10,11 @@ module Sportradar
10
10
  @access_level = access_level
11
11
  end
12
12
 
13
+ def sim!
14
+ @version = 5
15
+ super
16
+ end
17
+
13
18
  def get_data(url)
14
19
  data = get request_url(url)
15
20
  if data.is_a?(Sportradar::Api::Error)
@@ -38,16 +43,6 @@ module Sportradar
38
43
  end
39
44
  end
40
45
 
41
- def league_hierarchy
42
- response = get request_url("league/hierarchy")
43
- if response.success?
44
- Sportradar::Api::Baseball::Mlb::Hierarchy.new(response.to_h, api: self)
45
- else
46
- response
47
- end
48
- end
49
- alias :hierarchy :league_hierarchy
50
-
51
46
  def content_format
52
47
  'json'
53
48
  end
@@ -59,19 +54,21 @@ module Sportradar
59
54
  end
60
55
 
61
56
  def api_key
62
- if access_level != 't'
57
+ if !['t', 'sim'].include?(access_level)
63
58
  Sportradar::Api.api_key_params('mlb', 'production')
59
+ elsif 'sim' == access_level
60
+ Sportradar::Api.api_key_params('mlb', 'simulation')
64
61
  else
65
62
  Sportradar::Api.api_key_params('mlb')
66
63
  end
67
64
  end
68
65
 
69
66
  def version
70
- Sportradar::Api.version('mlb')
67
+ @version || Sportradar::Api.version('mlb')
71
68
  end
72
69
 
73
70
  def allowed_access_levels
74
- %w[p t]
71
+ %w[p t sim]
75
72
  end
76
73
 
77
74
  def allowed_seasons
@@ -197,6 +197,35 @@ module Sportradar
197
197
  end
198
198
 
199
199
  # status helpers
200
+ def realtime_state
201
+ if future?
202
+ 'Scheduled'
203
+ elsif finished?
204
+ 'Final'
205
+ elsif postponed?
206
+ 'Postponed'
207
+ # elsif halftime?
208
+ # 'Halftime'
209
+ else
210
+ clock_display
211
+ end
212
+ end
213
+
214
+ def clock_display
215
+ if clock && period
216
+ "#{clock} #{period_display}"
217
+ end
218
+ end
219
+ def period_display
220
+ if period > 5
221
+ "#{period - 4}OT"
222
+ elsif period == 5
223
+ 'OT'
224
+ else
225
+ "Q#{period}"
226
+ end
227
+ end
228
+
200
229
  def postponed?
201
230
  'postponed' == status
202
231
  end
@@ -263,7 +292,7 @@ module Sportradar
263
292
  end
264
293
  set_pbp(period_data)
265
294
  @pbp = @periods_hash.values
266
- check_newness(:pbp, plays.last)
295
+ check_newness(:pbp, plays.last&.updated)
267
296
  check_newness(:score, @score)
268
297
  data
269
298
  end
@@ -98,7 +98,7 @@ module Sportradar
98
98
  end
99
99
 
100
100
  def api_key
101
- if access_level != 't'
101
+ if !['t', 'sim'].include?(access_level)
102
102
  Sportradar::Api.api_key_params('nba', 'production')
103
103
  else
104
104
  Sportradar::Api.api_key_params('nba')
@@ -110,7 +110,7 @@ module Sportradar
110
110
  end
111
111
 
112
112
  def allowed_access_levels
113
- %w[p t]
113
+ %w[p t sim]
114
114
  end
115
115
 
116
116
  def allowed_seasons
@@ -23,6 +23,11 @@ module Sportradar
23
23
  @api || Sportradar::Api::Basketball::Nba.new
24
24
  end
25
25
 
26
+ def sim!
27
+ @api = api.sim!
28
+ self
29
+ end
30
+
26
31
  end
27
32
  end
28
33
  end
@@ -112,7 +112,7 @@ module Sportradar
112
112
  end
113
113
 
114
114
  def api_key
115
- if access_level != 't'
115
+ if !['t', 'sim'].include?(access_level)
116
116
  Sportradar::Api.api_key_params('ncaamb', 'production')
117
117
  else
118
118
  Sportradar::Api.api_key_params('ncaamb')
@@ -124,7 +124,7 @@ module Sportradar
124
124
  end
125
125
 
126
126
  def allowed_access_levels
127
- %w[p t]
127
+ %w[p t sim]
128
128
  end
129
129
 
130
130
  def allowed_seasons
@@ -6,6 +6,16 @@ module Sportradar
6
6
 
7
7
  # NCAA MB specific
8
8
 
9
+ def period_display
10
+ if period > 5
11
+ "#{period - 4}OT"
12
+ elsif period == 5
13
+ 'OT'
14
+ else
15
+ "Q#{period}"
16
+ end
17
+ end
18
+
9
19
  def team_class
10
20
  Team
11
21
  end
@@ -23,6 +33,11 @@ module Sportradar
23
33
  @api || Sportradar::Api::Basketball::Ncaamb.new
24
34
  end
25
35
 
36
+ def sim!
37
+ @api = api.sim!
38
+ self
39
+ end
40
+
26
41
  end
27
42
  end
28
43
  end
@@ -20,13 +20,13 @@ module Sportradar
20
20
  @api_key = ENV['API_KEY']
21
21
  @api_timeout = ENV.fetch('SPORTRADAR_API_TIMEOUT', 15 )
22
22
  @use_ssl = ENV.fetch('SPORTRADAR_API_USE_SSL', true)
23
- @format = ENV.fetch("SPORTRADAR_API_FORMAT", :xml).to_s
23
+ @format = ENV.fetch("SPORTRADAR_API_FORMAT", :json).to_s
24
24
  end
25
25
 
26
26
  def reset
27
27
  @api_timeout = ENV.fetch('SPORTRADAR_API_TIMEOUT', 15 )
28
28
  @use_ssl = ENV.fetch('SPORTRADAR_API_USE_SSL', true)
29
- @format = ENV.fetch("SPORTRADAR_API_FORMAT", :xml).to_s
29
+ @format = ENV.fetch("SPORTRADAR_API_FORMAT", :json).to_s
30
30
  end
31
31
  end
32
32
  end
@@ -13,7 +13,6 @@ module Sportradar
13
13
  end
14
14
 
15
15
  def initialize(data, **opts)
16
- @response = data
17
16
  @id = data["id"]
18
17
  @api = opts[:api]
19
18
  @plays_hash = {}
@@ -23,6 +22,7 @@ module Sportradar
23
22
  end
24
23
 
25
24
  def update(data, **opts)
25
+ @response = data
26
26
  @type = data['type']
27
27
  @team = data['team']
28
28
  @clock = data['clock']
@@ -53,6 +53,10 @@ module Sportradar
53
53
  @events_hash.values
54
54
  end
55
55
 
56
+ def over?
57
+ !!@end_reason
58
+ end
59
+
56
60
  def end_reason_possibilities
57
61
  [
58
62
  'UNKNOWN',
@@ -26,6 +26,9 @@ module Sportradar
26
26
  def events
27
27
  [self]
28
28
  end
29
+ def over?
30
+ false # TODO
31
+ end
29
32
  end
30
33
 
31
34
  end
@@ -32,6 +32,10 @@ module Sportradar
32
32
  {}
33
33
  end
34
34
 
35
+ def period
36
+ quarter
37
+ end
38
+
35
39
  def summary_stat(team_id, stat_name)
36
40
  scoring.dig(team_id, stat_name)
37
41
  end
@@ -89,7 +93,7 @@ module Sportradar
89
93
 
90
94
  # @links = data['links'] ? structure_links(data['links']) : {}
91
95
 
92
- @teams_hash = { @home.id => @home, @away.id => @away } if @home && @away
96
+ @teams_hash = { @home.id => @home, @away.id => @away } if @home.id && @away.id
93
97
  @team_ids = { home: (@home&.id || home_alias), away: (@away&.id || away_alias) }
94
98
 
95
99
  @scoring_raw.update(data, source: source)
@@ -114,8 +118,14 @@ module Sportradar
114
118
  else
115
119
  @home.update(data['home_team'], game: self) if data['home_team'].is_a?(Hash)
116
120
  @away.update(data['away_team'], game: self) if data['away_team'].is_a?(Hash)
117
- @home_alias = data['home'] if data['home'].is_a?(String) # this might actually be team ID and not alias. check in NFL
118
- @away_alias = data['away'] if data['away'].is_a?(String) # this might actually be team ID and not alias. check in NFL
121
+ if data['home'].is_a?(String) # this might actually be team ID and not alias. check in NFL
122
+ @home_alias = data['home']
123
+ @home.id ||= @home_alias
124
+ end
125
+ if data['away'].is_a?(String) # this might actually be team ID and not alias. check in NFL
126
+ @away_alias = data['away']
127
+ @away.id ||= @away_alias
128
+ end
119
129
  end
120
130
  end
121
131
 
@@ -383,6 +393,11 @@ module Sportradar
383
393
  Team
384
394
  end
385
395
 
396
+ def sim!
397
+ @api = api.sim!
398
+ self
399
+ end
400
+
386
401
  end
387
402
  end
388
403
  end
@@ -56,7 +56,7 @@ module Sportradar
56
56
  divisions_by_name[code_name]
57
57
  end
58
58
  private def divisions_by_name
59
- @divisions_by_name ||= divisions.map { |d| [d.alias, d] }.to_h
59
+ @divisions_by_name ||= divisions.map { |d| [d.id, d] }.to_h
60
60
  end
61
61
  def conferences
62
62
  divisions.flat_map(&:conferences)
@@ -178,8 +178,8 @@ module Sportradar
178
178
  end
179
179
 
180
180
  ## hierarchy
181
- def get_hierarchy
182
- data = api.get_data(path_hierarchy).to_h
181
+ def get_hierarchy(division = 'FBS')
182
+ data = api.get_data(path_hierarchy(division)).to_h
183
183
  ingest_hierarchy(data)
184
184
  end
185
185
 
@@ -216,7 +216,7 @@ module Sportradar
216
216
  end
217
217
 
218
218
  def ingest_standings(data)
219
- update(data.dig('league','season'), source: :teams)
219
+ update(data, source: :teams)
220
220
  data
221
221
  end
222
222
 
@@ -244,7 +244,7 @@ module Sportradar
244
244
  # end
245
245
 
246
246
  def self.sim_api
247
- Sportradar::Api::Football::Ncaafb::Api.new('sim-t')
247
+ Sportradar::Api::Football::Ncaafb::Api.new.sim!
248
248
  end
249
249
  def self.simulation
250
250
  new({}, api: sim_api, year: 2015, type: 'reg')
@@ -252,7 +252,7 @@ module Sportradar
252
252
  def self.simulations
253
253
  api = sim_api
254
254
  ['2015/REG/1/WKY/MSH', '2015/REG/1/KEN/FLA', '2015/REG/1/WOU/PRST'].map do |game_uri|
255
- Game.new({'uri' => game_uri}, api: api)
255
+ Game.new({'id' => game_uri}).sim!
256
256
  end
257
257
  end
258
258
 
@@ -11,6 +11,11 @@ module Sportradar
11
11
  @access_level = access_level
12
12
  end
13
13
 
14
+ def sim!
15
+ @access_level = 'sim-t'
16
+ self
17
+ end
18
+
14
19
  def default_year
15
20
  default_date.year
16
21
  end
@@ -21,7 +26,7 @@ module Sportradar
21
26
  'reg'
22
27
  end
23
28
  def default_access_level
24
- if (ENV['SPORTRADAR_ENV'] || ENV['SPORTRADAR_ENV_MLB'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
29
+ if (ENV['SPORTRADAR_ENV'] || ENV['SPORTRADAR_ENV_NCAAFB'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
25
30
  'p'
26
31
  else
27
32
  't'
@@ -11,7 +11,7 @@ module Sportradar
11
11
 
12
12
  @id = data["id"]
13
13
  @name = data["name"]
14
- @alias = data["alias"]
14
+ @alias = data["alias"] || data["id"]
15
15
  @teams_hash = {}
16
16
  @subdivisions_hash = {}
17
17
  @assigned_teams = nil
@@ -11,7 +11,7 @@ module Sportradar
11
11
 
12
12
  @id = data["id"]
13
13
  @name = data["name"]
14
- @alias = data["alias"]
14
+ @alias = data["alias"] || data["id"]
15
15
  update(data, **opts)
16
16
  end
17
17
 
@@ -28,7 +28,7 @@ module Sportradar
28
28
  end
29
29
 
30
30
  def conferences_by_name
31
- @conferences_by_name ||= conferences.map { |c| [c.alias, c] }.to_h
31
+ @conferences_by_name ||= conferences.map { |c| [c.id, c] }.to_h
32
32
  end
33
33
 
34
34
  def teams
@@ -5,8 +5,8 @@ module Sportradar
5
5
  class Game < Sportradar::Api::Football::Game
6
6
 
7
7
  def initialize(data, **opts)
8
- if data['uri']
9
- @year, @type, @week_number, @away_alias, @home_alias = data['uri'].split('/')
8
+ if data['id'].include?('/')
9
+ @year, @type, @week_number, @away_alias, @home_alias = data.delete('id').split('/')
10
10
  end
11
11
  super
12
12
  end
@@ -16,7 +16,7 @@ module Sportradar
16
16
  end
17
17
 
18
18
  def generate_title
19
- if home && away
19
+ if home.full_name && away.full_name
20
20
  "#{home.full_name} vs #{away.full_name}"
21
21
  elsif home_alias && away_alias
22
22
  "#{home_alias} vs #{away_alias}"
@@ -33,6 +33,11 @@ module Sportradar
33
33
  ingest_extended_box(data)
34
34
  end
35
35
 
36
+ def queue_extended_box
37
+ url, headers, options, timeout = api.get_request_info(path_extended_box)
38
+ {url: url, headers: headers, params: options, timeout: timeout, callback: method(:ingest_extended_box)}
39
+ end
40
+
36
41
  def ingest_extended_box(data)
37
42
  data = data
38
43
  update(data, source: :extended_box)
@@ -1,17 +1,39 @@
1
1
  module Sportradar
2
2
  module Api
3
3
  module Football
4
- class Ncaaf
4
+ class Ncaafb
5
5
  class Play < Sportradar::Api::Football::Play
6
6
 
7
- # def parse_player
8
- # # TODO: Currently there is an issue where we are only mapping one player_id to a play, but there are plays with multiple players involved.
9
- # play_stats = @statistics.penalty || @statistics.rush || @statistics.return || @statistics.receive
10
- # if play_stats.is_a?(Array)
11
- # play_stats = play_stats.first
12
- # end
13
- # @player_id = play_stats&.player&.id
14
- # end
7
+
8
+ def parsed_ending
9
+ @parsed_ending ||= parse_description_for_drive_end
10
+ end
11
+
12
+ private
13
+
14
+ def parse_description_for_drive_end
15
+ parsed_ending = case @description
16
+ when /intercepted/i
17
+ :interception
18
+ when /extra point is good/i
19
+ :touchdown
20
+ # when missed extra point
21
+ when /punts/i
22
+ :punt
23
+ when /Field Goal is No Good. blocked/i
24
+ :fg
25
+ # when missed field goal
26
+ when /Field Goal is Good/i
27
+ :fg
28
+ when "End of 1st Half"
29
+ :end_of_half
30
+ else
31
+ #
32
+ end
33
+ if parsed_ending
34
+ parsed_ending
35
+ end
36
+ end
15
37
 
16
38
  end
17
39
  end
@@ -4,6 +4,10 @@ module Sportradar
4
4
  class Ncaafb
5
5
  class Team < Sportradar::Api::Football::Team
6
6
 
7
+ def alias
8
+ id
9
+ end
10
+
7
11
  def players
8
12
  get_roster if @players_hash.empty?
9
13
  @players_hash.values
@@ -260,7 +260,7 @@ module Sportradar
260
260
  # end
261
261
 
262
262
  def self.sim_api
263
- Sportradar::Api::Football::Nfl::Api.new('sim')
263
+ Sportradar::Api::Football::Nfl::Api.new.sim!
264
264
  end
265
265
  def self.simulation
266
266
  new({}, api: sim_api, year: 2015, type: 'reg')
@@ -268,7 +268,7 @@ module Sportradar
268
268
  def self.simulations
269
269
  api = sim_api
270
270
  ['f45b4a31-b009-4039-8394-42efbc6d5532', '5a7042cb-fe7a-4838-b93f-6b8c167ec384', '7f761bb5-7963-43ea-a01b-baf4f5d50fe3'].map do |game_id|
271
- Game.new({'id' => game_id}, api: api)
271
+ Game.new({'id' => game_id}).sim!
272
272
  end
273
273
  end
274
274
 
@@ -21,7 +21,7 @@ module Sportradar
21
21
  'reg'
22
22
  end
23
23
  def default_access_level
24
- if (ENV['SPORTRADAR_ENV'] || ENV['SPORTRADAR_ENV_MLB'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
24
+ if (ENV['SPORTRADAR_ENV'] || ENV['SPORTRADAR_ENV_NFL'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
25
25
  'p'
26
26
  else
27
27
  'ot'
@@ -39,7 +39,7 @@ module Sportradar
39
39
  end
40
40
 
41
41
  def api_key
42
- if access_level != 'ot'
42
+ if !['ot', 'sim'].include?(access_level)
43
43
  ::Sportradar::Api.api_key_params('nfl', 'production')
44
44
  else
45
45
  ::Sportradar::Api.api_key_params('nfl')
@@ -51,6 +51,14 @@ module Sportradar
51
51
  self
52
52
  end
53
53
 
54
+ def end_of_regulation?
55
+ false
56
+ end
57
+
58
+ def halftime?
59
+ false
60
+ end
61
+
54
62
  def parse_player
55
63
  # TODO: Currently there is an issue where we are only mapping one player_id to a play, but there are plays with multiple players involved.
56
64
  play_stats = @statistics.penalty || @statistics.rush || @statistics.return || @statistics.receive
@@ -2,7 +2,7 @@ module Sportradar
2
2
  module Api
3
3
  module Football
4
4
  class Player < Data
5
- attr_accessor :response, :id, :number, :name_full, :name_first, :name_last, :position, :birth_place, :college, :height, :weight, :averages, :totals, :draft, :api
5
+ attr_accessor :response, :id, :preferred_name, :number, :name_full, :name_first, :name_last, :position, :birth_place, :college, :height, :weight, :averages, :totals, :draft, :api
6
6
 
7
7
  def initialize(data, **opts)
8
8
  @response = data
@@ -14,11 +14,19 @@ module Sportradar
14
14
  update(data, **opts)
15
15
  end
16
16
 
17
+ def first_name
18
+ @name_first || @first_name
19
+ end
20
+
21
+ def last_name
22
+ @name_last || @last_name
23
+ end
24
+
17
25
  def name # to match api for NFL::Player
18
26
  name_full
19
27
  end
20
28
  def display_name
21
- name_full
29
+ preferred_name ? "#{preferred_name} #{last_name}" : name_full
22
30
  end
23
31
 
24
32
  def birth_date # to match api for NFL::Player
@@ -31,10 +39,11 @@ module Sportradar
31
39
 
32
40
  def update(data, **opts)
33
41
  @status = data['status'] if data['status']
34
- @name_full = data['name_full'] || data['name'] || @name_full
35
- @name_first = data['name_first'] if data['name_first']
36
- @name_last = data['name_last'] if data['name_last']
37
- @name_abbr = data['name_abbr'] if data['name_abbr']
42
+ @preferred_name = data['preferred_name'] || data['name_preferred'] || @preferred_name
43
+ @name_full = data['name_full'] || data['name'] || @name_full
44
+ @name_first = data['name_first'] || data['first_name'] || @name_first
45
+ @name_last = data['name_last'] || data['last_name'] || @name_last
46
+ @name_abbr = data['name_abbr'] || data['abbr_name'] || @name_abbr
38
47
  @height = data['height'] if data['height']
39
48
  @weight = data['weight'] if data['weight']
40
49
  @position = data['position'] if data['position']
@@ -6,6 +6,11 @@ module Sportradar
6
6
 
7
7
  # attr_reader :url, :headers, :timeout, :api_key
8
8
 
9
+ def sim!
10
+ @access_level = 'sim'
11
+ self
12
+ end
13
+
9
14
  def get_data(url)
10
15
  data = get request_url(url)
11
16
  if data.is_a?(::Sportradar::Api::Error)
@@ -9,6 +9,7 @@ module Sportradar
9
9
  end
10
10
 
11
11
  def league(league_name)
12
+ # ActiveSupport
12
13
  matches.select{ |match| match.tournament_group.name.parameterize == league_name.parameterize}
13
14
  end
14
15
 
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.11.0"
3
+ VERSION = "0.11.1"
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.11.0
4
+ version: 0.11.1
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-07-11 00:00:00.000000000 Z
11
+ date: 2017-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -460,7 +460,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
460
460
  version: '0'
461
461
  requirements: []
462
462
  rubyforge_project:
463
- rubygems_version: 2.5.2
463
+ rubygems_version: 2.6.11
464
464
  signing_key:
465
465
  specification_version: 4
466
466
  summary: Sportradar API client