modules/check_in/app/services/chip_api/service.rb
def handle_response(resp)
      body = resp&.body
      value = begin
        Oj.load(body)
      rescue
        body
      end
      status = resp&.status

      case status
      when 200, 400
        { data: value, status: status }
      when 401
        { data: { error: true, message: 'Unauthorized' }, status: status }
      when 404
        { data: { error: true, message: 'We could not find that UUID' }, status: status }
      when 403
        { data: { error: true, message: 'Forbidden' }, status: status }
      else
        { data: { error: true, message: 'Something went wrong' }, status: status }
      end
    end
##
# Handle and format the response for the UI
#
# @param resp [Faraday::Response]
# @return [Hash]
#
Handle and format the response for the UI
Handle and format the response for the UI
def handle_response(resp)
      body = resp&.body
      value = begin
        Oj.load(body)
      rescue
        body
      end
      status = resp&.status
      case status
      when 200, 400
        { data: value, status: status }
      when 401
        { data: { error: true, message: 'Unauthorized' }, status: status }
      when 404
        { data: { error: true, message: 'We could not find that UUID' }, status: status }
      when 403
        { data: { error: true, message: 'Forbidden' }, status: status }
      else
        { data: { error: true, message: 'Something went wrong' }, status: status }
      end
    end
def handle_response ( resp ) body = resp &. body value = begin Oj . load ( body ) rescue body end status = resp &. status case status when 200 , 400 { data : value , status : status } when 401 { data : { error : true , message : 'Unauthorized' } , status : status } when 404 { data : { error : true , message : 'We could not find that UUID' } , status : status } when 403 { data : { error : true , message : 'Forbidden' } , status : status } else { data : { error : true , message : 'Something went wrong' } , status : status } end end
Handle and format the response for the UI
Handle and format the response for the UI
None
Hash
resp
None