lib/sportradar/api/images.rb in sportradar-api-0.9.10 vs lib/sportradar/api/images.rb in sportradar-api-0.9.11
- old
+ new
@@ -1,22 +1,24 @@
module Sportradar
module Api
class Images < Request
- attr_accessor :sport, :league, :access_level
- def initialize( sport, access_level = 't', league = nil)
+ attr_accessor :sport, :league, :access_level, :nfl_premium
+ def initialize( sport, access_level: 't', league: nil, nfl_premium: false)
raise Sportradar::Api::Error::InvalidSport unless allowed_sports.include? sport
@sport = sport
raise Sportradar::Api::Error::InvalidLeague unless soccer_leagues.include?(league) || league.nil?
@league = league
-
+ @nfl_premium = nfl_premium
raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level
@access_level = access_level
end
def player_manifests(year = Date.today.year)
if league
response = get request_url("#{league}/#{image_type}/players/#{year}/manifest")
+ elsif nfl_premium
+ response = get request_url("#{image_type}/players/#{year}/manifest")
else
response = get request_url("players/#{image_type}/manifests/all_assets")
end
if response.success? && response["assetlist"]
Sportradar::Api::Images::AssetList.new response["assetlist"]
@@ -65,17 +67,22 @@
"/#{sport}-images-#{access_level}#{version}/#{provider}/#{path}"
end
def api_key
if league
+
if access_level == 'p'
Sportradar::Api.api_key_params("images_#{league}", "production")
else
Sportradar::Api.api_key_params("images_#{league}")
end
else
- if access_level == 'p'
+ if nfl_premium && access_level == 'p'
+ Sportradar::Api.api_key_params("images_nfl_official_premium", "production")
+ elsif nfl_premium
+ Sportradar::Api.api_key_params("images_nfl_official_premium")
+ elsif access_level == 'p'
Sportradar::Api.api_key_params("images_#{sport}", "production")
else
Sportradar::Api.api_key_params("images_#{sport}")
end
end
@@ -84,21 +91,23 @@
def api_key_query_string
"?#{api_key.keys.first}=#{api_key.values.first}"
end
def provider
- if uses_v2_api?
+ if nfl_premium
+ 'ap_premium'
+ elsif uses_v2_api?
'usat'
elsif uses_v3_api?
'reuters'
end
end
def version
- if uses_v2_api?
- Sportradar::Api.version('images')
- elsif uses_v3_api?
+ if uses_v3_api? || nfl_premium
3
+ elsif uses_v2_api?
+ Sportradar::Api.version('images')
end
end
def image_type
'headshots'