sportradar-api 0.1.19 → 0.1.21
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.rb +12 -5
- data/lib/sportradar/api/content.rb +5 -1
- data/lib/sportradar/api/images.rb +20 -8
- data/lib/sportradar/api/images/asset.rb +43 -0
- data/lib/sportradar/api/images/asset_list.rb +26 -0
- data/lib/sportradar/api/images/link.rb +15 -0
- data/lib/sportradar/api/images/tag.rb +14 -0
- data/lib/sportradar/api/live_images.rb +9 -3
- data/lib/sportradar/api/nfl.rb +5 -2
- data/lib/sportradar/api/soccer.rb +5 -1
- data/lib/sportradar/api/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c374b67abc0b894e5b70a9b78f4132d26dd4a8f5
|
4
|
+
data.tar.gz: 35143b5222ed880ecdc50ffae837565d8fc1da81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 074738a6f0828de96aed6aa11c1a72d47e3b25bf02e8aab42a4298205f98c414994a2b343b099326ca2af415b37df496a53a2f8b4bad82f2bf9694ff9d043028
|
7
|
+
data.tar.gz: dfe4a9d69ee338d3b10eb8b235d5161a2b2313ca3e3f58acb7991078afd6a4d86427b95c4a6b2a672ef33d9e2e819f022b7b94782f9e9fe7c6d33ce2a58bed5c
|
data/Gemfile.lock
CHANGED
data/lib/sportradar/api.rb
CHANGED
@@ -54,8 +54,15 @@ require "sportradar/api/nfl/team"
|
|
54
54
|
require "sportradar/api/nfl/venue"
|
55
55
|
require "sportradar/api/nfl/week"
|
56
56
|
|
57
|
-
require "sportradar/api/images"
|
58
57
|
require "sportradar/api/live_images"
|
58
|
+
require "sportradar/api/images"
|
59
|
+
require "sportradar/api/images/asset_list"
|
60
|
+
require "sportradar/api/images/asset"
|
61
|
+
require "sportradar/api/images/link"
|
62
|
+
require "sportradar/api/images/tag"
|
63
|
+
|
64
|
+
|
65
|
+
|
59
66
|
require "sportradar/api/content"
|
60
67
|
require "sportradar/api/odds"
|
61
68
|
|
@@ -91,12 +98,12 @@ module Sportradar
|
|
91
98
|
|
92
99
|
private
|
93
100
|
|
94
|
-
def self.api_key_params(api)
|
95
|
-
{ api_key: self.api_key(api) }
|
101
|
+
def self.api_key_params(api, access_level = 'trial')
|
102
|
+
{ api_key: self.api_key(api, access_level) }
|
96
103
|
end
|
97
104
|
|
98
|
-
def self.api_key(api)
|
99
|
-
ENV.fetch("SPORTRADAR_#{api.to_s.upcase.gsub('-', '_')}", "api_key missing for #{api}")
|
105
|
+
def self.api_key(api, access_level = 'trial')
|
106
|
+
ENV.fetch("SPORTRADAR_#{api.to_s.upcase.gsub('-', '_')}#{'_PRODUCTION' if access_level == 'production'}", "api_key missing for #{api}")
|
100
107
|
end
|
101
108
|
|
102
109
|
def self.version(api)
|
@@ -27,7 +27,11 @@ module Sportradar
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def api_key
|
30
|
-
|
30
|
+
if access_level == 'p'
|
31
|
+
Sportradar::Api.api_key_params("content_#{sport}", "production")
|
32
|
+
else
|
33
|
+
Sportradar::Api.api_key_params("content_#{sport}")
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
def provider
|
@@ -2,7 +2,7 @@ module Sportradar
|
|
2
2
|
module Api
|
3
3
|
class Images < Request
|
4
4
|
attr_accessor :sport, :league, :access_level
|
5
|
-
def initialize( sport,
|
5
|
+
def initialize( sport, access_level = 't', league = nil)
|
6
6
|
raise Sportradar::Api::Error::InvalidSport unless allowed_sports.include? sport
|
7
7
|
@sport = sport
|
8
8
|
raise Sportradar::Api::Error::InvalidLeague unless soccer_leagues.include?(league) || league.nil?
|
@@ -14,29 +14,33 @@ module Sportradar
|
|
14
14
|
|
15
15
|
def player_manifests(year = Date.today.year)
|
16
16
|
if league
|
17
|
-
get request_url("#{league}/#{image_type}/players/#{year}/manifest")
|
17
|
+
response = get request_url("#{league}/#{image_type}/players/#{year}/manifest")
|
18
18
|
else
|
19
|
-
get request_url("players/#{image_type}/manifests/all_assets")
|
19
|
+
response = get request_url("players/#{image_type}/manifests/all_assets")
|
20
20
|
end
|
21
|
+
Sportradar::Api::Images::AssetList.new response["assetlist"] if response.success? && response["assetlist"]
|
21
22
|
end
|
23
|
+
|
22
24
|
alias_method :all_players, :player_manifests
|
23
25
|
# Coach Manifests
|
24
26
|
|
25
27
|
def coach_manifests
|
26
28
|
raise Sportradar::Api::Error::InvalidLeague unless league.nil?
|
27
|
-
get request_url("coaches/#{image_type}/manifests/all_assets")
|
29
|
+
response = get request_url("coaches/#{image_type}/manifests/all_assets")
|
30
|
+
Sportradar::Api::Images::AssetList.new response["assetlist"] if response.success? && response["assetlist"]
|
28
31
|
end
|
29
32
|
alias_method :all_coaches, :coach_manifests
|
30
33
|
|
31
34
|
def venue_manifests
|
32
35
|
raise Sportradar::Api::Error::InvalidLeague unless league.nil?
|
33
|
-
get request_url("venues/manifests/all_assets")
|
36
|
+
response = get request_url("venues/manifests/all_assets")
|
37
|
+
Sportradar::Api::Images::AssetList.new response["assetlist"] if response.success? && response["assetlist"]
|
34
38
|
end
|
35
39
|
alias_method :all_venues, :venue_manifests
|
36
40
|
|
37
41
|
# The Player Images, Coach Images, Venue Images APIs aren't really meant to be used directly, the manifests return an href path of an image we can pass it into the image_url method to get the entire image url
|
38
42
|
def image_url(href)
|
39
|
-
href.slice!(0) # remove initial '/'
|
43
|
+
href.slice!(0) if href.chars.first == '/' # remove initial '/'
|
40
44
|
set_base request_url(href) + api_key_query_string
|
41
45
|
end
|
42
46
|
alias_method :player_images, :image_url
|
@@ -51,9 +55,17 @@ module Sportradar
|
|
51
55
|
|
52
56
|
def api_key
|
53
57
|
if league
|
54
|
-
|
58
|
+
if access_level == 'p'
|
59
|
+
Sportradar::Api.api_key_params("images_#{league}", "production")
|
60
|
+
else
|
61
|
+
Sportradar::Api.api_key_params("images_#{league}")
|
62
|
+
end
|
55
63
|
else
|
56
|
-
|
64
|
+
if access_level == 'p'
|
65
|
+
Sportradar::Api.api_key_params("images_#{sport}", "production")
|
66
|
+
else
|
67
|
+
Sportradar::Api.api_key_params("images_#{sport}")
|
68
|
+
end
|
57
69
|
end
|
58
70
|
end
|
59
71
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Sportradar
|
2
|
+
module Api
|
3
|
+
class Images::Asset < Data
|
4
|
+
attr_accessor :response, :id, :created, :updated, :title, :description, :copyright, :links, :tags
|
5
|
+
|
6
|
+
def initialize(data)
|
7
|
+
@response = data
|
8
|
+
@id = data["id"]
|
9
|
+
@created = data["created"]
|
10
|
+
@updated = data["updated"]
|
11
|
+
@title = data["title"]
|
12
|
+
@description = data["description"]
|
13
|
+
@copyright = data["copyright"]
|
14
|
+
set_links
|
15
|
+
set_tags
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def set_links
|
21
|
+
if response["links"] && response["links"]["link"]
|
22
|
+
if response["links"]["link"].is_a?(Array)
|
23
|
+
@links = response["links"]["link"].map {|x| Sportradar::Api::Images::Link.new x }
|
24
|
+
elsif response["links"]["link"].is_a?(Hash)
|
25
|
+
@links = [ Sportradar::Api::Images::Link.new(response["links"]["link"]) ]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_tags
|
31
|
+
if response["tags"] && response["tags"]["tag"]
|
32
|
+
if response["tags"]["tag"].is_a?(Array)
|
33
|
+
@tags = response["tags"]["tag"].map {|x| Sportradar::Api::Images::Tag.new x }
|
34
|
+
elsif response["tags"]["tag"].is_a?(Hash)
|
35
|
+
@tags = [ Sportradar::Api::Images::Tag.new(response["tags"]["tag"]) ]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Sportradar
|
2
|
+
module Api
|
3
|
+
class Images::AssetList < Data
|
4
|
+
attr_accessor :response, :type, :sport, :assets
|
5
|
+
|
6
|
+
def initialize(data)
|
7
|
+
@response = data
|
8
|
+
@type = data["type"]
|
9
|
+
@sport = data["sport"]
|
10
|
+
set_assets
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def set_assets
|
15
|
+
if response["asset"]
|
16
|
+
if response["asset"].is_a?(Array)
|
17
|
+
@assets = response["asset"].map {|x| Sportradar::Api::Images::Asset.new x }
|
18
|
+
elsif response["asset"].is_a?(Hash)
|
19
|
+
@assets = [ Sportradar::Api::Images::Asset.new(response["asset"]) ]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Sportradar
|
2
|
+
module Api
|
3
|
+
class Images::Link < Data
|
4
|
+
attr_accessor :response, :width, :height, :href
|
5
|
+
|
6
|
+
def initialize(data)
|
7
|
+
@response = data
|
8
|
+
@width = data["width"]
|
9
|
+
@height = data["height"]
|
10
|
+
@href = data["href"]
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -11,13 +11,14 @@ module Sportradar
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def daily_manifest(date = Date.today )
|
14
|
-
get request_url("#{image_type }/#{date.to_s}/manifests/all_assets")
|
14
|
+
response = get request_url("#{image_type }/#{date.to_s}/manifests/all_assets")
|
15
|
+
Sportradar::Api::Images::AssetList.new response["assetlist"] if response.success? && response["assetlist"]
|
15
16
|
end
|
16
17
|
alias_method :all_images, :daily_manifest
|
17
18
|
|
18
19
|
# The Event images APIs aren't really meant to be used directly, the manifests return an href path of an image we can pass it into the image_url method to get the entire image url
|
19
20
|
def image_url(href)
|
20
|
-
href.slice!(0) # remove initial '/'
|
21
|
+
href.slice!(0) if href.chars.first == '/' # remove initial '/'
|
21
22
|
set_base request_url(href) + api_key_query_string
|
22
23
|
end
|
23
24
|
|
@@ -28,7 +29,12 @@ module Sportradar
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def api_key
|
31
|
-
|
32
|
+
if access_level == 'p'
|
33
|
+
Sportradar::Api.api_key_params("live_images_#{sport}", "production")
|
34
|
+
else
|
35
|
+
Sportradar::Api.api_key_params("live_images_#{sport}")
|
36
|
+
end
|
37
|
+
|
32
38
|
end
|
33
39
|
|
34
40
|
def api_key_query_string
|
data/lib/sportradar/api/nfl.rb
CHANGED
@@ -9,7 +9,6 @@ module Sportradar
|
|
9
9
|
@access_level = access_level
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
12
|
def schedule(year = Date.today.year, season = "reg")
|
14
13
|
raise Sportradar::Api::Error::InvalidSeason unless allowed_seasons.include? season
|
15
14
|
response = get request_url("games/#{ year }/#{ season }/schedule")
|
@@ -95,7 +94,11 @@ module Sportradar
|
|
95
94
|
end
|
96
95
|
|
97
96
|
def api_key
|
98
|
-
|
97
|
+
if access_level == 'o'
|
98
|
+
Sportradar::Api.api_key_params("nfl", "production")
|
99
|
+
else
|
100
|
+
Sportradar::Api.api_key_params("nfl")
|
101
|
+
end
|
99
102
|
end
|
100
103
|
|
101
104
|
def version
|
@@ -86,7 +86,11 @@ module Sportradar
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def api_key
|
89
|
-
|
89
|
+
if access_level == 'p'
|
90
|
+
Sportradar::Api.api_key_params("soccer_#{league}", "production")
|
91
|
+
else
|
92
|
+
Sportradar::Api.api_key_params("soccer_#{league}")
|
93
|
+
end
|
90
94
|
end
|
91
95
|
|
92
96
|
def version
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportradar-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Eggett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -230,6 +230,10 @@ files:
|
|
230
230
|
- lib/sportradar/api/data.rb
|
231
231
|
- lib/sportradar/api/error.rb
|
232
232
|
- lib/sportradar/api/images.rb
|
233
|
+
- lib/sportradar/api/images/asset.rb
|
234
|
+
- lib/sportradar/api/images/asset_list.rb
|
235
|
+
- lib/sportradar/api/images/link.rb
|
236
|
+
- lib/sportradar/api/images/tag.rb
|
233
237
|
- lib/sportradar/api/live_images.rb
|
234
238
|
- lib/sportradar/api/nfl.rb
|
235
239
|
- lib/sportradar/api/nfl/broadcast.rb
|