sportradar-api 0.13.2 → 0.13.3

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: d90031bff174b8d314611057f2acc13f218e6e94
4
- data.tar.gz: cb532e237828d29e7d8016d5fa961cfb63d09ade
3
+ metadata.gz: e7c4e102adf1dedfa30d0b4dee8c2ec487c90d47
4
+ data.tar.gz: 19963209a9360cafab24e0c55a4ca85c66c4deec
5
5
  SHA512:
6
- metadata.gz: 55018b31361e1984906f2bb6ef53e2df683979c53a3d461e3755987890f430e3e8957ea6e2c2c04a4d15e799e632d67edc9ded3727d5aa3e5e161ef638eb8604
7
- data.tar.gz: b2849370cdd051bce505eea3732b573bd1bf7b257acbde599599e505039dc213e33fe51835c5ecde47116e8c6b6cc57d6fadb33aa4a96503ad2d40472c34689a
6
+ metadata.gz: 9ca4e5c8b891388951e2df4a8dc068187215a3e3a46af659a368bd23bde2ca3bfff529b5c7b396285aaa7d3231ae1992354bef9f479bb564735a2f40d6ddb5cc
7
+ data.tar.gz: 395c76784ab1845428afa14ae82b8cdb50ecad5a68fedc0fc149714149bf0679055daf538bb17f143a7f5d21794ad034fdfa6c1ed2c1e4b0b1f15592ce4ee185
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportradar-api (0.13.2)
4
+ sportradar-api (0.13.3)
5
5
  activesupport
6
6
  httparty (>= 0.14.0)
7
7
 
@@ -469,7 +469,7 @@ module Sportradar
469
469
  end
470
470
 
471
471
  def api
472
- @api || Sportradar::Api::Baseball::Mlb::Api.new
472
+ @api ||= Sportradar::Api::Baseball::Mlb::Api.new
473
473
  end
474
474
 
475
475
  def sim!
@@ -20,7 +20,7 @@ module Sportradar
20
20
  alias :quarters :periods
21
21
 
22
22
  def api
23
- @api || Sportradar::Api::Basketball::Nba::Api.new
23
+ @api ||= Sportradar::Api::Basketball::Nba::Api.new
24
24
  end
25
25
 
26
26
  def sim!
@@ -30,7 +30,7 @@ module Sportradar
30
30
  alias :halfs :periods
31
31
 
32
32
  def api
33
- @api || Sportradar::Api::Basketball::Ncaamb::Api.new
33
+ @api ||= Sportradar::Api::Basketball::Ncaamb::Api.new
34
34
  end
35
35
 
36
36
  def sim!
@@ -107,7 +107,7 @@ module Sportradar
107
107
  end
108
108
 
109
109
  def api
110
- @api || Sportradar::Api::Football::Ncaafb::Api.new
110
+ @api ||= Sportradar::Api::Football::Ncaafb::Api.new
111
111
  end
112
112
 
113
113
  end
@@ -42,7 +42,7 @@ module Sportradar
42
42
  end
43
43
 
44
44
  def api
45
- @api || Sportradar::Api::Football::Nfl::Api.new
45
+ @api ||= Sportradar::Api::Football::Nfl::Api.new
46
46
  end
47
47
 
48
48
  end
@@ -11,6 +11,7 @@ require_relative 'soccer/team'
11
11
  require_relative 'soccer/player'
12
12
  require_relative 'soccer/venue'
13
13
  require_relative 'soccer/fact'
14
+ require_relative 'soccer/scoring'
14
15
 
15
16
  module Sportradar
16
17
  module Api
@@ -6,6 +6,7 @@ module Sportradar
6
6
  attr_reader :home_score, :away_score, :winner_id, :aggregate_home_score, :aggregate_away_score, :aggregate_winner_id
7
7
  attr_reader :referee, :weather_info, :coverage_info, :probabilities
8
8
  attr_reader :home, :away, :tournament_id
