sportradar-api 0.13.7 → 0.13.8

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: c7792f128e62db64648080193cd385ed93c8180a
4
- data.tar.gz: 8ef947b616a3858e3b3ea36876ee885c5689a73d
3
+ metadata.gz: 261614c3df25512fb2357a7db35385ac28504b6c
4
+ data.tar.gz: d24b315ce19e902c9202fbd76a19c251272ce1d2
5
5
  SHA512:
6
- metadata.gz: 8e3e99d57562e71bbeed7f11ce45f445b483c0c03f1cf1f6d8b2b1e4290fff99ff36a170df077449fd698a3d7993a4e1599fa433d0985af30b02ba0290a92286
7
- data.tar.gz: 68a39b20ec7a67d92ff54f21531947ddd261729075cd851d8d648355b3a176faedd5da785f31f10cb6875d670cecf94e374f8bebfb9bb87fc7ad645535112d2f
6
+ metadata.gz: 56e278b2c57ee6c770fe6e761575dd0512bf8bd188bf198f2aba6bbaa8405ed58ee1a8899808e0ef4254a6fb48d06603b57b3bcfb8d6ae59eae6f1f6633be37f
7
+ data.tar.gz: e87a20f5c1446db67e8b81db3753c384b3d7e435af9826b6c24c0721414f600be43c437730b67b3db0e077cbbe884a426016c1b995c7f153090ddf0defa66e6d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportradar-api (0.13.7)
4
+ sportradar-api (0.13.8)
5
5
  activesupport
6
6
  httparty (>= 0.14.0)
7
7
 
@@ -16,6 +16,10 @@ module Sportradar
16
16
  end
17
17
  end
18
18
 
19
+ def halftime?
20
+ status == 'halftime' || clock == '00:00' && period == 1
21
+ end
22
+
19
23
  def team_class
20
24
  Team
21
25
  end
@@ -152,7 +152,7 @@ module Sportradar
152
152
  end
153
153
 
154
154
  def clock_display
155
- return unless @match_status
155
+ return unless @match_time
156
156
  if @match_time == '45:00' || @match_time == '90:00' # stoppage time
157
157
  @match_time.split(':').first + ?'
158
158
  else
@@ -10,6 +10,8 @@ module Sportradar
10
10
  @response = data
11
11
  @id = data['id'] if data['id']
12
12
  @api = opts[:api]
13
+ @team = opts[:team]
14
+
13
15
  @league_group = league_group || data['league_group'] || @api&.league_group
14
16
 
15
17
  update(data, **opts)
@@ -36,6 +38,9 @@ module Sportradar
36
38
  @matches_played = data['matches_played'] if data['matches_played']
37
39
  @stats = data['statistics'] if data['statistics']
38
40
  @date_of_birth = Date.parse(data['date_of_birth']) if data['date_of_birth']
41
+
42
+ @team.update_player_stats(self, data['statistics'], opts[:game]) if data['statistics'] && @team
43
+
39
44
  end
40
45
 
41
46
  def display_name
@@ -2,13 +2,13 @@ module Sportradar
2
2
  module Api
3
3
  module Soccer
4
4
  class Team < Data
5
- attr_accessor :tournament_id, :venue
5
+ attr_accessor :tournament_id, :venue, :player_stats
6
6
  attr_reader :id, :league_group, :name, :country, :country_code, :abbreviation, :qualifier
7
7
  alias :alias :abbreviation
8
8
  alias :market :name
9
9
  alias :display_name :name
10
10
  alias :full_name :name
11
- attr_reader :team_statistics, :jerseys, :manager, :statistics
11
+ attr_reader :team_stats, :jerseys, :manager, :statistics
12
12
 
13
13
  def initialize(data = {}, league_group: nil, **opts)
14
14
  @response = data
@@ -17,6 +17,7 @@ module Sportradar
17
17
  @league_group = league_group || data['league_group'] || @api&.league_group
18
18
 
19
19
  @players_hash = {}
20
+ @player_stats = {}
20
21
  @matches_hash = {}
21
22
 
22
23
  update(data, **opts)
@@ -42,7 +43,7 @@ module Sportradar
42
43
  create_data(@players_hash, data['player_statistics'], klass: Player, api: api, team: self) if data['player_statistics']
43
44
 
44
45
  # TODO team statistics
45
- @team_statistics = data['team_statistics'] if data['team_statistics']
46
+ @team_stats = data['team_statistics'] if data['team_statistics']
46
47
 
47
48
  create_data(@matches_hash, Soccer.parse_results(data['results']), klass: Match, api: api, team: self) if data['results']
48
49
  create_data(@matches_hash, data['schedule'], klass: Match, api: api, team: self) if data['schedule']
@@ -100,7 +101,9 @@ module Sportradar
100
101
  url, headers, options, timeout = api.get_request_info(path_roster)
101
102
  {url: url, headers: headers, params: options, timeout: timeout, callback: method(:ingest_roster)}
102
103
  end
103
-
104
+ def update_player_stats(player, stats, game = nil)
105
+ game ? game.update_player_stats(player, stats) : @player_stats.merge(player.id => stats.merge(player: player))
106
+ end
104
107
  def path_results
105
108
  "#{ path_base }/results"
106
109
  end
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.13.7"
3
+ VERSION = "0.13.8"
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.13.7
4
+ version: 0.13.8
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-11-09 00:00:00.000000000 Z
11
+ date: 2017-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler