Method: CoreLibrary::ResponseHandler#handle

Defined in:
lib/apimatic-core/response_handler.rb

#handle(response, global_errors, should_symbolize_hash = false) ⇒ Object

Main method to handle the response with all the set properties.

Parameters:

  • response (HttpResponse)

    The response received.

  • global_errors (Hash)

    The global errors object.

  • should_symbolize_hash (Boolean) (defaults to: false)

    Flag to symbolize the hash during response deserialization.

Returns:

  • (Object)

    The deserialized response of the API Call.



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/apimatic-core/response_handler.rb', line 157

def handle(response, global_errors, should_symbolize_hash = false)
  # checking Nullify 404
  return nil if response.status_code == 404 && @is_nullify404

  # validating response if configured
  validate(response, global_errors)

  return if @is_response_void && !@is_api_response

  # applying deserializer if configured
  deserialized_value = apply_deserializer(response, should_symbolize_hash)

  # applying api_response if configured
  deserialized_value = apply_api_response(response, deserialized_value)

  # applying convertor if configured
  deserialized_value = apply_convertor(deserialized_value)

  deserialized_value
end