sportradar-api 0.12.3 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/lib/sportradar/api/baseball/game.rb +6 -2
- data/lib/sportradar/api/baseball/mlb.rb +1 -1
- data/lib/sportradar/api/baseball/pitch.rb +5 -0
- data/lib/sportradar/api/basketball/game.rb +14 -2
- data/lib/sportradar/api/basketball/nba/player.rb +2 -2
- data/lib/sportradar/api/basketball/nba.rb +1 -1
- data/lib/sportradar/api/basketball/plays/base.rb +1 -1
- data/lib/sportradar/api/data.rb +2 -1
- data/lib/sportradar/api/error.rb +1 -1
- data/lib/sportradar/api/images.rb +1 -1
- data/lib/sportradar/api/request.rb +22 -1
- data/lib/sportradar/api/soccer/api.rb +66 -0
- data/lib/sportradar/api/soccer/event.rb +45 -0
- data/lib/sportradar/api/soccer/fact.rb +56 -53
- data/lib/sportradar/api/soccer/group.rb +70 -0
- data/lib/sportradar/api/soccer/lineup.rb +31 -0
- data/lib/sportradar/api/soccer/match.rb +224 -44
- data/lib/sportradar/api/soccer/player.rb +54 -67
- data/lib/sportradar/api/soccer/season.rb +58 -7
- data/lib/sportradar/api/soccer/standing.rb +43 -6
- data/lib/sportradar/api/soccer/team.rb +155 -53
- data/lib/sportradar/api/soccer/team_group.rb +57 -0
- data/lib/sportradar/api/soccer/tournament.rb +302 -14
- data/lib/sportradar/api/soccer/venue.rb +14 -13
- data/lib/sportradar/api/{soccer → soccer-old}/boxscore.rb +0 -0
- data/lib/sportradar/api/{soccer → soccer-old}/category.rb +0 -0
- data/lib/sportradar/api/soccer-old/fact.rb +61 -0
- data/lib/sportradar/api/{soccer → soccer-old}/hierarchy.rb +0 -0
- data/lib/sportradar/api/soccer-old/match.rb +55 -0
- data/lib/sportradar/api/soccer-old/player.rb +88 -0
- data/lib/sportradar/api/{soccer → soccer-old}/ranking.rb +0 -0
- data/lib/sportradar/api/{soccer → soccer-old}/schedule.rb +0 -0
- data/lib/sportradar/api/soccer-old/season.rb +14 -0
- data/lib/sportradar/api/soccer-old/standing.rb +13 -0
- data/lib/sportradar/api/{soccer → soccer-old}/statistic.rb +0 -0
- data/lib/sportradar/api/{soccer → soccer-old}/summary.rb +0 -0
- data/lib/sportradar/api/soccer-old/team.rb +63 -0
- data/lib/sportradar/api/soccer-old/tournament.rb +20 -0
- data/lib/sportradar/api/{soccer → soccer-old}/tournament_group.rb +0 -0
- data/lib/sportradar/api/soccer-old/venue.rb +21 -0
- data/lib/sportradar/api/soccer-old.rb +158 -0
- data/lib/sportradar/api/soccer.rb +18 -152
- data/lib/sportradar/api/version.rb +1 -1
- data/lib/sportradar/api.rb +17 -18
- data/soccer-old/boxscore_test.rb +14 -0
- data/soccer-old/hierarchy_test.rb +14 -0
- data/soccer-old/match_test.rb +23 -0
- data/soccer-old/player_test.rb +40 -0
- data/soccer-old/ranking_test.rb +16 -0
- data/soccer-old/schedule_test.rb +24 -0
- data/soccer-old/standing_test.rb +14 -0
- data/soccer-old/summary_test.rb +14 -0
- data/soccer-old/team_test.rb +21 -0
- data/soccer-old_test.rb +184 -0
- metadata +34 -10
@@ -0,0 +1,61 @@
|
|
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
|
File without changes
|
@@ -0,0 +1,55 @@
|
|
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
|
@@ -0,0 +1,88 @@
|
|
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
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
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
|
@@ -0,0 +1,13 @@
|
|
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
|
File without changes
|
File without changes
|
@@ -0,0 +1,63 @@
|
|
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
|
@@ -0,0 +1,20 @@
|
|
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
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
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
|
@@ -0,0 +1,158 @@
|
|
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
|