Sha256: 29c50f6c1afd91e43a8b7abe60ac6cac007c1b2fcd15c62aa0b753f28a26d507
Contents?: true
Size: 1.58 KB
Versions: 17
Compression:
Stored size: 1.58 KB
Contents
module Sportradar module Api class LiveImages < Request attr_accessor :sport, :access_level def initialize( sport, access_level = 't') raise Sportradar::Api::Error::InvalidSport unless allowed_sports.include? sport @sport = sport raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level @access_level = access_level end def daily_manifest(date = Date.today ) get request_url("#{image_type }/#{date.to_s}/manifests/all_assets") end alias_method :all_images, :daily_manifest # 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 def image_url(href) href.slice!(0) # remove initial '/' set_base request_url(href) + api_key_query_string end private def request_url(path) "/#{sport}-liveimages-#{access_level}#{version}/#{provider}/#{path}" end def api_key Sportradar::Api.api_key_params("live_images_#{sport}") end def api_key_query_string "?#{api_key.keys.first}=#{api_key.values.first}" end def provider 'usat' end def version Sportradar::Api.version('live_images') end def image_type 'news' end def allowed_access_levels ['p', 't'] end def allowed_sports ['golf', 'mlb', 'nascar', 'nba', 'nfl', 'nhl', 'ncaafb', 'ncaamb', 'mls'] end end end end
Version data entries
17 entries across 17 versions & 1 rubygems