Sha256: 7b8b95d8348fd9ebe5af6ac84dc65eed20de34e7b0962e24137a82bde52d432b

Contents?: true

Size: 1.78 KB

Versions: 59

Compression:

Stored size: 1.78 KB

Contents

module Sportradar
  module Api
    module Basketball
      class Ncaamb
        class Api < Request
          attr_accessor :league, :access_level, :error

          def initialize(access_level = default_access_level)
            @league = 'ncaamb'
            raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level
            @access_level = access_level
          end

          def default_year
            (Date.today - 210).year
          end
          def default_date
            Date.today
          end
          def default_season
            'reg'
          end
          def default_access_level
            if (ENV['SPORTRADAR_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
              'p'
            else
              't'
            end
          end

          def content_format
            'json'
          end

          private

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

          def api_key
            if !['t', 'sim'].include?(access_level) || (access_level == 'sim' && default_access_level == 'p')
              Sportradar::Api.api_key_params('ncaamb', 'production')
            else
              Sportradar::Api.api_key_params('ncaamb')
            end
          end

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

          def allowed_access_levels
            %w[p t sim]
          end

          def allowed_seasons
            ["pre", "reg", 'ct', "pst"]
          end

        end
      end
    end
  end
end

__END__

sr = Sportradar::Api::Basketball::Ncaamb.new
ss = sr.schedule(2015, 'ct');
ss = sr.schedule(2015, 'pst');
rank = sr.rankings('US');
ds = sr.daily_schedule;

# not ready
lh = sr.league_hierarchy;
ls = sr.standings;

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
sportradar-api-0.20.2 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.20.1 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.20.0 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.20.0.pre2 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.20.0.pre lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.19.6 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.19.5 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.19.4 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.19.3 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.19.2 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.19.1 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.19.0 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.18.1 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.18.0 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.17.6 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.17.5 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.17.5.pre lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.17.4 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.17.3 lib/sportradar/api/basketball/ncaamb/api.rb
sportradar-api-0.17.2 lib/sportradar/api/basketball/ncaamb/api.rb