sportradar-api 0.13.4 → 0.13.5
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/basketball/game.rb +5 -4
- data/lib/sportradar/api/basketball/nba/quarter.rb +9 -2
- data/lib/sportradar/api/basketball/ncaamb/half.rb +9 -0
- 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 +120 -8
- data/lib/sportradar/api/soccer/player.rb +8 -2
- data/lib/sportradar/api/soccer/scoring.rb +24 -16
- data/lib/sportradar/api/soccer/team.rb +2 -0
- data/lib/sportradar/api/version.rb +1 -1
- metadata +3 -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
@@ -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
|
@@ -1,158 +0,0 @@
|
|
1
|
-
module Sportradar
|
2
|
-
module Api
|
3
|
-
class Soccer < Request
|
4
|
-
attr_accessor :league, :access_level, :simulation
|
5
|
-
def initialize(league = "na", access_level = "t")
|
6
|
-
raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level
|
7
|
-
raise Sportradar::Api::Error::InvalidLeague unless allowed_leagues.include? league
|
8
|
-
@league = league
|
9
|
-
@access_level = access_level
|
10
|
-
end
|
11
|
-
|
12
|
-
def schedule
|
13
|
-
response = get request_url("matches/schedule")
|
14
|
-
if response.success?
|
15
|
-
Sportradar::Api::Soccer::Schedule.new response
|
16
|
-
else
|
17
|
-
response
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# date = Date.parse('2016-07-17')
|
22
|
-
def daily_schedule(date = Date.today)
|
23
|
-
response = get request_url("matches/#{date_path(date)}/schedule")
|
24
|
-
if response.success?
|
25
|
-
Sportradar::Api::Soccer::Schedule.new response
|
26
|
-
else
|
27
|
-
response
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
def daily_summary(date = Date.today)
|
33
|
-
response = get request_url("matches/#{date_path(date)}/summary")
|
34
|
-
if response.success?
|
35
|
-
Sportradar::Api::Soccer::Summary.new response
|
36
|
-
else
|
37
|
-
response
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def daily_boxscore(date = Date.today)
|
42
|
-
response = get request_url("matches/#{date_path(date)}/boxscore")
|
43
|
-
if response.success?
|
44
|
-
Sportradar::Api::Soccer::Boxscore.new response
|
45
|
-
else
|
46
|
-
response
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# match_id = "357607e9-87cd-4848-b53e-0485d9c1a3bc"
|
51
|
-
def match_summary(match_id)
|
52
|
-
check_simulation(match_id)
|
53
|
-
response = get request_url("matches/#{match_id}/summary")
|
54
|
-
if response.success?
|
55
|
-
Sportradar::Api::Soccer::Summary.new response
|
56
|
-
else
|
57
|
-
response
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# match_id = "357607e9-87cd-4848-b53e-0485d9c1a3bc"
|
62
|
-
def match_boxscore(match_id)
|
63
|
-
check_simulation(match_id)
|
64
|
-
response = get request_url("matches/#{match_id}/boxscore")
|
65
|
-
if response.success?
|
66
|
-
Sportradar::Api::Soccer::Boxscore.new response
|
67
|
-
else
|
68
|
-
response
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# team_id = "b78b9f61-0697-4347-a1b6-b7685a130eb1"
|
73
|
-
def team_profile(team_id)
|
74
|
-
response = get request_url("teams/#{team_id}/profile")
|
75
|
-
if response.success? && response["profile"] && response["profile"]["team"]
|
76
|
-
Sportradar::Api::Soccer::Team.new response["profile"]["team"]
|
77
|
-
else
|
78
|
-
response
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# player_id = "2aeacd39-3f9c-42af-957e-9df8573973c4"
|
83
|
-
def player_profile(player_id)
|
84
|
-
response = get request_url("players/#{player_id}/profile")
|
85
|
-
if response.success? && response["profile"] && response["profile"]["player"]
|
86
|
-
Sportradar::Api::Soccer::Player.new response["profile"]["player"]
|
87
|
-
else
|
88
|
-
response
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def player_rankings
|
93
|
-
response = get request_url("players/leader")
|
94
|
-
if response.success? && response["leaders"]
|
95
|
-
Sportradar::Api::Soccer::Ranking.new response["leaders"]
|
96
|
-
else
|
97
|
-
response
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def team_hierarchy
|
102
|
-
response = get request_url("teams/hierarchy")
|
103
|
-
if response.success? && response["hierarchy"]
|
104
|
-
Sportradar::Api::Soccer::Hierarchy.new response["hierarchy"]
|
105
|
-
else
|
106
|
-
response
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def team_standings
|
111
|
-
response = get request_url("teams/standing")
|
112
|
-
if response.success?
|
113
|
-
Sportradar::Api::Soccer::Standing.new response["standings"]
|
114
|
-
else
|
115
|
-
response
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def simulation_match
|
120
|
-
"22653ed5-0b2c-4e30-b10c-c6d51619b52b"
|
121
|
-
end
|
122
|
-
|
123
|
-
private
|
124
|
-
|
125
|
-
def check_simulation(match_id)
|
126
|
-
@simulation = true if match_id == simulation_match
|
127
|
-
end
|
128
|
-
|
129
|
-
def request_url(path)
|
130
|
-
if simulation
|
131
|
-
"/soccer-sim2/wc/#{path}"
|
132
|
-
else
|
133
|
-
"/soccer-#{access_level}#{version}/#{league}/#{path}"
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def api_key
|
138
|
-
if access_level == 'p'
|
139
|
-
Sportradar::Api.api_key_params("soccer_#{league}", "production")
|
140
|
-
else
|
141
|
-
Sportradar::Api.api_key_params("soccer_#{league}")
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def version
|
146
|
-
Sportradar::Api.version("soccer")
|
147
|
-
end
|
148
|
-
|
149
|
-
def allowed_access_levels
|
150
|
-
["p", "t"]
|
151
|
-
end
|
152
|
-
|
153
|
-
def allowed_leagues
|
154
|
-
["eu", "na", "sa", "wc", "as", "af"]
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
data/soccer-old/boxscore_test.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Sportradar::Api::Soccer::BoxscoreTest < Minitest::Test
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@attrs = {"boxscore"=> {"matches"=> {"match"=> [{"id"=>"3f7eb973-daab-49e5-b91a-6ab7cc1301a1", "status"=>"closed", "period"=>"P2", "scheduled"=>"2016-09-30T00:00:00Z", "clock"=>"", "scratched"=>"false"} ] } } }
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_it_initializes_a_soccer_boxscore
|
10
|
-
data_object = Sportradar::Api::Soccer::Boxscore.new(@attrs)
|
11
|
-
assert [:matches].all? { |e| data_object.attributes.include?(e) }
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Sportradar::Api::Soccer::HierarchyTest < Minitest::Test
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@attrs = {"category"=> [{"id"=>"c4ef0886-dfee-4725-81eb-1bb919be832a", "name"=>"International Clubs", "country_code"=>"XZ", "country"=>"International", "reference_id"=>"sr:category:393", "tournament_group"=> {"id"=>"dc3ea36c-1a29-41e3-b830-9dd2c685670a", "name"=>"CONCACAF CL", "season_start"=>"2016-08-01T22:00:00Z", "season_end"=>"2017-04-27T21:59:00Z", "season"=>"2016", "reference_id"=>"sr:tournamentgroup:498", "tournament"=> [{"id"=>"f1651216-f4f1-4e61-bd58-92a80df54df3", "name"=>"CONCACAF Champions League, Group 6", "season_id"=>"42881571-769d-4877-9f85-71868dc510d1", "season_start"=>"2016-08-01T22:00:00Z", "season_end"=>"2017-04-27T21:59:00Z", "season"=>"2016", "type"=>"group", "type_group_id"=>"6", "reference_id"=>"sr:tournament:21399"}] } }] }
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_it_initializes_a_soccer_hierarchy
|
10
|
-
data_object = Sportradar::Api::Soccer::Hierarchy.new(@attrs)
|
11
|
-
assert [:categories].all? { |e| data_object.attributes.include?(e) }
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
data/soccer-old/match_test.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Sportradar::Api::Soccer::MatchTest < Minitest::Test
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@attrs = {"id"=>"3f7eb973-daab-49e5-b91a-6ab7cc1301a1", "status"=>"closed", "period"=>"P2", "scheduled"=>"2016-09-30T00:00:00Z", "clock"=>"", "scratched"=>"false"}
|
7
|
-
@data_object = Sportradar::Api::Soccer::Match.new(@attrs)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_it_initializes_a_soccer_match
|
11
|
-
|
12
|
-
assert [:status, :period].all? { |e| @data_object.attributes.include?(e) }
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_match_has_a_period_name
|
16
|
-
assert_equal "Period two", @data_object.period_name
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_match_has_a_status_description
|
20
|
-
assert_equal "The match is over", @data_object.status_description
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
data/soccer-old/player_test.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Sportradar::Api::Soccer::PlayerTest < Minitest::Test
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@attrs = {"id"=>"2aeacd39-3f9c-42af-957e-9df8573973c4", "first_name"=>"Kyle", "last_name"=>"Beckerman", "country_code"=>"USA", "country"=>"United States", "preferred_foot"=>"R", "birthdate"=>"1982-04-23", "height_in"=>"70", "weight_lb"=>"154", "height_cm"=>"177", "weight_kg"=>"69", "tactical_position" => "6", "full_first_name"=>"Kyle Robert", "full_last_name"=>"Beckerman", "teams"=> {"team"=> [{"id"=>"b78b9f61-0697-4347-a1b6-b7685a130eb1", "name"=>"Salt Lake", "full_name"=>"Real Salt Lake", "country_code"=>"USA", "country"=>"United States", "jersey_number"=>"5", "position"=>"M", "is_player"=>"true", "is_manager"=>"false"}, {"id"=>"79a99f09-13ca-45c4-b3f0-2a61f94e0651", "name"=>"USA", "full_name"=>"USA", "country_code"=>"USA", "country"=>"United States", "jersey_number"=>"15", "position"=>"M", "is_player"=>"true", "is_manager"=>"false"}]}, "statistics"=>{"season"=>[{"year"=>"2007", "statistic"=>{"goals"=>"0", "goal_frequency"=>"0", "goal_average"=>"0.0"}}]}}
|
7
|
-
@data_object = Sportradar::Api::Soccer::Player.new(@attrs)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_it_initializes_a_soccer_player
|
11
|
-
|
12
|
-
assert [:last_name, :first_name, :country, :country_code, :birthdate, :teams, :statistics].all? { |e| @data_object.attributes.include?(e) }
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_soccer_player_has_name
|
16
|
-
assert_equal [@data_object.first_name, @data_object.last_name].join(' '), @data_object.name
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_soccer_player_has_full_name
|
20
|
-
assert_equal [@data_object.full_first_name, @data_object.full_last_name].join(' '), @data_object.full_name
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_soccer_player_has_position_name
|
24
|
-
assert_equal "Midfielder", @data_object.position_name
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_soccer_player_has_tactical_position_name
|
28
|
-
assert_equal "Central Midfielder", @data_object.tactical_position_name
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_soccer_player_has_age
|
32
|
-
assert_equal 35, @data_object.age
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_soccer_player_has_height_in_feet
|
36
|
-
assert_equal "5' 10\"", @data_object.height_ft
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
end
|
data/soccer-old/ranking_test.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Sportradar::Api::Soccer::RankingTest < Minitest::Test
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@attrs = {"category"=> [{"id"=>"c4ef0886-dfee-4725-81eb-1bb919be832a", "name"=>"International Clubs", "country_code"=>"XZ", "country"=>"International", "reference_id"=>"sr:category:393", "tournament_group"=> {"id"=>"dc3ea36c-1a29-41e3-b830-9dd2c685670a", "name"=>"CONCACAF CL", "season_start"=>"2016-08-01T22:00:00Z", "season_end"=>"2017-04-27T21:59:00Z", "season"=>"2016", "reference_id"=>"sr:tournamentgroup:498", "tournament"=> [{"id"=>"f1651216-f4f1-4e61-bd58-92a80df54df3", "name"=>"CONCACAF Champions League, Group 6", "season_id"=>"42881571-769d-4877-9f85-71868dc510d1", "season_start"=>"2016-08-01T22:00:00Z", "season_end"=>"2017-04-27T21:59:00Z", "season"=>"2016", "type"=>"group", "type_group_id"=>"6", "reference_id"=>"sr:tournament:21399"}] } }] }
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_it_initializes_a_soccer_ranking
|
10
|
-
data_object = Sportradar::Api::Soccer::Ranking.new(@attrs)
|
11
|
-
assert [:categories].all? { |e| data_object.attributes.include?(e) }
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
data/soccer-old/schedule_test.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Sportradar::Api::Soccer::ScheduleTest < Minitest::Test
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@attrs = {"schedule"=> {"matches"=> {"match"=> [{"id"=>"3f7eb973-daab-49e5-b91a-6ab7cc1301a1", "status"=>"closed", "scheduled"=>"2016-09-30T00:00:00Z", "scratched"=>"false", "season_id"=>"42881571-769d-4877-9f85-71868dc510d1", "category"=> {"id"=>"c4ef0886-dfee-4725-81eb-1bb919be832a", "name"=>"International Clubs", "country_code"=>"XZ", "country"=>"International", }, "tournament_group"=> {"id"=>"dc3ea36c-1a29-41e3-b830-9dd2c685670a", "name"=>"CONCACAF CL", "season_start"=>"2016-08-01T22:00:00Z", "season_end"=>"2017-04-27T21:59:00Z", "season"=>"2016"}, "tournament"=> {"id"=>"c6b22c43-0e13-412a-9f0d-66ca1e3f9d51", "name"=>"CONCACAF Champions League, Group 5", "season_id"=>"42881571-769d-4877-9f85-71868dc510d1", "season_start"=>"2016-08-01T22:00:00Z", "season_end"=>"2017-04-27T21:59:00Z", "season"=>"2016", "type"=>"group", "type_group_id"=>"5", }, "home"=> {"id"=>"57ebb898-c0f3-473c-b8b6-47ed3473ad05", "name"=>"Police Utd", "full_name"=>"Police United", "alias"=>"POU", "country_code"=>"UNK", "country"=>"Unknown", "type"=>"team"}, "away"=> {"id"=>"d4fe17a0-745b-4abb-be38-20814a235258", "name"=>"Olimpia", "full_name"=>"CD Olimpia", "alias"=>"OLI", "country_code"=>"HND", "country"=>"Honduras", "type"=>"team"} } ] } } }
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_it_initializes_a_soccer_schedule
|
10
|
-
data_object = Sportradar::Api::Soccer::Schedule.new(@attrs)
|
11
|
-
assert [:matches].all? { |e| data_object.attributes.include?(e) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_it_finds_a_league_by_name
|
15
|
-
data_object = Sportradar::Api::Soccer::Schedule.new(@attrs)
|
16
|
-
assert_equal data_object.league("CONCACAF CL").first.tournament_group.name, "CONCACAF CL"
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_it_finds_available_leagues
|
20
|
-
data_object = Sportradar::Api::Soccer::Schedule.new(@attrs)
|
21
|
-
assert_includes data_object.available_leagues, "CONCACAF CL"
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
data/soccer-old/standing_test.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Sportradar::Api::Soccer::StandingTest < Minitest::Test
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@attrs = { "categories"=> {"category"=> [{"id"=>"ab5bfdbe-ed48-45e8-a6b9-eda3a8aaad3b", "name"=>"Mexico", "country_code"=>"MEX", "country"=>"Mexico", "tournament_group"=> {"id"=>"3baac5eb-2bd1-4561-ab76-b96d267dfe2a", "name"=>"Primera Division", "season_start"=>"2016-07-15T22:00:00Z", "season_end"=>"2017-06-24T21:59:00Z", "season"=>"2016", "reference_id"=>"sr:tournamentgroup:352", "tournament"=> [{"id"=>"3022ecee-5b9c-4e48-b6f8-7b0338e88b0f", "name"=>"Primera Division, Apertura", "season_id"=>"72a31835-d37e-470f-8370-b6b5e278fe60", "season_start"=>"2016-07-15T22:00:00Z", "season_end"=>"2017-06-24T21:59:00Z", "season"=>"2016", "type"=>"group", "reference_id"=>"sr:tournament:28", "team"=> [{"id"=>"50c96149-b75d-4961-83bf-516900533fb1", "name"=>"Tijuana", "full_name"=>"Club Tijuana", "alias"=>"TIJ", "country_code"=>"MEX", "country"=>"Mexico", "type"=>"team", "reference_id"=>"sr:team:36525", "rank"=>"1", "win"=>"7", "draw"=>"3", "loss"=>"1", "goals_for"=>"20", "goals_against"=>"9", "points"=>"24", "change"=>"1", "goals_diff"=>"11", "home"=> {"rank"=>"1", "change"=>"0", "win"=>"5", "draw"=>"0", "loss"=>"0", "goals_for"=>"11", "goals_against"=>"1", "points"=>"15"}, "away"=> {"rank"=>"2", "change"=>"5", "win"=>"2", "draw"=>"3", "loss"=>"1", "goals_for"=>"9", "goals_against"=>"8", "points"=>"9"}}] } ] } } ] } }
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_it_initializes_a_soccer_standing
|
10
|
-
data_object = Sportradar::Api::Soccer::Standing.new(@attrs)
|
11
|
-
assert [:categories].all? { |e| data_object.attributes.include?(e) }
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|