sportradar-api 0.13.0 → 0.13.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sportradar/api/baseball/game.rb +1 -1
- data/lib/sportradar/api/basketball/game.rb +5 -4
- data/lib/sportradar/api/basketball/nba/game.rb +1 -1
- data/lib/sportradar/api/basketball/nba/quarter.rb +9 -2
- data/lib/sportradar/api/basketball/ncaamb/game.rb +1 -1
- data/lib/sportradar/api/basketball/ncaamb/half.rb +9 -0
- data/lib/sportradar/api/basketball/play.rb +1 -0
- data/lib/sportradar/api/basketball/plays/jumpball_violation.rb +11 -0
- data/lib/sportradar/api/basketball/plays.rb +1 -0
- 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/README.md +4 -0
- data/lib/sportradar/api/soccer/event.rb +14 -13
- data/lib/sportradar/api/soccer/match.rb +130 -4
- data/lib/sportradar/api/soccer/player.rb +8 -2
- data/lib/sportradar/api/soccer/scoring.rb +71 -0
- data/lib/sportradar/api/soccer/team.rb +7 -2
- data/lib/sportradar/api/soccer/tournament.rb +21 -2
- data/lib/sportradar/api/soccer.rb +1 -0
- data/lib/sportradar/api/version.rb +1 -1
- metadata +5 -29
- data/lib/sportradar/api/soccer-old/boxscore.rb +0 -13
- data/lib/sportradar/api/soccer-old/category.rb +0 -17
- data/lib/sportradar/api/soccer-old/fact.rb +0 -61
- data/lib/sportradar/api/soccer-old/hierarchy.rb +0 -14
- data/lib/sportradar/api/soccer-old/match.rb +0 -55
- data/lib/sportradar/api/soccer-old/player.rb +0 -88
- data/lib/sportradar/api/soccer-old/ranking.rb +0 -13
- data/lib/sportradar/api/soccer-old/schedule.rb +0 -22
- data/lib/sportradar/api/soccer-old/season.rb +0 -14
- data/lib/sportradar/api/soccer-old/standing.rb +0 -13
- data/lib/sportradar/api/soccer-old/statistic.rb +0 -14
- data/lib/sportradar/api/soccer-old/summary.rb +0 -13
- data/lib/sportradar/api/soccer-old/team.rb +0 -63
- data/lib/sportradar/api/soccer-old/tournament.rb +0 -20
- data/lib/sportradar/api/soccer-old/tournament_group.rb +0 -35
- data/lib/sportradar/api/soccer-old/venue.rb +0 -21
- data/lib/sportradar/api/soccer-old.rb +0 -158
- data/soccer-old/boxscore_test.rb +0 -14
- data/soccer-old/hierarchy_test.rb +0 -14
- data/soccer-old/match_test.rb +0 -23
- data/soccer-old/player_test.rb +0 -40
- data/soccer-old/ranking_test.rb +0 -16
- data/soccer-old/schedule_test.rb +0 -24
- data/soccer-old/standing_test.rb +0 -14
- data/soccer-old/summary_test.rb +0 -14
- data/soccer-old/team_test.rb +0 -21
- data/soccer-old_test.rb +0 -184
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.
|
|
4
|
+
version: 0.13.5
|
|
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
|
+
date: 2017-11-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -314,6 +314,7 @@ files:
|
|
|
314
314
|
- lib/sportradar/api/basketball/plays/free_throw_made.rb
|
|
315
315
|
- lib/sportradar/api/basketball/plays/free_throw_miss.rb
|
|
316
316
|
- lib/sportradar/api/basketball/plays/jumpball.rb
|
|
317
|
+
- lib/sportradar/api/basketball/plays/jumpball_violation.rb
|
|
317
318
|
- lib/sportradar/api/basketball/plays/kickball.rb
|
|
318
319
|
- lib/sportradar/api/basketball/plays/lane.rb
|
|
319
320
|
- lib/sportradar/api/basketball/plays/lineup_change.rb
|
|
@@ -432,24 +433,8 @@ files:
|
|
|
432
433
|
- lib/sportradar/api/odds.rb
|
|
433
434
|
- lib/sportradar/api/poll.rb
|
|
434
435
|
- lib/sportradar/api/request.rb
|
|
435
|
-
- lib/sportradar/api/soccer-old.rb
|
|
436
|
-
- lib/sportradar/api/soccer-old/boxscore.rb
|
|
437
|
-
- lib/sportradar/api/soccer-old/category.rb
|
|
438
|
-
- lib/sportradar/api/soccer-old/fact.rb
|
|
439
|
-
- lib/sportradar/api/soccer-old/hierarchy.rb
|
|
440
|
-
- lib/sportradar/api/soccer-old/match.rb
|
|
441
|
-
- lib/sportradar/api/soccer-old/player.rb
|
|
442
|
-
- lib/sportradar/api/soccer-old/ranking.rb
|
|
443
|
-
- lib/sportradar/api/soccer-old/schedule.rb
|
|
444
|
-
- lib/sportradar/api/soccer-old/season.rb
|
|
445
|
-
- lib/sportradar/api/soccer-old/standing.rb
|
|
446
|
-
- lib/sportradar/api/soccer-old/statistic.rb
|
|
447
|
-
- lib/sportradar/api/soccer-old/summary.rb
|
|
448
|
-
- lib/sportradar/api/soccer-old/team.rb
|
|
449
|
-
- lib/sportradar/api/soccer-old/tournament.rb
|
|
450
|
-
- lib/sportradar/api/soccer-old/tournament_group.rb
|
|
451
|
-
- lib/sportradar/api/soccer-old/venue.rb
|
|
452
436
|
- lib/sportradar/api/soccer.rb
|
|
437
|
+
- lib/sportradar/api/soccer/README.md
|
|
453
438
|
- lib/sportradar/api/soccer/api.rb
|
|
454
439
|
- lib/sportradar/api/soccer/event.rb
|
|
455
440
|
- lib/sportradar/api/soccer/fact.rb
|
|
@@ -457,6 +442,7 @@ files:
|
|
|
457
442
|
- lib/sportradar/api/soccer/lineup.rb
|
|
458
443
|
- lib/sportradar/api/soccer/match.rb
|
|
459
444
|
- lib/sportradar/api/soccer/player.rb
|
|
445
|
+
- lib/sportradar/api/soccer/scoring.rb
|
|
460
446
|
- lib/sportradar/api/soccer/season.rb
|
|
461
447
|
- lib/sportradar/api/soccer/standing.rb
|
|
462
448
|
- lib/sportradar/api/soccer/team.rb
|
|
@@ -464,16 +450,6 @@ files:
|
|
|
464
450
|
- lib/sportradar/api/soccer/tournament.rb
|
|
465
451
|
- lib/sportradar/api/soccer/venue.rb
|
|
466
452
|
- lib/sportradar/api/version.rb
|
|
467
|
-
- soccer-old/boxscore_test.rb
|
|
468
|
-
- soccer-old/hierarchy_test.rb
|
|
469
|
-
- soccer-old/match_test.rb
|
|
470
|
-
- soccer-old/player_test.rb
|
|
471
|
-
- soccer-old/ranking_test.rb
|
|
472
|
-
- soccer-old/schedule_test.rb
|
|
473
|
-
- soccer-old/standing_test.rb
|
|
474
|
-
- soccer-old/summary_test.rb
|
|
475
|
-
- soccer-old/team_test.rb
|
|
476
|
-
- soccer-old_test.rb
|
|
477
453
|
- sportradar-api.gemspec
|
|
478
454
|
homepage: https://github.com/beneggett/sportradar-api
|
|
479
455
|
licenses: []
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Boxscore < Data
|
|
4
|
-
attr_accessor :response, :matches
|
|
5
|
-
|
|
6
|
-
def initialize(data)
|
|
7
|
-
@response = data
|
|
8
|
-
@matches = parse_into_array(selector: response["boxscore"]["matches"]["match"], klass: Sportradar::Api::Soccer::Match) if response['boxscore'] && response['boxscore']['matches'] && response["boxscore"]["matches"]["match"]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Category < Data
|
|
4
|
-
attr_accessor :response, :id, :name, :country_code, :country, :tournament_groups
|
|
5
|
-
|
|
6
|
-
def initialize(data)
|
|
7
|
-
@response = data
|
|
8
|
-
@id = data["id"]
|
|
9
|
-
@name = data["name"]
|
|
10
|
-
@country_code = data["country_code"]
|
|
11
|
-
@country = data["country"]
|
|
12
|
-
@tournament_groups = parse_into_array(selector: response["tournament_group"], klass: Sportradar::Api::Soccer::TournamentGroup) if response["tournament_group"]
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Fact < Data
|
|
4
|
-
|
|
5
|
-
attr_accessor :id, :type, :time, :updated_time, :scratch, :reference_id, :clock, :team_id, :description, :period, :x, :y, :player_id, :card, :injury_time, :home_score, :away_score, :player_out_id, :player_in_id, :penalty, :owngoal, :header, :assist1_id, :winner_id, :draw, :response
|
|
6
|
-
|
|
7
|
-
def initialize(data)
|
|
8
|
-
@response = data
|
|
9
|
-
@id = data["id"]
|
|
10
|
-
@type = data["type"]
|
|
11
|
-
@time = data["time"]
|
|
12
|
-
@updated_time = data["updated_time"]
|
|
13
|
-
@scratch = data["scratch"]
|
|
14
|
-
@reference_id = data["reference_id"]
|
|
15
|
-
@clock = data["clock"]
|
|
16
|
-
@team_id = data["team_id"]
|
|
17
|
-
@description = data["description"]
|
|
18
|
-
@period = data["period"]
|
|
19
|
-
@x = data["x"]
|
|
20
|
-
@y = data["y"]
|
|
21
|
-
@player_id = data["player_id"]
|
|
22
|
-
@card = data["card"]
|
|
23
|
-
@injury_time = data["injury_time"]
|
|
24
|
-
@home_score = data["home_score"]
|
|
25
|
-
@away_score = data["away_score"]
|
|
26
|
-
@player_out_id = data["player_out_id"]
|
|
27
|
-
@player_in_id = data["player_in_id"]
|
|
28
|
-
@penalty = data["penalty"]
|
|
29
|
-
@owngoal = data["owngoal"]
|
|
30
|
-
@header = data["header"]
|
|
31
|
-
@assist1_id = data["assist1_id"]
|
|
32
|
-
@winner_id = data["winner_id"]
|
|
33
|
-
@draw = data["draw"]
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
## Fact Types
|
|
37
|
-
# card
|
|
38
|
-
# corner_kick
|
|
39
|
-
# free_kick
|
|
40
|
-
# game_resumed
|
|
41
|
-
# goal
|
|
42
|
-
# goal_kick
|
|
43
|
-
# injury
|
|
44
|
-
# injury_return
|
|
45
|
-
# injury_time
|
|
46
|
-
# keeper_save
|
|
47
|
-
# match_ended
|
|
48
|
-
# match_started
|
|
49
|
-
# offside
|
|
50
|
-
# penalty_awarded
|
|
51
|
-
# penalty_missed
|
|
52
|
-
# period_over
|
|
53
|
-
# period_started
|
|
54
|
-
# shot_blocked
|
|
55
|
-
# shot_off_target
|
|
56
|
-
# shot_on_target
|
|
57
|
-
# substitution
|
|
58
|
-
# throwin
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Hierarchy < Data
|
|
4
|
-
attr_accessor :response, :categories
|
|
5
|
-
|
|
6
|
-
def initialize(data)
|
|
7
|
-
@response = data
|
|
8
|
-
@categories = parse_into_array(selector: response["category"], klass: Sportradar::Api::Soccer::Category) if response["category"]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Match < Data
|
|
4
|
-
|
|
5
|
-
attr_accessor :id, :status, :scheduled, :scratched, :season_id, :reference_id, :category, :tournament_group, :tournament, :home, :away, :venue, :round, :coverage, :period, :clock, :referee, :facts, :response, :future_game, :winner
|
|
6
|
-
|
|
7
|
-
def initialize(data)
|
|
8
|
-
@response = data
|
|
9
|
-
@id = data["id"]
|
|
10
|
-
@reference_id = data["reference_id"]
|
|
11
|
-
@scheduled = Time.parse(data["scheduled"]) if data["scheduled"]
|
|
12
|
-
@scratched = data["scratched"] == "true"
|
|
13
|
-
@season_id = data["season_id"]
|
|
14
|
-
@status = data["status"]
|
|
15
|
-
@category = Sportradar::Api::Soccer::Category.new data["category"] if data["category"]
|
|
16
|
-
@coverage = OpenStruct.new data["coverage"]
|
|
17
|
-
@round = OpenStruct.new data["round"]
|
|
18
|
-
@tournament = Sportradar::Api::Soccer::Tournament.new data["tournament"] if data["tournament"]
|
|
19
|
-
@tournament_group = Sportradar::Api::Soccer::TournamentGroup.new data["tournament_group"] if data["tournament_group"]
|
|
20
|
-
|
|
21
|
-
@away = Sportradar::Api::Soccer::Team.new data["away"] if data["away"]
|
|
22
|
-
@home = Sportradar::Api::Soccer::Team.new data["home"] if data["home"]
|
|
23
|
-
@venue = Sportradar::Api::Soccer::Venue.new data["venue"] if data["venue"]
|
|
24
|
-
|
|
25
|
-
@future_game = @scheduled > Time.now.utc
|
|
26
|
-
@winner = find_winner if @home && @away && !future_game
|
|
27
|
-
|
|
28
|
-
# Actual stats from match summary
|
|
29
|
-
@period = data["period"]
|
|
30
|
-
@clock = data["clock"]
|
|
31
|
-
@referee = OpenStruct.new data["referee"] if data["referee"]
|
|
32
|
-
@facts = data["facts"]["fact"].map {|fact| Sportradar::Api::Soccer::Fact.new fact } if data["facts"]
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def find_winner
|
|
36
|
-
if @home.winner == 'draw'
|
|
37
|
-
'draw'
|
|
38
|
-
else
|
|
39
|
-
[@home, @away].find {|team| team.winner == "true" }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def period_name
|
|
45
|
-
period_names = {"P1" => "Period one", "H" => "Halftime", "P2" => "Period two", "PX1" => "Pre-extra time one", "X1" => "Extra time one", "PX2" => "Pre-extra time two", "X2" => "Extra time two", "PP" => "Pre-penalty", "P" => "Penalty"}
|
|
46
|
-
period_names[period] if period
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def status_description
|
|
50
|
-
status_descriptions = {"scheduled" => "The match is scheduled to be played", "inprogress" => "The match is currently in progress", "postponed" => "The match has been postponed to a future date", "delayed" => "The match has been temporarily delayed and will be continued", "canceled" => "The match has been canceled and will not be played", "closed" => "The match is over"}
|
|
51
|
-
status_descriptions[status] if status
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Player < Data
|
|
4
|
-
|
|
5
|
-
attr_accessor :id, :first_name, :last_name, :country_code, :country, :reference_id, :full_first_name, :full_last_name, :position, :started, :jersey_number, :tactical_position, :tactical_order, :statistics, :preferred_foot, :birthdate, :height_in, :weight_lb, :height_cm, :weight_kg, :teams, :response, :rank, :total, :statistics, :last_modified
|
|
6
|
-
|
|
7
|
-
def initialize(data)
|
|
8
|
-
@response = data
|
|
9
|
-
@teams = parse_into_array(selector: response["team"], klass: Sportradar::Api::Soccer::Team) if response["team"]
|
|
10
|
-
@teams = parse_into_array(selector: response["teams"]["team"], klass: Sportradar::Api::Soccer::Team) if response["teams"] && response["teams"]["team"]
|
|
11
|
-
@id = data["id"]
|
|
12
|
-
@first_name = data["first_name"]
|
|
13
|
-
@last_name = data["last_name"]
|
|
14
|
-
@country_code = data["country_code"]
|
|
15
|
-
@country = data["country"]
|
|
16
|
-
@reference_id = data["reference_id"]
|
|
17
|
-
@full_first_name = data["full_first_name"]
|
|
18
|
-
@full_last_name = data["full_last_name"]
|
|
19
|
-
@position = data["position"] || primary_team.try(:position)
|
|
20
|
-
@started = data["started"]
|
|
21
|
-
@jersey_number = data["jersey_number"] || primary_team.try(:jersey_number)
|
|
22
|
-
@tactical_position = data["tactical_position"]
|
|
23
|
-
@tactical_order = data["tactical_order"]
|
|
24
|
-
@last_modified = data["last_modified"]
|
|
25
|
-
|
|
26
|
-
# profile
|
|
27
|
-
@preferred_foot = data["preferred_foot"]
|
|
28
|
-
@birthdate = data["birthdate"]
|
|
29
|
-
@height_in = data["height_in"]
|
|
30
|
-
@weight_lb = data["weight_lb"]
|
|
31
|
-
@height_cm = data["height_cm"]
|
|
32
|
-
@weight_kg = data["weight_kg"]
|
|
33
|
-
@rank = data["rank"]
|
|
34
|
-
@total = OpenStruct.new data["total"] if data["total"]
|
|
35
|
-
@statistics = parse_into_array(selector:response["statistics"]["season"], klass: Sportradar::Api::Soccer::Season) if response["statistics"] && response["statistics"]["season"]
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def name
|
|
40
|
-
[first_name, last_name].join(' ')
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def full_name
|
|
44
|
-
full = [full_first_name, full_last_name].join(' ')
|
|
45
|
-
full == " " ? name : full
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def position_name
|
|
49
|
-
positions = {"G" => "Goalie", "D" => "Defender", "M" => "Midfielder", "F" => "Forward", "" => "N/A"}
|
|
50
|
-
if position
|
|
51
|
-
positions[position]
|
|
52
|
-
elsif primary_team.present?
|
|
53
|
-
positions[primary_team.position]
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def primary_team
|
|
58
|
-
if teams.count == 1
|
|
59
|
-
teams.first
|
|
60
|
-
else
|
|
61
|
-
teams.find {|team| team.name != team.country_code}
|
|
62
|
-
end if teams
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def tactical_position_name
|
|
67
|
-
tactical_positions = { "0" => "Unknown", "1" => "Goalkeeper", "2" => "Right Back", "3" => "Central Defender", "4" => "Left Back", "5" => "Right winger", "6" => "Central Midfielder", "7" => "Left Winger", "8" => "Forward" }
|
|
68
|
-
tactical_positions[tactical_position] if tactical_position
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def age
|
|
72
|
-
if birthdate.present?
|
|
73
|
-
now = Time.now.utc.to_date
|
|
74
|
-
dob = birthdate.to_date
|
|
75
|
-
now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def height_ft
|
|
80
|
-
if height_in.present?
|
|
81
|
-
feet, inches = height_in.to_i.divmod(12)
|
|
82
|
-
"#{feet}' #{inches}\""
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Ranking < Data
|
|
4
|
-
attr_accessor :response, :categories
|
|
5
|
-
|
|
6
|
-
def initialize(data)
|
|
7
|
-
@response = data
|
|
8
|
-
@categories = parse_into_array(selector: response["category"], klass: Sportradar::Api::Soccer::Category) if response["category"]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Schedule < Data
|
|
4
|
-
attr_accessor :response, :matches
|
|
5
|
-
|
|
6
|
-
def initialize(data)
|
|
7
|
-
@response = data
|
|
8
|
-
@matches = parse_into_array(selector: response["schedule"]["matches"]["match"], klass: Sportradar::Api::Soccer::Match) if response['schedule'] && response['schedule']['matches'] && response["schedule"]["matches"]["match"]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def league(league_name)
|
|
12
|
-
# ActiveSupport
|
|
13
|
-
matches.select{ |match| match.tournament_group.name.parameterize == league_name.parameterize}
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def available_leagues
|
|
17
|
-
matches.map {|match| match.tournament_group.name}.uniq
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Season < Data
|
|
4
|
-
attr_accessor :response, :year, :statistics
|
|
5
|
-
|
|
6
|
-
def initialize(data)
|
|
7
|
-
@response = data
|
|
8
|
-
@year = data["year"]
|
|
9
|
-
@statistics = parse_into_array(selector: response["statistic"], klass: Sportradar::Api::Soccer::Statistic) if response["statistic"]
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Standing < Data
|
|
4
|
-
attr_accessor :response, :categories
|
|
5
|
-
|
|
6
|
-
def initialize(data)
|
|
7
|
-
@response = data
|
|
8
|
-
@categories = parse_into_array(selector: response["categories"]["category"], klass: Sportradar::Api::Soccer::Category) if response["categories"] && response["categories"]["category"]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Summary < Data
|
|
4
|
-
attr_accessor :response, :matches
|
|
5
|
-
|
|
6
|
-
def initialize(data)
|
|
7
|
-
@response = data
|
|
8
|
-
@matches = parse_into_array(selector: response["summary"]["matches"]["match"], klass: Sportradar::Api::Soccer::Match) if response['summary'] && response['summary']['matches'] && response["summary"]["matches"]["match"]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Team < Data
|
|
4
|
-
attr_accessor :response, :id, :name, :full_name, :alias, :country_code, :country, :type, :reference_id, :formation, :score, :regular_score, :penalty_score, :winner, :scoring, :statistics, :first_half_score, :second_half_score, :players, :manager, :roster, :jersey_number, :position, :is_player, :is_manager, :rank, :win, :draw, :loss, :goals_for, :goals_against, :points, :change, :goals_diff, :jersey_number, :position, :is_player, :is_manager, :home, :away
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def initialize(data)
|
|
8
|
-
@response = data
|
|
9
|
-
@id = data["id"]
|
|
10
|
-
@reference_id = data["reference_id"]
|
|
11
|
-
@name = data["name"]
|
|
12
|
-
@full_name = data["full_name"] || data["name"]
|
|
13
|
-
@alias = data["alias"]
|
|
14
|
-
@country_code = data["country_code"]
|
|
15
|
-
@country = data["country"]
|
|
16
|
-
@type = data["type"]
|
|
17
|
-
@formation = data["formation"]
|
|
18
|
-
@score = data["score"]
|
|
19
|
-
@regular_score = data["regular_score"]
|
|
20
|
-
@penalty_score = data["penalty_score"]
|
|
21
|
-
@winner = data["winner"]
|
|
22
|
-
@rank = data["rank"]
|
|
23
|
-
@win = data["win"]
|
|
24
|
-
@draw = data["draw"]
|
|
25
|
-
@loss = data["loss"]
|
|
26
|
-
@goals_for = data["goals_for"]
|
|
27
|
-
@goals_against = data["goals_against"]
|
|
28
|
-
@points = data["points"]
|
|
29
|
-
@change = data["change"]
|
|
30
|
-
@goals_diff = data["goals_diff"]
|
|
31
|
-
@jersey_number = data["jersey_number"]
|
|
32
|
-
@position = data["position"]
|
|
33
|
-
@is_player = data["is_player"]
|
|
34
|
-
@is_manager = data["is_manager"]
|
|
35
|
-
|
|
36
|
-
# Standings generate these
|
|
37
|
-
@home = OpenStruct.new data["home"] if data["home"]
|
|
38
|
-
@away = OpenStruct.new data["away"] if data["away"]
|
|
39
|
-
|
|
40
|
-
@scoring = OpenStruct.new data["scoring"] if data["scoring"]
|
|
41
|
-
parse_scoring if scoring
|
|
42
|
-
|
|
43
|
-
@statistics = OpenStruct.new data["statistics"] if data["statistics"]
|
|
44
|
-
@players = parse_into_array(selector: data["players"]["player"], klass: Sportradar::Api::Soccer::Player) if response['players'] && response['players']['player']
|
|
45
|
-
@players = parse_into_array(selector: data["roster"]["player"], klass: Sportradar::Api::Soccer::Player) if response['roster'] && response['roster']['player']
|
|
46
|
-
@manager = Sportradar::Api::Soccer::Player.new data["manager"] if data["manager"]
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
alias_method :roster, :players
|
|
50
|
-
|
|
51
|
-
private
|
|
52
|
-
|
|
53
|
-
def parse_scoring
|
|
54
|
-
if scoring.half.is_a?(Array)
|
|
55
|
-
@first_half_score = scoring.half.find {|x| x["number"] == "1"}["points"]
|
|
56
|
-
@second_half_score = scoring.half.find {|x| x["number"] == "2"}["points"]
|
|
57
|
-
elsif scoring.half.is_a?(Hash)
|
|
58
|
-
@first_half_score = scoring.half["points"]
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Tournament < Data
|
|
4
|
-
attr_accessor :response, :id, :name, :season_start, :season_end, :season, :type, :reference_id, :coverage, :teams
|
|
5
|
-
|
|
6
|
-
def initialize(data)
|
|
7
|
-
@response = data
|
|
8
|
-
@id = data["id"]
|
|
9
|
-
@name = data["name"]
|
|
10
|
-
@season_start = data["season_start"]
|
|
11
|
-
@season_end = data["season_end"]
|
|
12
|
-
@season = data["season"]
|
|
13
|
-
@reference_id = data["reference_id"]
|
|
14
|
-
@coverage = OpenStruct.new data["coverage"] if data["coverage"]
|
|
15
|
-
@teams = parse_into_array(selector: response["team"], klass: Sportradar::Api::Soccer::Team) if response["team"]
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::TournamentGroup < Data
|
|
4
|
-
attr_accessor :response, :id, :name, :season_start, :season_end, :season, :reference_id, :top_goals, :top_own_goals, :top_assists, :top_cards, :top_points, :tournaments
|
|
5
|
-
|
|
6
|
-
def initialize(data)
|
|
7
|
-
@response = data
|
|
8
|
-
@id = data["id"]
|
|
9
|
-
@name = data["name"]
|
|
10
|
-
@season_start = data["season_start"]
|
|
11
|
-
@season_end = data["season_end"]
|
|
12
|
-
@season = data["season"]
|
|
13
|
-
@reference_id = data["reference_id"]
|
|
14
|
-
@top_goals = parse_players(data["top_goals"]["player"]) if data["top_goals"] && data["top_goals"]["player"]
|
|
15
|
-
@top_own_goals = parse_players(data["top_own_goals"]["player"]) if data["top_own_goals"] && data["top_own_goals"]["player"]
|
|
16
|
-
@top_assists = parse_players(data["top_assists"]["player"]) if data["top_assists"] && data["top_assists"]["player"]
|
|
17
|
-
@top_cards = parse_players(data["top_cards"]["player"]) if data["top_cards"] && data["top_cards"]["player"]
|
|
18
|
-
@top_points = parse_players(data["top_points"]["player"]) if data["top_points"] && data["top_points"]["player"]
|
|
19
|
-
@tournaments = parse_into_array(selector: response["tournament"], klass: Sportradar::Api::Soccer::Tournament) if response["tournament"]
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
def parse_players(field_to_parse)
|
|
25
|
-
if field_to_parse.is_a?(Array)
|
|
26
|
-
field_to_parse.map {|player| Sportradar::Api::Soccer::Player.new player }
|
|
27
|
-
elsif field_to_parse.is_a?(Hash)
|
|
28
|
-
[ Sportradar::Api::Soccer::Player.new(field_to_parse) ]
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module Sportradar
|
|
2
|
-
module Api
|
|
3
|
-
class Soccer::Venue < Data
|
|
4
|
-
|
|
5
|
-
attr_accessor :id, :name, :country_code, :country, :city, :capacity, :coordinates, :reference_id, :response
|
|
6
|
-
|
|
7
|
-
def initialize(data)
|
|
8
|
-
@response = data
|
|
9
|
-
@id = data["id"]
|
|
10
|
-
@name = data["name"]
|
|
11
|
-
@country_code = data["country_code"]
|
|
12
|
-
@country = data["country"]
|
|
13
|
-
@city = data["city"]
|
|
14
|
-
@capacity = data["capacity"]
|
|
15
|
-
@coordinates = data["coordinates"]
|
|
16
|
-
@reference_id = data["reference_id"]
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|