9
+ attr_reader :clock, :period, :score, :scoring, :broadcast, :coverage # these are for consistency with other sports
9
10
 
10
11
  def initialize(data = {}, league_group: nil, **opts)
11
12
  @response = data
@@ -17,6 +18,7 @@ module Sportradar
17
18
  @timeline_hash = {}
18
19
  @lineups_hash = {}
19
20
  get_tournament_id(data, **opts)
21
+ @scoring_raw = Scoring.new(data, game: self)
20
22
  @home = Team.new({}, api: api, match: self)
21
23
  @away = Team.new({}, api: api, match: self)
22
24
  @teams_hash = { away: @away, home: @home }
@@ -75,6 +77,18 @@ module Sportradar
75
77
  # parse_nested_data(data)
76
78
  end
77
79
 
80
+ def title
81
+ [@home, @away].compact.join(' vs ')
82
+ end
83
+
84
+ def realtime_state
85
+
86
+ end
87
+
88
+ def scoring
89
+ @scoring_raw.scores
90
+ end
91
+
78
92
  def update_teams(data)
79
93
  home_hash = data.detect { |team_hash| team_hash["qualifier"] == "home" || team_hash["team"] == "home" }
80
94
  away_hash = (data - [home_hash]).first
@@ -0,0 +1,63 @@
1
+ module Sportradar
2
+ module Api
3
+ module Soccer
4
+ class Scoring < Data
5
+ attr_accessor :response, :api, :id, :home, :away, :scores
6
+
7
+ def initialize(data, **opts)
8
+ @api = opts[:api]
9
+ @match = opts[:match]
10
+
11
+ @scores = {}
12
+ @id = data['id']
13
+
14
+ update(data, **opts)
15
+ end
16
+
17
+ def update(data, source: nil, **opts)
18
+ new_scores = case source
19
+ when :box
20
+ parse_from_box(data)
21
+ when :timeline
22
+ parse_from_timeline(data)
23
+ when :summary
24
+ parse_from_box(data)
25
+ else
26
+ if data['period'] || data['half']
27
+ parse_from_timeline(data)
28
+ elsif data['team']
29
+ parse_from_box(data)
30
+ else # schedule requests
31
+ {}
32
+ end
33
+ end
34
+ # parse data structure
35
+ # handle data from team (all periods)
36
+ # handle data from period (both teams)
37
+ # handle data from match?
38
+ @scores.each { |k, v| v.merge!(new_scores.delete(k) || {} ) }
39
+ new_scores.each { |k, v| @scores.merge!(k => v) }
40
+ end
41
+
42
+ def goals(team_id)
43
+ @score[team_id].to_i
44
+ end
45
+
46
+
47
+ private
48
+
49
+ def parse_from_timeline(data)
50
+ end
51
+
52
+ # def period_name
53
+ # 'period'
54
+ # end
55
+
56
+ def parse_from_summary(data)
57
+ #
58
+ end
59
+
60
+ end
61
+ end
62
+ end
63
+ end
@@ -52,6 +52,10 @@ module Sportradar
52
52
  end
53
53
  end
54
54
 
55
+ def current_season
56
+ seasons.detect(&:current?)
57
+ end
58
+
55
59
  def standings(type = nil)
56
60
  if type
57
61
  @standings_hash[type]
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.13.2"
3
+ VERSION = "0.13.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportradar-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2
4
+ version: 0.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett
@@ -458,6 +458,7 @@ files:
458
458
  - lib/sportradar/api/soccer/lineup.rb
459
459
  - lib/sportradar/api/soccer/match.rb
460
460
  - lib/sportradar/api/soccer/player.rb
461
+ - lib/sportradar/api/soccer/scoring.rb
461
462
  - lib/sportradar/api/soccer/season.rb
462
463
  - lib/sportradar/api/soccer/standing.rb
463
464
  - lib/sportradar/api/soccer/team.rb