Sha256: 9c7d930633ff050c6a5493a01b3a3b5f5f999d0936cd20f65edaa06369cb6463

Contents?: true

Size: 1.64 KB

Versions: 32

Compression:

Stored size: 1.64 KB

Contents

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

          def initialize(access_level = default_access_level)
            @league = 'nba'
            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)
            "/nba-#{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('nba', 'production')
            else
              Sportradar::Api.api_key_params('nba')
            end
          end

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

          def allowed_access_levels
            %w[p t sim]
          end

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

        end
      end
    end
  end
end

__END__

sr = Sportradar::Api::Basketball::Nba.new
lh = sr.league_hierarchy;
ls = sr.standings;

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
sportradar-api-0.14.0 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.26 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.25 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.24 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.23 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.22 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.21 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.20 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.19 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.18 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.17 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.16 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.15 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.14 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.13 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.12 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.11 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.10 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.9 lib/sportradar/api/basketball/nba/api.rb
sportradar-api-0.13.8 lib/sportradar/api/basketball/nba/api.rb