lib/finapps/rest/base_client.rb in finapps-2.0.15 vs lib/finapps/rest/base_client.rb in finapps-2.0.16

- old
+ new

@@ -37,19 +37,23 @@ def send_request(path, method, params={}) raise FinApps::MissingArgumentsError.new 'Missing argument: path.' if path.blank? raise FinApps::MissingArgumentsError.new 'Missing argument: method.' if method.blank? response, error_messages = execute_request(method, params, path) - result = if response.blank? + result = if empty?(response) nil else block_given? ? yield(response) : response.body end [result, error_messages] end private + + def empty?(response) + response.blank? || (response.respond_to?(:body) && response.body.blank?) + end def execute_request(method, params, path) error_messages = [] begin response = execute_method method, params, path