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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +3 -3
  5. data/lib/sportradar/api/baseball/game.rb +6 -2
  6. data/lib/sportradar/api/baseball/mlb.rb +1 -1
  7. data/lib/sportradar/api/baseball/pitch.rb +5 -0
  8. data/lib/sportradar/api/basketball/game.rb +14 -2
  9. data/lib/sportradar/api/basketball/nba/player.rb +2 -2
  10. data/lib/sportradar/api/basketball/nba.rb +1 -1
  11. data/lib/sportradar/api/basketball/plays/base.rb +1 -1
  12. data/lib/sportradar/api/data.rb +2 -1
  13. data/lib/sportradar/api/error.rb +1 -1
  14. data/lib/sportradar/api/images.rb +1 -1
  15. data/lib/sportradar/api/request.rb +22 -1
  16. data/lib/sportradar/api/soccer/api.rb +66 -0
  17. data/lib/sportradar/api/soccer/event.rb +45 -0
  18. data/lib/sportradar/api/soccer/fact.rb +56 -53
  19. data/lib/sportradar/api/soccer/group.rb +70 -0
  20. data/lib/sportradar/api/soccer/lineup.rb +31 -0
  21. data/lib/sportradar/api/soccer/match.rb +224 -44
  22. data/lib/sportradar/api/soccer/player.rb +54 -67
  23. data/lib/sportradar/api/soccer/season.rb +58 -7
  24. data/lib/sportradar/api/soccer/standing.rb +43 -6
  25. data/lib/sportradar/api/soccer/team.rb +155 -53
  26. data/lib/sportradar/api/soccer/team_group.rb +57 -0
  27. data/lib/sportradar/api/soccer/tournament.rb +302 -14
  28. data/lib/sportradar/api/soccer/venue.rb +14 -13
  29. data/lib/sportradar/api/{soccer → soccer-old}/boxscore.rb +0 -0
  30. data/lib/sportradar/api/{soccer → soccer-old}/category.rb +0 -0
  31. data/lib/sportradar/api/soccer-old/fact.rb +61 -0
  32. data/lib/sportradar/api/{soccer → soccer-old}/hierarchy.rb +0 -0
  33. data/lib/sportradar/api/soccer-old/match.rb +55 -0
  34. data/lib/sportradar/api/soccer-old/player.rb +88 -0
  35. data/lib/sportradar/api/{soccer → soccer-old}/ranking.rb +0 -0
  36. data/lib/sportradar/api/{soccer → soccer-old}/schedule.rb +0 -0
  37. data/lib/sportradar/api/soccer-old/season.rb +14 -0
  38. data/lib/sportradar/api/soccer-old/standing.rb +13 -0
  39. data/lib/sportradar/api/{soccer → soccer-old}/statistic.rb +0 -0
  40. data/lib/sportradar/api/{soccer → soccer-old}/summary.rb +0 -0
  41. data/lib/sportradar/api/soccer-old/team.rb +63 -0
  42. data/lib/sportradar/api/soccer-old/tournament.rb +20 -0
  43. data/lib/sportradar/api/{soccer → soccer-old}/tournament_group.rb +0 -0
  44. data/lib/sportradar/api/soccer-old/venue.rb +21 -0
  45. data/lib/sportradar/api/soccer-old.rb +158 -0
  46. data/lib/sportradar/api/soccer.rb +18 -152
  47. data/lib/sportradar/api/version.rb +1 -1
  48. data/lib/sportradar/api.rb +17 -18
  49. data/soccer-old/boxscore_test.rb +14 -0
  50. data/soccer-old/hierarchy_test.rb +14 -0
  51. data/soccer-old/match_test.rb +23 -0
  52. data/soccer-old/player_test.rb +40 -0
  53. data/soccer-old/ranking_test.rb +16 -0
  54. data/soccer-old/schedule_test.rb +24 -0
  55. data/soccer-old/standing_test.rb +14 -0
  56. data/soccer-old/summary_test.rb +14 -0
  57. data/soccer-old/team_test.rb +21 -0
  58. data/soccer-old_test.rb +184 -0
  59. metadata +34 -10
@@ -1,157 +1,23 @@
1
+ require_relative 'soccer/api'
2
+ require_relative 'soccer/group'
3
+ require_relative 'soccer/tournament'
4
+ require_relative 'soccer/standing'
5
+ require_relative 'soccer/team_group'
6
+ require_relative 'soccer/season'
7
+ require_relative 'soccer/match'
8
+ require_relative 'soccer/event'
9
+ require_relative 'soccer/lineup'
10
+ require_relative 'soccer/team'
11
+ require_relative 'soccer/player'
12
+ require_relative 'soccer/venue'
13
+ require_relative 'soccer/fact'
14
+
1
15
  module Sportradar
