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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sportradar/api/baseball/game.rb +1 -1
- data/lib/sportradar/api/basketball/nba/game.rb +1 -1
- data/lib/sportradar/api/basketball/ncaamb/game.rb +1 -1
- data/lib/sportradar/api/football/ncaafb/game.rb +1 -1
- data/lib/sportradar/api/football/nfl/game.rb +1 -1
- data/lib/sportradar/api/soccer.rb +1 -0
- data/lib/sportradar/api/soccer/match.rb +14 -0
- data/lib/sportradar/api/soccer/scoring.rb +63 -0
- data/lib/sportradar/api/soccer/tournament.rb +4 -0
- data/lib/sportradar/api/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7c4e102adf1dedfa30d0b4dee8c2ec487c90d47
|
4
|
+
data.tar.gz: 19963209a9360cafab24e0c55a4ca85c66c4deec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ca4e5c8b891388951e2df4a8dc068187215a3e3a46af659a368bd23bde2ca3bfff529b5c7b396285aaa7d3231ae1992354bef9f479bb564735a2f40d6ddb5cc
|
7
|
+
data.tar.gz: 395c76784ab1845428afa14ae82b8cdb50ecad5a68fedc0fc149714149bf0679055daf538bb17f143a7f5d21794ad034fdfa6c1ed2c1e4b0b1f15592ce4ee185
|
data/Gemfile.lock
CHANGED
@@ -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
|
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.
|
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
|