lib/sportradar/api/content.rb in sportradar-api-0.10.16 vs lib/sportradar/api/content.rb in sportradar-api-0.10.17

- old
+ new

@@ -1,11 +1,11 @@ module Sportradar module Api class Content < Request attr_accessor :sport, :access_level - def initialize( sport, access_level = 't') + def initialize( sport, access_level = default_access_level) 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 @@ -29,9 +29,17 @@ response end end private + + def default_access_level + if (ENV['SPORTRADAR_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']) == 'production' + 'p' + else + 't' + end + end def request_url(path) "/content-#{sport}-#{access_level}#{version}/#{path}" end