2
16
  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"]
17
+ module Soccer
18
+
19
+ def self.parse_results(arr)
20
+ arr.map { |hash| hash["sport_event"].merge(hash["sport_event_status"]) }
155
21
  end
156
22
  end
157
23
  end
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.12.3"
3
+ VERSION = "0.13.0"
4
4
  end
5
5
  end
@@ -13,23 +13,6 @@ require "sportradar/api/poll"
13
13
  require "sportradar/api/broadcast"
14
14
 
15
15
  require "sportradar/api/soccer"
16
- require "sportradar/api/soccer/boxscore"
17
- require "sportradar/api/soccer/category"
18
- require "sportradar/api/soccer/fact"
19
- require "sportradar/api/soccer/hierarchy"
20
- require "sportradar/api/soccer/match"
21
- require "sportradar/api/soccer/player"
22
- require "sportradar/api/soccer/ranking"
23
- require "sportradar/api/soccer/schedule"
24
- require "sportradar/api/soccer/season"
25
- require "sportradar/api/soccer/standing"
26
- require "sportradar/api/soccer/statistic"
27
- require "sportradar/api/soccer/summary"
28
- require "sportradar/api/soccer/team"
29
- require "sportradar/api/soccer/tournament"
30
- require "sportradar/api/soccer/tournament_group"
31
- require "sportradar/api/soccer/venue"
32
-
33
16
  require "sportradar/api/football"
34
17
  require "sportradar/api/basketball"
35
18
  require "sportradar/api/baseball"
@@ -80,7 +63,7 @@ module Sportradar
80
63
  {api: :images, version: 2},
81
64
  {api: :live_images, version: 1},
82
65
  {api: :olympics, version: 2},
83
- {api: :soccer, version: 2},
66
+ {api: :soccer, version: 3},
84
67
  {api: :ncaawb, version: 3},
85
68
  {api: :mma, version: 1},
86
69
  {api: :cricket, version: 1},
@@ -109,4 +92,20 @@ module Sportradar
109
92
  end
110
93
 
111
94
  end
