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.



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

def initialize(response)
  @response = response
end

Instance Method Details

#error_messageObject



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

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

#get_contentObject



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

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

#get_responseObject



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

def get_response
  @response
end

#is_success?Boolean

Returns:

  • (Boolean)


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

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

#to_sObject



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

def to_s
  @response.to_s
end