lib/after_ship/core/request.rb
# Do the request to the server and handle the response.
Do the request to the server and handle the response.
Do the request to the server and handle the response .
def response
      response = typhoeus_response
      ErrorHandler.precheck(response)
      parsed_body = MultiJson.load(response.body, JSON_OPTIONS)
      ErrorHandler.check(parsed_body.fetch(:meta))
      if @block
        @block.call(parsed_body)
      else
        parsed_body
      end
    rescue MultiJson::ParseError => e
      logger = Logger.new($stdout)
      logger.error("#{e.class}: #{e.message}")
      if response
        logger.error('Response body:')
        logger.error(response.body.inspect)
      end
      raise Error::InternalError, 'AfterShip internal error, please try again.'
    end
def response response = typhoeus_response ErrorHandler . precheck ( response ) parsed_body = MultiJson . load ( response . body , JSON_OPTIONS ) ErrorHandler . check ( parsed_body . fetch ( :meta ) ) if @block @block . call ( parsed_body ) else parsed_body end rescue MultiJson :: ParseError => e logger = Logger . new ( $stdout ) logger . error ( "#{e.class}: #{e.message}" ) if response logger . error ( 'Response body:' ) logger . error ( response . body . inspect ) end raise Error :: InternalError , 'AfterShip internal error, please try again.' end
Do the request to the server and handle the response.
Do the request to the server and handle the response .