95
+
96
+ def self.ordinalize_period(i)
97
+ case i
98
+ when 1
99
+ '1st'
100
+ when 2
101
+ '2nd'
102
+ when 3
103
+ '3rd'
104
+ when nil
105
+ ''
106
+ else
107
+ "#{i}th"
108
+ end
109
+ end
110
+
112
111
  end
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,23 @@
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
@@ -0,0 +1,40 @@
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
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,24 @@
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
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class Sportradar::Api::Soccer::SummaryTest < Minitest::Test
4
+
5
+ def setup
6
+ @attrs = {"summary"=> {"matches"=> {"match"=> {"id"=>"357607e9-87cd-4848-b53e-0485d9c1a3bc", "status"=>"closed", "period"=>"P2", "scheduled"=>"2016-07-13T23:00:00Z", "clock"=>"", "scratched"=>"false", "season_id"=>"34913769-58a6-487d-aa7a-1883c8f87909", "coverage"=> {"lineups"=>"2", "tactical_lineups"=>"true", "corner_facts"=>"true", "extended_facts"=>"true"} } } } }
7
+ end
8
+
9
+ def test_it_initializes_a_soccer_summary
10
+ data_object = Sportradar::Api::Soccer::Summary.new(@attrs)
11
+ assert [:matches].all? { |e| data_object.attributes.include?(e) }
12
+ end
13
+
14
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class Sportradar::Api::Soccer::TeamTest < Minitest::Test
4
+
5
+ def setup
6
+ @attrs = {"id"=>"b78b9f61-0697-4347-a1b6-b7685a130eb1", "name"=>"Salt Lake", "full_name"=>"Real Salt Lake", "alias"=>"SAL", "country_code"=>"USA", "country"=>"United States", "type"=>"team", "reference_id"=>"sr:team:5133", "manager"=> {"id"=>"c0456c5f-51a0-4d12-996f-e3b2a1c7945c", "first_name"=>"Jeff", "last_name"=>"Cassar", "country_code"=>"USA", "country"=>"United States", "birthdate"=>"1974-02-02", "reference_id"=>"sr:manager:539898"}, "roster"=> {"player"=> [{"id"=>"640f8388-9feb-4142-933f-204aecb7ae9f", "first_name"=>"Justen", "last_name"=>"Glad"}] } }
7
+ end
8
+
9
+ def test_it_initializes_a_soccer_team
10
+ data_object = Sportradar::Api::Soccer::Team.new(@attrs)
11
+ assert [:name, :full_name, :alias, :country, :country_code, :manager, :players].all? { |e| data_object.attributes.include?(e) }
12
+ end
13
+
14
+ def test_it_parses_a_scoring_hash
15
+ data_object = Sportradar::Api::Soccer::Team.new(@attrs.merge("scoring"=>{"half"=>{"points"=>"0", "number"=>"1"}} ) )
16
+ assert_equal data_object.first_half_score, "0"
17
+
18
+ end
19
+
20
+
21
+ end
@@ -0,0 +1,184 @@
1
+ require 'test_helper'
2
+
3
+ class Sportradar::Api::SoccerTest < Minitest::Test
4
+
5
+ def match_id
6
+ "357607e9-87cd-4848-b53e-0485d9c1a3bc"
7
+ end
8
+
9
+ def team_id
10
+ "b78b9f61-0697-4347-a1b6-b7685a130eb1"
11
+ end
12
+
13
+ def player_id
14
+ "2aeacd39-3f9c-42af-957e-9df8573973c4"
15
+ end
16
+
17
+ def simulation_game_id
18
+ "22653ed5-0b2c-4e30-b10c-c6d51619b52b"
19
+ end
20
+
21
+ def test_it_accepts_a_valid_access_level
22
+ good = Sportradar::Api::Soccer.new
23
+ assert_kind_of Sportradar::Api::Soccer, good
24
+ assert_raises Sportradar::Api::Error::InvalidAccessLevel do
25
+ Sportradar::Api::Soccer.new('na', 'dumb')
26
+ end
27
+ end
28
+
29
+ def test_it_accepts_a_valid_league
30
+ good = Sportradar::Api::Soccer.new
31
+ assert_kind_of Sportradar::Api::Soccer, good
32
+ assert_raises Sportradar::Api::Error::InvalidLeague do
33
+ Sportradar::Api::Soccer.new('dumb', 't')
34
+ end
35
+ end
36
+
37
+ def test_it_makes_a_good_schedule_request
38
+ VCR.use_cassette("soccer good schedule request") do
39
+ request = Sportradar::Api::Soccer.new.schedule
40
+ assert_kind_of Sportradar::Api::Soccer::Schedule, request
41
+ end
42
+ end
43
+
44
+ def test_it_makes_a_good_daily_schedule_request
45
+ VCR.use_cassette("soccer good daily schedule request") do
46
+ request = Sportradar::Api::Soccer.new.daily_schedule(good_date)
47
+ assert_kind_of Sportradar::Api::Soccer::Schedule, request
48
+ assert request.matches.present?
49
+ end
50
+ end
51
+
52
+ def test_it_makes_a_bad_daily_schedule_request
53
+ VCR.use_cassette("soccer bad daily schedule request") do
54
+ request = Sportradar::Api::Soccer.new.daily_schedule(old_date)
55
+ assert_kind_of Sportradar::Api::Soccer::Schedule, request
56
+ refute request.matches.present?
57
+ end
58
+ end
59
+
60
+ def test_it_makes_a_good_daily_summary_request
61
+ VCR.use_cassette("soccer good daily summary request") do
62
+ request = Sportradar::Api::Soccer.new.daily_summary(good_date)
63
+ assert_kind_of Sportradar::Api::Soccer::Summary, request
64
+ assert request.matches.present?
65
+ end
66
+ end
67
+
68
+ def test_it_makes_a_bad_daily_summary_request
69
+ VCR.use_cassette("soccer bad daily summary request") do
70
+ request = Sportradar::Api::Soccer.new.daily_summary(old_date)
71
+ assert_kind_of Sportradar::Api::Soccer::Summary, request
72
+ refute request.matches.present?
73
+ end
74
+ end
75
+
76
+ def test_it_makes_a_good_daily_boxscore_request
77
+ VCR.use_cassette("soccer good daily boxscore request") do
78
+ request = Sportradar::Api::Soccer.new.daily_boxscore(good_date)
79
+ assert_kind_of Sportradar::Api::Soccer::Boxscore, request
80
+ assert request.matches.present?
81
+ end
82
+ end
83
+
84
+ def test_it_makes_a_bad_daily_boxscore_request
85
+ VCR.use_cassette("soccer bad daily boxscore request") do
86
+ request = Sportradar::Api::Soccer.new.daily_boxscore(old_date)
87
+ assert_kind_of Sportradar::Api::Soccer::Boxscore, request
88
+ refute request.matches.present?
89
+ end
90
+ end
91
+
92
+ def test_it_makes_a_good_match_summary_request
93
+ VCR.use_cassette("soccer good match summary request") do
94
+ request = Sportradar::Api::Soccer.new.match_summary(match_id)
95
+ assert_kind_of Sportradar::Api::Soccer::Summary, request
96
+ assert request.matches.present?
97
+ end
98
+ end
99
+
100
+ def test_it_makes_a_bad_match_summary_request
101
+ VCR.use_cassette("soccer bad match summary request") do
102
+ request = Sportradar::Api::Soccer.new.match_summary('dumb')
103
+ assert_kind_of Sportradar::Api::Error, request
104
+ end
105
+ end
106
+
107
+ def test_it_makes_a_good_match_boxscore_request
108
+ VCR.use_cassette("soccer good match boxscore request") do
109
+ request = Sportradar::Api::Soccer.new.match_boxscore(match_id)
110
+ assert_kind_of Sportradar::Api::Soccer::Boxscore, request
111
+ assert request.matches.present?
112
+ end
113
+ end
114
+
115
+ def test_it_makes_a_bad_match_boxscore_request
116
+ VCR.use_cassette("soccer bad match boxscore request") do
117
+ request = Sportradar::Api::Soccer.new.match_boxscore('dumb')
118
+ assert_kind_of Sportradar::Api::Error, request
119
+ end
120
+ end
121
+
122
+ def test_it_makes_a_good_team_profile_request
123
+ VCR.use_cassette("soccer good team profile request") do
124
+ request = Sportradar::Api::Soccer.new.team_profile(team_id)
125
+ assert_kind_of Sportradar::Api::Soccer::Team, request
126
+ end
127
+ end
128
+
129
+ def test_it_makes_a_bad_team_profile_request
130
+ VCR.use_cassette("soccer bad team profile request") do
131
+ request = Sportradar::Api::Soccer.new.team_profile('dumb')
132
+ assert_kind_of Sportradar::Api::Error, request
133
+ end
134
+ end
135
+
136
+ def test_it_makes_a_good_player_profile_request
137
+ VCR.use_cassette("soccer good player profile request") do
138
+ request = Sportradar::Api::Soccer.new.player_profile(player_id)
139
+ assert_kind_of Sportradar::Api::Soccer::Player, request
140
+ end
141
+ end
142
+
143
+ def test_it_makes_a_bad_player_profile_request
144
+ VCR.use_cassette("soccer bad player profile request") do
145
+ request = Sportradar::Api::Soccer.new.player_profile('dumb')
146
+ refute_kind_of Sportradar::Api::Soccer::Player, request
147
+ end
148
+ end
149
+
150
+ def test_it_makes_a_good_player_rankings_request
151
+ VCR.use_cassette("soccer good player rankings request") do
152
+ request = Sportradar::Api::Soccer.new.player_rankings
153
+ assert_kind_of Sportradar::Api::Soccer::Ranking, request
154
+ end
155
+ end
156
+
157
+ def test_it_makes_a_good_team_hierarchy_request
158
+ VCR.use_cassette("soccer good team hierarchy request") do
159
+ request = Sportradar::Api::Soccer.new.team_hierarchy
160
+ assert_kind_of Sportradar::Api::Soccer::Hierarchy, request
161
+ end
162
+ end
163
+
164
+ def test_it_makes_a_good_team_standings_request
165
+ VCR.use_cassette("soccer good team standings request") do
166
+ request = Sportradar::Api::Soccer.new.team_standings
167
+ assert_kind_of Sportradar::Api::Soccer::Standing, request
168
+ end
169
+ end
170
+
171
+
172
+ def test_simulation_match
173
+ assert_equal simulation_game_id, Sportradar::Api::Soccer.new.simulation_match
174
+ end
175
+
176
+ def test_it_makes_a_good_simulation_match_boxscore_request
177
+ VCR.use_cassette("soccer good simulation match boxscore request") do
178
+ request = Sportradar::Api::Soccer.new.match_boxscore(simulation_game_id)
179
+ assert_kind_of Sportradar::Api::Soccer::Boxscore, request
180
+ end
181
+ end
182
+
183
+
184
+ end