Sha256: 0bc47f8a2b2dfe9e4e1afc8a028568407721e6e7980f403a4f283d2371212f52

Contents?: true

Size: 1.73 KB

Versions: 16

Compression:

Stored size: 1.73 KB

Contents

module Sportradar
  module Api
    class Content < 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 news( date = Date.today, content_type = 'all' )
        raise Sportradar::Api::Error::InvalidType unless allowed_news_types.include? content_type
        get request_url("#{provider }/news/#{date_path(date)}/#{content_type}")
      end

      def analysis( date = Date.today, content_type = 'all' )
        raise Sportradar::Api::Error::InvalidType unless allowed_analysis_types.include? content_type
        get request_url("#{provider }/analysis/#{date_path(date)}/#{content_type}")
      end

      private

      def request_url(path)
        "/content-#{sport}-#{access_level}#{version}/#{path}"
      end

      def api_key
        if access_level == 'p'
          Sportradar::Api.api_key_params("content_#{sport}", "production")
        else
          Sportradar::Api.api_key_params("content_#{sport}")
        end
      end

      def provider
        'tsx'
      end

      def version
        Sportradar::Api.version('content')
      end

      def allowed_access_levels
        ['p', 't']
      end

      def allowed_sports
        ['nfl', 'ncaafb', 'nhl', 'nba', 'ncaamb', 'mlb', 'golf', 'nascar', 'f1', 'auto-racing']
      end

      def allowed_news_types
        ['all', 'injuries', 'transactions']
      end

      def allowed_analysis_types
        ['all', 'preview', 'recap', 'team_report']
      end

    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sportradar-api-0.1.36 lib/sportradar/api/content.rb
sportradar-api-0.1.35 lib/sportradar/api/content.rb
sportradar-api-0.1.34 lib/sportradar/api/content.rb
sportradar-api-0.1.33 lib/sportradar/api/content.rb
sportradar-api-0.1.32 lib/sportradar/api/content.rb
sportradar-api-0.1.31 lib/sportradar/api/content.rb
sportradar-api-0.1.30 lib/sportradar/api/content.rb
sportradar-api-0.1.29 lib/sportradar/api/content.rb
sportradar-api-0.1.28 lib/sportradar/api/content.rb
sportradar-api-0.1.27 lib/sportradar/api/content.rb
sportradar-api-0.1.26 lib/sportradar/api/content.rb
sportradar-api-0.1.25 lib/sportradar/api/content.rb
sportradar-api-0.1.24 lib/sportradar/api/content.rb
sportradar-api-0.1.23 lib/sportradar/api/content.rb
sportradar-api-0.1.22 lib/sportradar/api/content.rb
sportradar-api-0.1.21 lib/sportradar/api/content.rb