lib/gooddata/connection.rb in gooddata-0.2.0 vs lib/gooddata/connection.rb in gooddata-0.4.0

- old
+ new

@@ -1,6 +1,6 @@ -require 'json/pure' +require 'json' require 'net/ftptls' # silence the parenthesis warning in rest-client 1.6.1 old_verbose, $VERBOSE = $VERBOSE, nil ; require 'rest-client' ; $VERBOSE = old_verbose @@ -40,15 +40,16 @@ # # === Parameters # # * +username+ - The GoodData account username # * +password+ - The GoodData account password - def initialize(username, password, url = nil) + def initialize(username, password, url = nil, options = {}) @status = :not_connected @username = username @password = password @url = url || DEFAULT_URL + @options = options end # Returns the user JSON object of the currently logged in GoodData user account. def user ensure_connection @@ -163,14 +164,16 @@ 'password' => @password, 'remember' => 1 } } - @server = RestClient::Resource.new @url, :headers => { - :content_type => :json, - :accept => [ :json, :zip ], - :user_agent => GoodData.gem_version_string - } + @server = RestClient::Resource.new @url, + :timeout => @options[:timeout], + :headers => { + :content_type => :json, + :accept => [ :json, :zip ], + :user_agent => GoodData.gem_version_string, + } GoodData.logger.debug "Logging in..." @user = post(LOGIN_PATH, credentials, :dont_reauth => true)['userLogin'] refresh_token :dont_reauth => true # avoid infinite loop if refresh_token fails with 401