lib/nk_alpe/request.rb
def normalize_response(response, http_status)
      case response
      when Hash
        response[:status] = http_status
        response.with_indifferent_access
      when String
        response_json = {}.with_indifferent_access
        response_json[:status] = http_status
        response_json[:message] = response
        response_json
      else
        response_hash = {}.with_indifferent_access
        response_hash[:status] = http_status
        response_hash[:message] = response
        response_hash
      end
    end
# Base on the response type, handle situation
# Also, add http status in case is not set
#
# @returns [Hash]
Base on the response type, handle situation
Also, add http status in case is not set
Base on the response type handle situation Also add http status in case is not set
def normalize_response(response, http_status)
      case response
      when Hash
        response[:status] = http_status
        response.with_indifferent_access
      when String
        response_json = {}.with_indifferent_access
        response_json[:status] = http_status
        response_json[:message] = response
        response_json
      else
        response_hash = {}.with_indifferent_access
        response_hash[:status] = http_status
        response_hash[:message] = response
        response_hash
      end
    end
def normalize_response ( response , http_status ) case response when Hash response [ :status ] = http_status response . with_indifferent_access when String response_json = { } . with_indifferent_access response_json [ :status ] = http_status response_json [ :message ] = response response_json else response_hash = { } . with_indifferent_access response_hash [ :status ] = http_status response_hash [ :message ] = response response_hash end end
Base on the response type, handle situation
Also, add http status in case is not set
Base on the response type handle situation Also add http status in case is not set
None
response
http_status