Class: HelperModule::SimpleHttpResult

Inherits:
Object
  • Object
show all
Defined in:
lib/helpers/simple_http_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ SimpleHttpResult

Returns a new instance of SimpleHttpResult.



212
213
214
# File 'lib/helpers/simple_http_helper.rb', line 212

def initialize(response)
  @response = response
end

Instance Method Details

#error_messageObject



228
229
230
# File 'lib/helpers/simple_http_helper.rb', line 228

def error_message
  is_success? ? '' : @response.body
end

#get_contentObject



232
233
234
# File 'lib/helpers/simple_http_helper.rb', line 232

def get_content
  is_success? ? JSON.parse(@response.body) : nil
end

#get_responseObject



220
221
222
# File 'lib/helpers/simple_http_helper.rb', line 220

def get_response
  @response
end

#is_success?Boolean

Returns:



224
225
226
# File 'lib/helpers/simple_http_helper.rb', line 224

def is_success?
  @response.code.to_i == 200
end

#to_sObject



216
217
218
# File 'lib/helpers/simple_http_helper.rb', line 216

def to_s
  @response.to_s
end