sportradar-api 0.1.38 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +13 -10
- data/Guardfile +7 -0
- data/lib/sportradar/api/config.rb +4 -5
- data/lib/sportradar/api/content.rb +12 -4
- data/lib/sportradar/api/content/article.rb +1 -12
- data/lib/sportradar/api/content/article_list.rb +1 -12
- data/lib/sportradar/api/data.rb +16 -0
- data/lib/sportradar/api/error.rb +5 -2
- data/lib/sportradar/api/football/stat_pack.rb +4 -17
- data/lib/sportradar/api/football/stat_pack/defense.rb +1 -1
- data/lib/sportradar/api/football/stat_pack/extra_points.rb +4 -4
- data/lib/sportradar/api/football/stat_pack/passing.rb +1 -1
- data/lib/sportradar/api/football/stat_pack/penalties.rb +4 -3
- data/lib/sportradar/api/football/stat_pack/rushing.rb +1 -1
- data/lib/sportradar/api/images.rb +19 -6
- data/lib/sportradar/api/images/asset.rb +2 -26
- data/lib/sportradar/api/images/asset_list.rb +1 -12
- data/lib/sportradar/api/live_images.rb +5 -1
- data/lib/sportradar/api/nfl.rb +73 -17
- data/lib/sportradar/api/nfl/changelog.rb +2 -24
- data/lib/sportradar/api/nfl/conference.rb +1 -13
- data/lib/sportradar/api/nfl/depth_chart.rb +1 -0
- data/lib/sportradar/api/nfl/division.rb +1 -13
- data/lib/sportradar/api/nfl/drive.rb +2 -20
- data/lib/sportradar/api/nfl/franchise.rb +0 -1
- data/lib/sportradar/api/nfl/game.rb +14 -14
- data/lib/sportradar/api/nfl/game_statistic.rb +73 -15
- data/lib/sportradar/api/nfl/hierarchy.rb +3 -30
- data/lib/sportradar/api/nfl/league_depth_chart.rb +1 -4
- data/lib/sportradar/api/nfl/play.rb +11 -5
- data/lib/sportradar/api/nfl/player.rb +6 -10
- data/lib/sportradar/api/nfl/position.rb +1 -13
- data/lib/sportradar/api/nfl/quarter.rb +1 -6
- data/lib/sportradar/api/nfl/scoring.rb +4 -4
- data/lib/sportradar/api/nfl/season.rb +4 -44
- data/lib/sportradar/api/nfl/team.rb +6 -35
- data/lib/sportradar/api/nfl/team_depth_chart.rb +8 -7
- data/lib/sportradar/api/nfl/week.rb +1 -14
- data/lib/sportradar/api/request.rb +15 -18
- data/lib/sportradar/api/soccer.rb +55 -11
- data/lib/sportradar/api/soccer/boxscore.rb +1 -12
- data/lib/sportradar/api/soccer/category.rb +1 -12
- data/lib/sportradar/api/soccer/hierarchy.rb +2 -14
- data/lib/sportradar/api/soccer/match.rb +3 -3
- data/lib/sportradar/api/soccer/player.rb +4 -31
- data/lib/sportradar/api/soccer/ranking.rb +1 -14
- data/lib/sportradar/api/soccer/schedule.rb +1 -12
- data/lib/sportradar/api/soccer/season.rb +1 -14
- data/lib/sportradar/api/soccer/standing.rb +1 -12
- data/lib/sportradar/api/soccer/summary.rb +1 -13
- data/lib/sportradar/api/soccer/team.rb +4 -3
- data/lib/sportradar/api/soccer/tournament.rb +1 -14
- data/lib/sportradar/api/soccer/tournament_group.rb +1 -11
- data/lib/sportradar/api/version.rb +1 -1
- data/sportradar-api.gemspec +2 -0
- metadata +17 -3
- data/lib/sportradar/api/nfl/stat.rb +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7ab71356ca8ef7269e48d33fa48e0e3c3873805f
|
|
4
|
+
data.tar.gz: 735eaa178acfb965fee08b05b605b1feac531163
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c7e016ad2c0f78ce88b1eae511749e30a49c3a715fb7384ecc6a48659026bf9a74cc2742942b0ccfa623e22dbb2d25855fc41b062c09ceedd11d03fd4f205e3
|
|
7
|
+
data.tar.gz: 5c406a3ad852e7b30d5db2893820870b6cdfcc3d85e8b9276526eb0639d3a8c26cdbe8dfebb06eaedb8630769758041301a48382d09dfc60b11f810c37e9f710
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
sportradar-api (0.
|
|
4
|
+
sportradar-api (0.9.0)
|
|
5
5
|
activesupport
|
|
6
6
|
httparty (>= 0.14.0)
|
|
7
7
|
|
|
@@ -14,14 +14,16 @@ GEM
|
|
|
14
14
|
minitest (~> 5.1)
|
|
15
15
|
tzinfo (~> 1.1)
|
|
16
16
|
addressable (2.4.0)
|
|
17
|
+
codeclimate-test-reporter (0.6.0)
|
|
18
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
|
17
19
|
coderay (1.1.1)
|
|
18
20
|
concurrent-ruby (1.0.2)
|
|
19
|
-
coveralls (0.8.
|
|
21
|
+
coveralls (0.8.15)
|
|
20
22
|
json (>= 1.8, < 3)
|
|
21
23
|
simplecov (~> 0.12.0)
|
|
22
24
|
term-ansicolor (~> 1.3)
|
|
23
25
|
thor (~> 0.19.1)
|
|
24
|
-
tins (
|
|
26
|
+
tins (>= 1.6.0, < 2)
|
|
25
27
|
crack (0.4.3)
|
|
26
28
|
safe_yaml (~> 1.0.0)
|
|
27
29
|
docile (1.1.5)
|
|
@@ -38,26 +40,26 @@ GEM
|
|
|
38
40
|
shellany (~> 0.0)
|
|
39
41
|
thor (>= 0.18.1)
|
|
40
42
|
guard-compat (1.2.1)
|
|
41
|
-
guard-minitest (2.4.
|
|
43
|
+
guard-minitest (2.4.6)
|
|
42
44
|
guard-compat (~> 1.2)
|
|
43
45
|
minitest (>= 3.0)
|
|
44
46
|
hashdiff (0.3.0)
|
|
45
47
|
httparty (0.14.0)
|
|
46
48
|
multi_xml (>= 0.5.2)
|
|
47
49
|
i18n (0.7.0)
|
|
48
|
-
json (
|
|
50
|
+
json (2.0.2)
|
|
49
51
|
listen (3.1.5)
|
|
50
52
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
51
53
|
rb-inotify (~> 0.9, >= 0.9.7)
|
|
52
54
|
ruby_dep (~> 1.2)
|
|
53
55
|
lumberjack (1.0.10)
|
|
54
56
|
method_source (0.8.2)
|
|
55
|
-
minitest (5.9.
|
|
57
|
+
minitest (5.9.1)
|
|
56
58
|
minitest-focus (1.1.2)
|
|
57
59
|
minitest (>= 4, < 6)
|
|
58
60
|
multi_xml (0.5.5)
|
|
59
61
|
nenv (0.3.0)
|
|
60
|
-
notiffany (0.1.
|
|
62
|
+
notiffany (0.1.1)
|
|
61
63
|
nenv (~> 0.1)
|
|
62
64
|
shellany (~> 0.0)
|
|
63
65
|
pry (0.10.4)
|
|
@@ -68,7 +70,7 @@ GEM
|
|
|
68
70
|
rb-fsevent (0.9.7)
|
|
69
71
|
rb-inotify (0.9.7)
|
|
70
72
|
ffi (>= 0.5.0)
|
|
71
|
-
ruby_dep (1.
|
|
73
|
+
ruby_dep (1.4.0)
|
|
72
74
|
safe_yaml (1.0.4)
|
|
73
75
|
shellany (0.0.1)
|
|
74
76
|
simplecov (0.12.0)
|
|
@@ -77,11 +79,11 @@ GEM
|
|
|
77
79
|
simplecov-html (~> 0.10.0)
|
|
78
80
|
simplecov-html (0.10.0)
|
|
79
81
|
slop (3.6.0)
|
|
80
|
-
term-ansicolor (1.
|
|
82
|
+
term-ansicolor (1.4.0)
|
|
81
83
|
tins (~> 1.0)
|
|
82
84
|
thor (0.19.1)
|
|
83
85
|
thread_safe (0.3.5)
|
|
84
|
-
tins (1.
|
|
86
|
+
tins (1.12.0)
|
|
85
87
|
tzinfo (1.2.2)
|
|
86
88
|
thread_safe (~> 0.1)
|
|
87
89
|
vcr (3.0.3)
|
|
@@ -95,6 +97,7 @@ PLATFORMS
|
|
|
95
97
|
|
|
96
98
|
DEPENDENCIES
|
|
97
99
|
bundler (~> 1.12)
|
|
100
|
+
codeclimate-test-reporter
|
|
98
101
|
coveralls
|
|
99
102
|
dotenv
|
|
100
103
|
guard
|
data/Guardfile
ADDED
|
@@ -14,7 +14,7 @@ module Sportradar
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
class Config
|
|
17
|
-
attr_accessor :
|
|
17
|
+
attr_accessor :api_timeout, :use_ssl, :format
|
|
18
18
|
|
|
19
19
|
def initialize
|
|
20
20
|
@api_key = ENV['API_KEY']
|
|
@@ -24,10 +24,9 @@ module Sportradar
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def reset
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
self.format = ENV.fetch("SPORTRADAR_API_FORMAT", :xml).to_s
|
|
27
|
+
@api_timeout = ENV.fetch('SPORTRADAR_API_TIMEOUT', 15 )
|
|
28
|
+
@use_ssl = ENV.fetch('SPORTRADAR_API_USE_SSL', true)
|
|
29
|
+
@format = ENV.fetch("SPORTRADAR_API_FORMAT", :xml).to_s
|
|
31
30
|
end
|
|
32
31
|
end
|
|
33
32
|
end
|
|
@@ -10,16 +10,24 @@ module Sportradar
|
|
|
10
10
|
@access_level = access_level
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def news( date = Date.today, content_type
|
|
13
|
+
def news( date = Date.today, content_type: 'all' )
|
|
14
14
|
raise Sportradar::Api::Error::InvalidType unless allowed_news_types.include? content_type
|
|
15
15
|
response = get request_url("#{provider }/news/#{date_path(date)}/#{content_type}")
|
|
16
|
-
|
|
16
|
+
if response.success? && response["content"]
|
|
17
|
+
Sportradar::Api::Content::ArticleList.new response["content"]
|
|
18
|
+
else
|
|
19
|
+
response
|
|
20
|
+
end
|
|
17
21
|
end
|
|
18
22
|
|
|
19
|
-
def analysis( date = Date.today, content_type
|
|
23
|
+
def analysis( date = Date.today, content_type: 'all' )
|
|
20
24
|
raise Sportradar::Api::Error::InvalidType unless allowed_analysis_types.include? content_type
|
|
21
25
|
response = get request_url("#{provider }/analysis/#{date_path(date)}/#{content_type}")
|
|
22
|
-
|
|
26
|
+
if response.success? && response["content"]
|
|
27
|
+
Sportradar::Api::Content::ArticleList.new response["content"]
|
|
28
|
+
else
|
|
29
|
+
response
|
|
30
|
+
end
|
|
23
31
|
end
|
|
24
32
|
|
|
25
33
|
private
|
|
@@ -16,7 +16,7 @@ module Sportradar
|
|
|
16
16
|
@credit = data["credit"]
|
|
17
17
|
@content = data["content"]["long"] if data["content"] && data["content"]["long"]
|
|
18
18
|
@provider = OpenStruct.new(data["provider"]) if data["provider"]
|
|
19
|
-
|
|
19
|
+
@references = parse_into_array(selector: response["refs"]["ref"], klass: Sportradar::Api::Content::Reference) if response["refs"] && response["refs"]["ref"]
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def transaction?
|
|
@@ -27,17 +27,6 @@ module Sportradar
|
|
|
27
27
|
injury == 'true'
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
private
|
|
31
|
-
def set_references
|
|
32
|
-
if response["refs"] && response["refs"]["ref"]
|
|
33
|
-
if response["refs"]["ref"].is_a?(Array)
|
|
34
|
-
@references = response["refs"]["ref"].map {|x| Sportradar::Api::Content::Reference.new x }
|
|
35
|
-
elsif response["refs"]["ref"].is_a?(Hash)
|
|
36
|
-
@references = [ Sportradar::Api::Content::Reference.new(response["refs"]["ref"]) ]
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
30
|
end
|
|
42
31
|
end
|
|
43
32
|
end
|
|
@@ -9,18 +9,7 @@ module Sportradar
|
|
|
9
9
|
@provider = data["provider"]
|
|
10
10
|
@start_time = Time.parse(data["start_time"]) if data["start_time"]
|
|
11
11
|
@end_time = Time.parse(data["end_time"]) if data["end_time"]
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
def set_articles
|
|
17
|
-
if response["item"]
|
|
18
|
-
if response["item"].is_a?(Array)
|
|
19
|
-
@articles = response["item"].map {|x| Sportradar::Api::Content::Article.new x }
|
|
20
|
-
elsif response["item"].is_a?(Hash)
|
|
21
|
-
@articles = [ Sportradar::Api::Content::Article.new(response["item"]) ]
|
|
22
|
-
end
|
|
23
|
-
end
|
|
12
|
+
@articles = parse_into_array(selector: response["item"], klass: Sportradar::Api::Content::Article) if response["item"]
|
|
24
13
|
end
|
|
25
14
|
|
|
26
15
|
end
|
data/lib/sportradar/api/data.rb
CHANGED
|
@@ -11,6 +11,22 @@ module Sportradar
|
|
|
11
11
|
self.instance_variables.map{|attribute| attribute.to_s.gsub('@', '').to_sym }
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def parse_into_array(selector: , klass: )
|
|
15
|
+
if selector.is_a?(Array)
|
|
16
|
+
selector.map {|x| klass.new x }
|
|
17
|
+
elsif selector.is_a?(Hash)
|
|
18
|
+
[ klass.new(selector) ]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def parse_out_hashes(data_element)
|
|
23
|
+
if data_element && data_element.is_a?(Array)
|
|
24
|
+
data_element.find {|elem| elem.is_a?(Hash) }
|
|
25
|
+
else
|
|
26
|
+
data_element
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
14
30
|
end
|
|
15
31
|
|
|
16
32
|
end
|
data/lib/sportradar/api/error.rb
CHANGED
|
@@ -15,11 +15,14 @@ module Sportradar
|
|
|
15
15
|
attr_reader :message, :code, :response
|
|
16
16
|
|
|
17
17
|
def initialize( code, message, response)
|
|
18
|
-
@code =
|
|
19
|
-
@message =
|
|
18
|
+
@code = code
|
|
19
|
+
@message = message
|
|
20
20
|
@response = response
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
def success?
|
|
24
|
+
false
|
|
25
|
+
end
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
28
|
end
|
|
@@ -2,16 +2,13 @@ module Sportradar
|
|
|
2
2
|
module Api
|
|
3
3
|
module Football
|
|
4
4
|
class StatPack < Data
|
|
5
|
-
attr_accessor :response, :player, :name, :id, :position, :yards
|
|
5
|
+
attr_accessor :response, :player, :name, :id, :position, :yards, :players
|
|
6
6
|
|
|
7
7
|
def initialize(data)
|
|
8
|
-
@response = data
|
|
9
|
-
set_stats
|
|
8
|
+
@response = data || {}
|
|
10
9
|
@player = Sportradar::Api::Nfl::Player.new(response) if response['name'] # this isn't used yet, and we need to determine a better solution
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def players
|
|
14
|
-
@players ||= set_players
|
|
10
|
+
@players = parse_into_array(selector: response["player"], klass: Sportradar::Api::Nfl::Player) if response["player"]
|
|
11
|
+
set_stats
|
|
15
12
|
end
|
|
16
13
|
|
|
17
14
|
private
|
|
@@ -20,16 +17,6 @@ module Sportradar
|
|
|
20
17
|
raise NotImplementedError, "Please implement `#{self.class}#set_stats`"
|
|
21
18
|
end
|
|
22
19
|
|
|
23
|
-
def set_players
|
|
24
|
-
if response["player"]
|
|
25
|
-
if response["player"].is_a? Hash
|
|
26
|
-
@players = [ self.class.new(response["player"]) ]
|
|
27
|
-
else
|
|
28
|
-
@players = response["player"].map{ |hash| self.class.new(hash) }
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
20
|
end
|
|
34
21
|
end
|
|
35
22
|
end
|
|
@@ -2,7 +2,7 @@ module Sportradar
|
|
|
2
2
|
module Api
|
|
3
3
|
class Football::StatPack::Defense < Football::StatPack
|
|
4
4
|
attr_accessor :tackles, :assists, :combined, :sacks, :sack_yards, :interceptions, :passes_defended, :forced_fumbles, :fumble_recoveries, :qb_hits, :tloss, :tloss_yards, :safeties, :sp_tackles, :sp_assists, :sp_forced_fumbles, :sp_fumble_recoveries, :sp_blocks, :misc_tackles, :misc_assists, :misc_forced_fumbles, :misc_fumble_recoveries, :missed_tackles
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
def set_stats
|
|
7
7
|
@tackles = response["tackles"]
|
|
8
8
|
@assists = response["assists"]
|
|
@@ -5,9 +5,9 @@ module Sportradar
|
|
|
5
5
|
|
|
6
6
|
def set_stats
|
|
7
7
|
kick_data = response['kicks'] || response
|
|
8
|
-
@attempts =
|
|
9
|
-
@made =
|
|
10
|
-
@blocked =
|
|
8
|
+
@attempts = kick_data["attempts"]
|
|
9
|
+
@made = kick_data["made"]
|
|
10
|
+
@blocked = kick_data["blocked"]
|
|
11
11
|
if response['conversions']
|
|
12
12
|
@pass_attempts = response["pass_attempts"]
|
|
13
13
|
@pass_successes = response["pass_successes"]
|
|
@@ -24,7 +24,7 @@ module Sportradar
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# # sample response
|
|
27
|
-
# extra_points =
|
|
27
|
+
# extra_points =
|
|
28
28
|
# {"kicks"=>
|
|
29
29
|
# {"player"=>
|
|
30
30
|
# [
|
|
@@ -7,7 +7,7 @@ module Sportradar
|
|
|
7
7
|
@attempts = response["attempts"]
|
|
8
8
|
@completions = response["completions"]
|
|
9
9
|
@cmp_pct = response["cmp_pct"]
|
|
10
|
-
# @yards = response["yards"]
|
|
10
|
+
# @yards = response["yards"] # 'yards' is air yards, which does not include sack yardage. air_yards is for college, net_yards for NFL
|
|
11
11
|
@avg_yards = response["avg_yards"]
|
|
12
12
|
@sacks = response["sacks"]
|
|
13
13
|
@sack_yards = response["sack_yards"]
|
|
@@ -6,10 +6,11 @@ module Sportradar
|
|
|
6
6
|
alias :count :penalties
|
|
7
7
|
|
|
8
8
|
def set_stats
|
|
9
|
-
@response = response
|
|
10
|
-
@penalties = response
|
|
11
|
-
@yards = response
|
|
9
|
+
@response = (response.dig(1) || {}) if response.is_a? Array
|
|
10
|
+
@penalties = response.dig('penalties')
|
|
11
|
+
@yards = response.dig('yards')
|
|
12
12
|
end
|
|
13
|
+
|
|
13
14
|
def formatted
|
|
14
15
|
"#{count}-#{yards}"
|
|
15
16
|
end
|
|
@@ -18,7 +18,11 @@ module Sportradar
|
|
|
18
18
|
else
|
|
19
19
|
response = get request_url("players/#{image_type}/manifests/all_assets")
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
if response.success? && response["assetlist"]
|
|
22
|
+
Sportradar::Api::Images::AssetList.new response["assetlist"]
|
|
23
|
+
else
|
|
24
|
+
response
|
|
25
|
+
end
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
alias_method :all_players, :player_manifests
|
|
@@ -27,14 +31,22 @@ module Sportradar
|
|
|
27
31
|
def coach_manifests
|
|
28
32
|
raise Sportradar::Api::Error::InvalidLeague unless league.nil?
|
|
29
33
|
response = get request_url("coaches/#{image_type}/manifests/all_assets")
|
|
30
|
-
|
|
34
|
+
if response.success? && response["assetlist"]
|
|
35
|
+
Sportradar::Api::Images::AssetList.new response["assetlist"]
|
|
36
|
+
else
|
|
37
|
+
response
|
|
38
|
+
end
|
|
31
39
|
end
|
|
32
40
|
alias_method :all_coaches, :coach_manifests
|
|
33
41
|
|
|
34
42
|
def venue_manifests
|
|
35
43
|
raise Sportradar::Api::Error::InvalidLeague unless league.nil?
|
|
36
44
|
response = get request_url("venues/manifests/all_assets")
|
|
37
|
-
|
|
45
|
+
if response.success? && response["assetlist"]
|
|
46
|
+
Sportradar::Api::Images::AssetList.new response["assetlist"]
|
|
47
|
+
else
|
|
48
|
+
response
|
|
49
|
+
end
|
|
38
50
|
end
|
|
39
51
|
alias_method :all_venues, :venue_manifests
|
|
40
52
|
|
|
@@ -121,9 +133,10 @@ module Sportradar
|
|
|
121
133
|
['bundesliga', 'epl', 'serie-a', 'la-liga', 'ligue-1']
|
|
122
134
|
end
|
|
123
135
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
# Was going to use this to prevent access to venues/coaches for sports that aren't this
|
|
137
|
+
# def additional_content_sports
|
|
138
|
+
# ['mlb', 'nba', 'nfl', 'nhl']
|
|
139
|
+
# end
|
|
127
140
|
|
|
128
141
|
end
|
|
129
142
|
end
|
|
@@ -12,34 +12,10 @@ module Sportradar
|
|
|
12
12
|
@title = data["title"]
|
|
13
13
|
@description = data["description"]
|
|
14
14
|
@copyright = data["copyright"]
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
set_tags
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
def set_links
|
|
23
|
-
if response["links"] && response["links"]["link"]
|
|
24
|
-
if response["links"]["link"].is_a?(Array)
|
|
25
|
-
@links = response["links"]["link"].map {|x| Sportradar::Api::Images::Link.new x }
|
|
26
|
-
elsif response["links"]["link"].is_a?(Hash)
|
|
27
|
-
@links = [ Sportradar::Api::Images::Link.new(response["links"]["link"]) ]
|
|
28
|
-
end
|
|
29
|
-
end
|
|
15
|
+
@links = parse_into_array(selector: response["links"]["link"], klass: Sportradar::Api::Images::Link) if response["links"] && response["links"]["link"]
|
|
16
|
+
@tags = parse_into_array(selector: response["tags"]["tag"], klass: Sportradar::Api::Images::Tag) if response["tags"] && response["tags"]["tag"]
|
|
30
17
|
end
|
|
31
18
|
|
|
32
|
-
def set_tags
|
|
33
|
-
if response["tags"] && response["tags"]["tag"]
|
|
34
|
-
if response["tags"]["tag"].is_a?(Array)
|
|
35
|
-
@tags = response["tags"]["tag"].map {|x| Sportradar::Api::Images::Tag.new x }
|
|
36
|
-
elsif response["tags"]["tag"].is_a?(Hash)
|
|
37
|
-
@tags = [ Sportradar::Api::Images::Tag.new(response["tags"]["tag"]) ]
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
|
|
43
19
|
end
|
|
44
20
|
end
|
|
45
21
|
end
|