sportradar-api 0.1.4 → 0.1.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/data.rb +17 -0
- data/lib/sportradar/api/nfl/broadcast.rb +13 -0
- data/lib/sportradar/api/nfl/changelog.rb +39 -0
- data/lib/sportradar/api/nfl/coach.rb +17 -0
- data/lib/sportradar/api/nfl/conference.rb +28 -0
- data/lib/sportradar/api/nfl/depth_chart.rb +15 -0
- data/lib/sportradar/api/nfl/division.rb +28 -0
- data/lib/sportradar/api/nfl/draft.rb +16 -0
- data/lib/sportradar/api/nfl/drive.rb +38 -0
- data/lib/sportradar/api/nfl/event.rb +19 -0
- data/lib/sportradar/api/nfl/franchise.rb +15 -0
- data/lib/sportradar/api/nfl/game.rb +50 -0
- data/lib/sportradar/api/nfl/hierarchy.rb +39 -0
- data/lib/sportradar/api/nfl/injury.rb +16 -0
- data/lib/sportradar/api/nfl/play.rb +28 -0
- data/lib/sportradar/api/nfl/player.rb +52 -0
- data/lib/sportradar/api/nfl/position.rb +26 -0
- data/lib/sportradar/api/nfl/quarter.rb +17 -0
- data/lib/sportradar/api/nfl/scoring.rb +24 -0
- data/lib/sportradar/api/nfl/season.rb +31 -0
- data/lib/sportradar/api/nfl/situation.rb +17 -0
- data/lib/sportradar/api/nfl/statistic.rb +28 -0
- data/lib/sportradar/api/nfl/summary.rb +18 -0
- data/lib/sportradar/api/nfl/team.rb +59 -0
- data/lib/sportradar/api/nfl/venue.rb +22 -0
- data/lib/sportradar/api/nfl/week.rb +17 -0
- data/lib/sportradar/api/nfl.rb +49 -32
- data/lib/sportradar/api/soccer/boxscore.rb +2 -3
- data/lib/sportradar/api/soccer/category.rb +28 -0
- data/lib/sportradar/api/soccer/fact.rb +2 -2
- data/lib/sportradar/api/soccer/hierarchy.rb +26 -0
- data/lib/sportradar/api/soccer/match.rb +5 -5
- data/lib/sportradar/api/soccer/player.rb +47 -6
- data/lib/sportradar/api/soccer/ranking.rb +26 -0
- data/lib/sportradar/api/soccer/schedule.rb +3 -4
- data/lib/sportradar/api/soccer/season.rb +27 -0
- data/lib/sportradar/api/soccer/standing.rb +24 -0
- data/lib/sportradar/api/soccer/statistic.rb +14 -0
- data/lib/sportradar/api/soccer/summary.rb +3 -4
- data/lib/sportradar/api/soccer/team.rb +20 -13
- data/lib/sportradar/api/soccer/tournament.rb +33 -0
- data/lib/sportradar/api/soccer/tournament_group.rb +45 -0
- data/lib/sportradar/api/soccer/venue.rb +2 -2
- data/lib/sportradar/api/soccer.rb +8 -5
- data/lib/sportradar/api/version.rb +1 -1
- data/lib/sportradar/api.rb +35 -0
- metadata +36 -2
@@ -0,0 +1,59 @@
|
|
1
|
+
module Sportradar
|
2
|
+
module Api
|
3
|
+
class Nfl::Team < Data
|
4
|
+
attr_accessor :response, :id, :name, :alias, :game_number, :defense, :special_teams, :offense, :players, :statistics, :team_records, :player_records, :market, :franchise, :venue, :hierarchy, :coaches, :players
|
5
|
+
|
6
|
+
|
7
|
+
def initialize(data)
|
8
|
+
@response = data
|
9
|
+
@id = data["id"]
|
10
|
+
@name = data["name"]
|
11
|
+
@alias = data["alias"]
|
12
|
+
@game_number = data["game_number"]
|
13
|
+
@market = data["market"]
|
14
|
+
@franchise = Sportradar::Api::Nfl::Franchise.new data["franchise"] if data["franchise"]
|
15
|
+
@venue = Sportradar::Api::Nfl::Venue.new data["venue"] if data["venue"]
|
16
|
+
@hierarchy = Sportradar::Api::Nfl::Hierarchy.new data["hierarchy"] if data["hierarchy"]
|
17
|
+
|
18
|
+
@defense = data["defense"]["position"].map {|position| Sportradar::Api::Nfl::Position.new position } if data["defense"] && data["defense"]["position"]
|
19
|
+
@offense = data["offense"]["position"].map {|position| Sportradar::Api::Nfl::Position.new position } if data["offense"] && data["offense"]["position"]
|
20
|
+
@special_teams = data["special_teams"]["position"].map {|position| Sportradar::Api::Nfl::Position.new position } if data["special_teams"] && data["special_teams"]["position"]
|
21
|
+
@statistics = OpenStruct.new data["statistics"] if data["statistics"] # TODO Implement better?
|
22
|
+
@team_records = OpenStruct.new data["team_records"] if data["team_records"] # TODO Implement better?
|
23
|
+
@player_records = OpenStruct.new data["player_records"] if data["player_records"] # TODO Implement better?
|
24
|
+
|
25
|
+
set_players
|
26
|
+
set_coaches
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def set_players
|
32
|
+
if response["player"]
|
33
|
+
if response["player"].is_a?(Array)
|
34
|
+
@players = response["player"].map {|player| Sportradar::Api::Nfl::Player.new player }
|
35
|
+
elsif response["player"].is_a?(Hash)
|
36
|
+
@players = [ Sportradar::Api::Nfl::Player.new(response["player"]) ]
|
37
|
+
end
|
38
|
+
elsif response["players"] && response["players"]["player"]
|
39
|
+
if response["players"]["player"].is_a?(Array)
|
40
|
+
@players = response["players"]["player"].map {|player| Sportradar::Api::Nfl::Player.new player }
|
41
|
+
elsif response["players"]["player"].is_a?(Hash)
|
42
|
+
@players = [ Sportradar::Api::Nfl::Player.new(response["players"]["player"]) ]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def set_coaches
|
48
|
+
if response["coaches"] && response["coaches"]["coach"]
|
49
|
+
if response["coaches"]["coach"].is_a?(Array)
|
50
|
+
@coaches = response["coaches"]["coach"].map {|coach| Sportradar::Api::Nfl::Coach.new coach }
|
51
|
+
elsif response["coaches"]["coach"].is_a?(Hash)
|
52
|
+
@coaches = [ Sportradar::Api::Nfl::Coach.new(response["coaches"]["coach"]) ]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Sportradar
|
2
|
+
module Api
|
3
|
+
class Nfl::Venue < Data
|
4
|
+
attr_accessor :response, :id, :name, :city, :state, :country, :zip, :address, :capacity, :surface, :roof_type
|
5
|
+
|
6
|
+
def initialize(data)
|
7
|
+
@response = data
|
8
|
+
@id = data["id"]
|
9
|
+
@name = data["name"]
|
10
|
+
@city = data["city"]
|
11
|
+
@state = data["state"]
|
12
|
+
@country = data["country"]
|
13
|
+
@zip = data["zip"]
|
14
|
+
@address = data["address"]
|
15
|
+
@capacity = data["capacity"]
|
16
|
+
@surface = data["surface"]
|
17
|
+
@roof_type = data["roof_type"]
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Sportradar
|
2
|
+
module Api
|
3
|
+
class Nfl::Week < Data
|
4
|
+
attr_accessor :response, :id, :sequence, :title, :games
|
5
|
+
|
6
|
+
|
7
|
+
def initialize(data)
|
8
|
+
@response = data
|
9
|
+
@id = data["id"]
|
10
|
+
@sequence = data["sequence"]
|
11
|
+
@title = data["title"]
|
12
|
+
@games = data["game"].map {|game| Sportradar::Api::Nfl::Game.new game } if data["game"]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/sportradar/api/nfl.rb
CHANGED
@@ -3,72 +3,89 @@ module Sportradar
|
|
3
3
|
class Nfl < Request
|
4
4
|
attr_accessor :league, :access_level
|
5
5
|
|
6
|
-
def initialize( access_level =
|
7
|
-
@league =
|
6
|
+
def initialize( access_level = "ot")
|
7
|
+
@league = "nfl"
|
8
8
|
raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level
|
9
9
|
@access_level = access_level
|
10
10
|
end
|
11
11
|
|
12
|
-
def league_hierarchy
|
13
|
-
get request_url("league/hierarchy")
|
14
|
-
end
|
15
12
|
|
16
|
-
def schedule(year = Date.today.year, season =
|
13
|
+
def schedule(year = Date.today.year, season = "reg")
|
17
14
|
raise Sportradar::Api::Error::InvalidSeason unless allowed_seasons.include? season
|
18
|
-
get request_url("games/#{ year }/#{ season }/schedule")
|
19
|
-
|
20
|
-
|
21
|
-
def weekly_schedule(year = Date.today.year, season = 'reg', week = 1)
|
22
|
-
get request_url("games/#{ week_path(year, season, week) }/schedule")
|
23
|
-
end
|
24
|
-
|
25
|
-
def standings(year = Date.today.year)
|
26
|
-
get request_url("seasontd/#{ year }/standings")
|
15
|
+
response = get request_url("games/#{ year }/#{ season }/schedule")
|
16
|
+
Sportradar::Api::Nfl::Season.new response["season"] if response.success? && response["season"]
|
27
17
|
end
|
28
18
|
|
29
|
-
def
|
30
|
-
get request_url("
|
19
|
+
def weekly_schedule(week = 1, year = Date.today.year, season = "reg")
|
20
|
+
response = get request_url("games/#{ week_path(year, season, week) }/schedule")
|
21
|
+
Sportradar::Api::Nfl::Season.new response["season"] if response.success? && response["season"]
|
31
22
|
end
|
32
23
|
|
33
|
-
def
|
34
|
-
get request_url("seasontd/#{ week_path(year, season, week) }/
|
24
|
+
def weekly_depth_charts(week = 1, year = Date.today.year, season = "reg" )
|
25
|
+
response = get request_url("seasontd/#{ week_path(year, season, week) }/depth_charts")
|
26
|
+
Sportradar::Api::Nfl::DepthChart.new response
|
35
27
|
end
|
36
28
|
|
37
|
-
def
|
38
|
-
get request_url("
|
29
|
+
def weekly_injuries(week = 1, year = Date.today.year, season = "reg")
|
30
|
+
response = get request_url("seasontd/#{ week_path(year, season, week) }/injuries")
|
31
|
+
Sportradar::Api::Nfl::Season.new response["season"] if response.success? && response["season"]
|
39
32
|
end
|
40
33
|
|
41
34
|
# past_game_id = "0141a0a5-13e5-4b28-b19f-0c3923aaef6e"
|
42
35
|
# future_game_id = "28290722-4ceb-4a4c-a4e5-1f9bec7283b3"
|
43
36
|
def game_boxscore(game_id)
|
44
|
-
get request_url("games/#{ game_id }/boxscore")
|
37
|
+
response = get request_url("games/#{ game_id }/boxscore")
|
38
|
+
Sportradar::Api::Nfl::Game.new response["game"] if response.success? && response["game"] # mostly done, just missing play statistics
|
45
39
|
end
|
46
40
|
|
47
41
|
def game_roster(game_id)
|
48
|
-
get request_url("games/#{ game_id }/roster")
|
42
|
+
response = get request_url("games/#{ game_id }/roster")
|
43
|
+
Sportradar::Api::Nfl::Game.new response["game"] if response.success? && response["game"]
|
49
44
|
end
|
50
45
|
|
51
46
|
def game_statistics(game_id)
|
52
|
-
get request_url("games/#{ game_id }/statistics")
|
47
|
+
response = get request_url("games/#{ game_id }/statistics")
|
48
|
+
Sportradar::Api::Nfl::Game.new response["game"] if response.success? && response["game"]
|
49
|
+
## Need to properly implement statistics
|
53
50
|
end
|
54
51
|
|
55
52
|
def play_by_play(game_id)
|
56
|
-
get request_url("games/#{ game_id }/pbp")
|
53
|
+
response = get request_url("games/#{ game_id }/pbp")
|
54
|
+
Sportradar::Api::Nfl::Game.new response["game"] if response.success? && response["game"]
|
55
|
+
# need to get into quarters, drives, plays, stats more still
|
57
56
|
end
|
58
57
|
|
59
58
|
# player_id = "ede260be-5ae6-4a06-887b-e4a130932705"
|
60
59
|
def player_profile(player_id)
|
61
|
-
get request_url("players/#{ player_id }/profile")
|
60
|
+
response = get request_url("players/#{ player_id }/profile")
|
61
|
+
Sportradar::Api::Nfl::Player.new response["player"] if response.success? && response["player"]
|
62
62
|
end
|
63
63
|
|
64
64
|
# team_id = "97354895-8c77-4fd4-a860-32e62ea7382a"
|
65
|
-
def seasonal_statistics(team_id, year = Date.today.year, season =
|
65
|
+
def seasonal_statistics(team_id, year = Date.today.year, season = "reg")
|
66
66
|
raise Sportradar::Api::Error::InvalidLeague unless allowed_seasons.include? season
|
67
|
-
get request_url("seasontd/#{ year }/#{ season }/teams/#{ team_id }/statistics")
|
67
|
+
response = get request_url("seasontd/#{ year }/#{ season }/teams/#{ team_id }/statistics")
|
68
|
+
Sportradar::Api::Nfl::Season.new response["season"] if response.success? && response["season"]
|
68
69
|
end
|
69
70
|
|
70
71
|
def team_profile(team_id)
|
71
|
-
get request_url("teams/#{ team_id }/profile")
|
72
|
+
response = get request_url("teams/#{ team_id }/profile")
|
73
|
+
Sportradar::Api::Nfl::Team.new response["team"] if response.success? && response["team"]
|
74
|
+
end
|
75
|
+
|
76
|
+
def league_hierarchy
|
77
|
+
response = get request_url("league/hierarchy")
|
78
|
+
Sportradar::Api::Nfl::Hierarchy.new response["league"] if response.success? && response["league"]
|
79
|
+
end
|
80
|
+
|
81
|
+
def standings(year = Date.today.year)
|
82
|
+
get request_url("seasontd/#{ year }/standings")
|
83
|
+
# TODO Needs implemented with more attention
|
84
|
+
end
|
85
|
+
|
86
|
+
def daily_change_log(date = Date.today)
|
87
|
+
response = get request_url("league/#{date_path(date)}/changes")
|
88
|
+
Sportradar::Api::Nfl::Changelog.new response["league"]["changelog"] if response.success? && response["league"] && response["league"]["changelog"]
|
72
89
|
end
|
73
90
|
|
74
91
|
private
|
@@ -82,15 +99,15 @@ module Sportradar
|
|
82
99
|
end
|
83
100
|
|
84
101
|
def version
|
85
|
-
Sportradar::Api.version(
|
102
|
+
Sportradar::Api.version("nfl")
|
86
103
|
end
|
87
104
|
|
88
105
|
def allowed_access_levels
|
89
|
-
[
|
106
|
+
["o", "ot"]
|
90
107
|
end
|
91
108
|
|
92
109
|
def allowed_seasons
|
93
|
-
[
|
110
|
+
["pre", "reg", "pst"]
|
94
111
|
end
|
95
112
|
end
|
96
113
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module Sportradar
|
2
2
|
module Api
|
3
|
-
class Soccer::Boxscore
|
4
|
-
attr_accessor :response, :
|
3
|
+
class Soccer::Boxscore < Data
|
4
|
+
attr_accessor :response, :matches
|
5
5
|
|
6
6
|
def initialize(data)
|
7
|
-
@updated_at = data["boxscore"]["generated"]
|
8
7
|
@response = data
|
9
8
|
set_matches
|
10
9
|
end
|
@@ -0,0 +1,28 @@
|
|
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
|
+
set_tournament_group
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def set_tournament_group
|
17
|
+
if response["tournament_group"]
|
18
|
+
if response["tournament_group"].is_a?(Array)
|
19
|
+
@tournament_groups = response["tournament_group"].map {|x| Sportradar::Api::Soccer::TournamentGroup.new x }
|
20
|
+
elsif response["tournament_group"].is_a?(Hash)
|
21
|
+
@tournament_groups = [ Sportradar::Api::Soccer::TournamentGroup.new(response["tournament_group"]) ]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Sportradar
|
2
2
|
module Api
|
3
|
-
class Soccer::Fact
|
3
|
+
class Soccer::Fact < Data
|
4
4
|
|
5
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
6
|
|
7
7
|
def initialize(data)
|
8
|
+
@response = data
|
8
9
|
@id = data["id"]
|
9
10
|
@type = data["type"]
|
10
11
|
@time = data["time"]
|
@@ -30,7 +31,6 @@ module Sportradar
|
|
30
31
|
@assist1_id = data["assist1_id"]
|
31
32
|
@winner_id = data["winner_id"]
|
32
33
|
@draw = data["draw"]
|
33
|
-
@response = data
|
34
34
|
end
|
35
35
|
|
36
36
|
## Fact Types
|
@@ -0,0 +1,26 @@
|
|
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
|
+
set_categories
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def set_categories
|
14
|
+
if response["category"]
|
15
|
+
if response["category"].is_a?(Array)
|
16
|
+
@categories = response["category"].map {|x| Sportradar::Api::Soccer::Category.new x }
|
17
|
+
elsif response["category"].is_a?(Hash)
|
18
|
+
@categories = [ Sportradar::Api::Soccer::Category.new(response["category"]) ]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,21 +1,22 @@
|
|
1
1
|
module Sportradar
|
2
2
|
module Api
|
3
|
-
class Soccer::Match
|
3
|
+
class Soccer::Match < Data
|
4
4
|
|
5
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
|
6
6
|
|
7
7
|
def initialize(data)
|
8
|
+
@response = data
|
8
9
|
@id = data["id"]
|
9
10
|
@reference_id = data["reference_id"]
|
10
11
|
@scheduled = Date.parse data["scheduled"]
|
11
12
|
@scratched = data["scratched"] == "true"
|
12
13
|
@season_id = data["season_id"]
|
13
14
|
@status = data["status"]
|
14
|
-
@category =
|
15
|
+
@category = Sportradar::Api::Soccer::Category.new data["category"] if data["category"]
|
15
16
|
@coverage = OpenStruct.new data["coverage"]
|
16
17
|
@round = OpenStruct.new data["round"]
|
17
|
-
@tournament =
|
18
|
-
@tournament_group =
|
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"]
|
19
20
|
|
20
21
|
@away = Sportradar::Api::Soccer::Team.new data["away"]
|
21
22
|
@home = Sportradar::Api::Soccer::Team.new data["home"]
|
@@ -26,7 +27,6 @@ module Sportradar
|
|
26
27
|
@clock = data["clock"]
|
27
28
|
@referee = OpenStruct.new data["referee"] if data["referee"]
|
28
29
|
@facts = data["facts"]["fact"].map {|fact| Sportradar::Api::Soccer::Fact.new fact } if data["facts"]
|
29
|
-
@response = data
|
30
30
|
end
|
31
31
|
|
32
32
|
def period_name
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Sportradar
|
2
2
|
module Api
|
3
|
-
class Soccer::Player
|
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
|
3
|
+
class Soccer::Player < Data
|
6
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
|
7
6
|
|
8
7
|
def initialize(data)
|
8
|
+
@response = data
|
9
9
|
@id = data["id"]
|
10
10
|
@first_name = data["first_name"]
|
11
11
|
@last_name = data["last_name"]
|
@@ -19,6 +19,7 @@ module Sportradar
|
|
19
19
|
@jersey_number = data["jersey_number"]
|
20
20
|
@tactical_position = data["tactical_position"]
|
21
21
|
@tactical_order = data["tactical_order"]
|
22
|
+
@last_modified = data["last_modified"]
|
22
23
|
|
23
24
|
# profile
|
24
25
|
@preferred_foot = data["preferred_foot"]
|
@@ -27,10 +28,21 @@ module Sportradar
|
|
27
28
|
@weight_lb = data["weight_lb"]
|
28
29
|
@height_cm = data["height_cm"]
|
29
30
|
@weight_kg = data["weight_kg"]
|
30
|
-
|
31
|
+
set_teams
|
31
32
|
|
32
|
-
@
|
33
|
-
@
|
33
|
+
@rank = data["rank"]
|
34
|
+
@total = OpenStruct.new data["total"] if data["total"]
|
35
|
+
|
36
|
+
set_statistics
|
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
|
34
46
|
end
|
35
47
|
|
36
48
|
def position_name
|
@@ -42,6 +54,35 @@ module Sportradar
|
|
42
54
|
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" }
|
43
55
|
tactical_positions[tactical_position] if tactical_position
|
44
56
|
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def set_teams
|
61
|
+
if response["team"]
|
62
|
+
if response["team"].is_a?(Array)
|
63
|
+
@teams = response["team"].map {|team| Sportradar::Api::Soccer::Team.new team }
|
64
|
+
elsif response["team"].is_a?(Hash)
|
65
|
+
@teams = [ Sportradar::Api::Soccer::Team.new(response["team"]) ]
|
66
|
+
end
|
67
|
+
elsif response["teams"] && response["teams"]["team"]
|
68
|
+
if response["teams"]["team"].is_a?(Array)
|
69
|
+
@teams = response["teams"]["team"].map {|team| Sportradar::Api::Soccer::Team.new team }
|
70
|
+
elsif response["teams"]["team"].is_a?(Hash)
|
71
|
+
@teams = [ Sportradar::Api::Soccer::Team.new(response["teams"]["team"]) ]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def set_statistics
|
77
|
+
if response["statistics"] && response["statistics"]["season"]
|
78
|
+
if response["statistics"]["season"].is_a?(Array)
|
79
|
+
@statistics = response["statistics"]["season"].map {|statistic| Sportradar::Api::Soccer::Season.new statistic }
|
80
|
+
elsif response["statistics"]["season"].is_a?(Hash)
|
81
|
+
@statistics = [ Sportradar::Api::Soccer::Season.new(response["statistics"]["season"]) ]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
45
86
|
end
|
46
87
|
end
|
47
88
|
end
|
@@ -0,0 +1,26 @@
|
|
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
|
+
set_categories
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def set_categories
|
14
|
+
if response["category"]
|
15
|
+
if response["category"].is_a?(Array)
|
16
|
+
@categories = response["category"].map {|x| Sportradar::Api::Soccer::Category.new x }
|
17
|
+
elsif response["category"].is_a?(Hash)
|
18
|
+
@categories = [ Sportradar::Api::Soccer::Category.new(response["category"]) ]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
module Sportradar
|
2
2
|
module Api
|
3
|
-
class Soccer::Schedule
|
4
|
-
attr_accessor :response, :
|
3
|
+
class Soccer::Schedule < Data
|
4
|
+
attr_accessor :response, :matches
|
5
5
|
|
6
6
|
def initialize(data)
|
7
|
-
@updated_at = data["schedule"]["generated"]
|
8
|
-
@matches = data["schedule"]["matches"]["match"].map {|x| Sportradar::Api::Soccer::Match.new x } if data["schedule"]["matches"]["match"]
|
9
7
|
@response = data
|
8
|
+
@matches = data["schedule"]["matches"]["match"].map {|x| Sportradar::Api::Soccer::Match.new x } if data["schedule"]["matches"]["match"]
|
10
9
|
end
|
11
10
|
|
12
11
|
end
|
@@ -0,0 +1,27 @@
|
|
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
|
+
set_statistics
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def set_statistics
|
16
|
+
if response["statistic"]
|
17
|
+
if response["statistic"].is_a?(Array)
|
18
|
+
@statistics = response["statistic"].map {|statistic| Sportradar::Api::Soccer::Statistic.new statistic }
|
19
|
+
elsif response["statistic"].is_a?(Hash)
|
20
|
+
@statistics = [ Sportradar::Api::Soccer::Statistic.new(response["statistic"]) ]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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
|
+
set_categories
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def set_categories
|
14
|
+
if response["categories"] && response["categories"]["category"]
|
15
|
+
if response["categories"]["category"].is_a?(Array)
|
16
|
+
@categories = response["categories"]["category"].map {|x| Sportradar::Api::Soccer::Category.new x }
|
17
|
+
elsif response["categories"]["category"].is_a?(Hash)
|
18
|
+
@categories = [ Sportradar::Api::Soccer::Category.new(response["categories"]["category"]) ]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
module Sportradar
|
2
2
|
module Api
|
3
|
-
class Soccer::Summary
|
4
|
-
attr_accessor :response, :
|
3
|
+
class Soccer::Summary < Data
|
4
|
+
attr_accessor :response, :matches
|
5
5
|
|
6
6
|
def initialize(data)
|
7
|
-
@updated_at = data["summary"]["generated"]
|
8
7
|
@response = data
|
9
8
|
set_matches
|
10
|
-
|
11
9
|
end
|
10
|
+
|
12
11
|
private
|
13
12
|
|
14
13
|
def set_matches
|
@@ -1,26 +1,41 @@
|
|
1
1
|
module Sportradar
|
2
2
|
module Api
|
3
|
-
class Soccer::Team
|
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
|
4
5
|
|
5
|
-
attr_accessor :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, :response
|
6
6
|
|
7
7
|
def initialize(data)
|
8
|
+
@response = data
|
8
9
|
@id = data["id"]
|
9
10
|
@reference_id = data["reference_id"]
|
10
|
-
@id = data["id"]
|
11
11
|
@name = data["name"]
|
12
12
|
@full_name = data["full_name"]
|
13
13
|
@alias = data["alias"]
|
14
14
|
@country_code = data["country_code"]
|
15
15
|
@country = data["country"]
|
16
16
|
@type = data["type"]
|
17
|
-
@reference_id = data["reference_id"]
|
18
17
|
@formation = data["formation"]
|
19
18
|
@score = data["score"]
|
20
19
|
@regular_score = data["regular_score"]
|
21
20
|
@penalty_score = data["penalty_score"]
|
22
21
|
@winner = data["winner"]
|
23
|
-
@
|
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
|
+
@home = OpenStruct.new data["home"] if data["home"]
|
36
|
+
@away = OpenStruct.new data["away"] if data["away"]
|
37
|
+
|
38
|
+
@scoring = OpenStruct.new data["scoring"] if data["scoring"]
|
24
39
|
@first_half_score = data["scoring"]["half"].find {|x| x["number"] == "1"}["points"] if data["scoring"]
|
25
40
|
@second_half_score = data["scoring"]["half"].find {|x| x["number"] == "2"}["points"] if data["scoring"]
|
26
41
|
@statistics = OpenStruct.new data["statistics"] if data["statistics"]
|
@@ -28,14 +43,6 @@ module Sportradar
|
|
28
43
|
|
29
44
|
@players = data["roster"]["player"].map {|player| Sportradar::Api::Soccer::Player.new player } if data["roster"]
|
30
45
|
@manager = Sportradar::Api::Soccer::Player.new data["manager"] if data["manager"]
|
31
|
-
|
32
|
-
# player teams info
|
33
|
-
@jersey_number = data["jersey_number"]
|
34
|
-
@position = data["position"]
|
35
|
-
@is_player = data["is_player"]
|
36
|
-
@is_manager = data["is_manager"]
|
37
|
-
|
38
|
-
@response = data
|
39
46
|
end
|
40
47
|
|
41
48
|
alias_method :roster, :players
|