Sha256: e2c9df990d10baf095d0bc16ef605003097ca687851b1c7160a9994e6be43c38

Contents?: true

Size: 1.6 KB

Versions: 17

Compression:

Stored size: 1.6 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
        Sportradar::Api.api_key_params("content_#{sport}")
      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

17 entries across 17 versions & 1 rubygems

Version Path
sportradar-api-0.1.19 lib/sportradar/api/content.rb
sportradar-api-0.1.18 lib/sportradar/api/content.rb
sportradar-api-0.1.17 lib/sportradar/api/content.rb
sportradar-api-0.1.16 lib/sportradar/api/content.rb
sportradar-api-0.1.15 lib/sportradar/api/content.rb
sportradar-api-0.1.14 lib/sportradar/api/content.rb
sportradar-api-0.1.13 lib/sportradar/api/content.rb
sportradar-api-0.1.12 lib/sportradar/api/content.rb
sportradar-api-0.1.11 lib/sportradar/api/content.rb
sportradar-api-0.1.10 lib/sportradar/api/content.rb
sportradar-api-0.1.8 lib/sportradar/api/content.rb
sportradar-api-0.1.7 lib/sportradar/api/content.rb
sportradar-api-0.1.6 lib/sportradar/api/content.rb
sportradar-api-0.1.5 lib/sportradar/api/content.rb
sportradar-api-0.1.4 lib/sportradar/api/content.rb
sportradar-api-0.1.3 lib/sportradar/api/content.rb
sportradar-api-0.1.2 lib/sportradar/api/content.rb