Sha256: 026c86bf41fe687d2e392bf70e7ec66666c1f8bbae22fa6bf0547d89eae6e763

Contents?: true

Size: 1.49 KB

Versions: 15

Compression:

Stored size: 1.49 KB

Contents

module Sportradar
  module Api
    module Odds
      class Api < Request
        attr_accessor :access_level, :language_code, :error, :base_path

        def initialize(base_path: base_path, access_level: default_access_level, language_code: 'en', **args)
          @language_code = language_code
          @access_level = access_level
          @base_path = base_path
          raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? @access_level
        end

        def default_season
          'reg'
        end

        def default_access_level
          if (ENV['SPORTRADAR_ODDS_ENV'] || ENV['SPORTRADAR_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production'
            'production'
          else
            'trial'
          end
        end

        def content_format
          'json'
        end

        def inspect
          self.class.name
        end

        private

        def request_url(path)
          "/#{base_path}/#{access_level}/v#{version}/#{language_code}/#{path}"
        end

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

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

        def allowed_access_levels
          %w[production trial]
        end

      end

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
sportradar-api-0.20.0 lib/sportradar/api/odds/api.rb
sportradar-api-0.20.0.pre2 lib/sportradar/api/odds/api.rb
sportradar-api-0.20.0.pre lib/sportradar/api/odds/api.rb
sportradar-api-0.19.6 lib/sportradar/api/odds/api.rb
sportradar-api-0.19.5 lib/sportradar/api/odds/api.rb
sportradar-api-0.19.4 lib/sportradar/api/odds/api.rb
sportradar-api-0.19.3 lib/sportradar/api/odds/api.rb
sportradar-api-0.19.2 lib/sportradar/api/odds/api.rb
sportradar-api-0.19.1 lib/sportradar/api/odds/api.rb
sportradar-api-0.19.0 lib/sportradar/api/odds/api.rb
sportradar-api-0.18.1 lib/sportradar/api/odds/api.rb
sportradar-api-0.18.0 lib/sportradar/api/odds/api.rb
sportradar-api-0.17.6 lib/sportradar/api/odds/api.rb
sportradar-api-0.17.5 lib/sportradar/api/odds/api.rb
sportradar-api-0.17.5.pre lib/sportradar/api/odds/api.rb