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.



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

def initialize(response)
  @response = response
end

Instance Method Details

#error_messageObject



236
237
238
# File 'lib/helpers/simple_http_helper.rb', line 236

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

#get_contentObject



240
241
242
# File 'lib/helpers/simple_http_helper.rb', line 240

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

#get_responseObject



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

def get_response
  @response
end

#is_success?Boolean

Returns:

  • (Boolean)


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

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

#to_sObject



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

def to_s
  @response.to_s
end