Class: BombDefuser::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/bomb_defuser/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource, params = {}) ⇒ Request

Returns a new instance of Request.



4
5
6
7
8
9
# File 'lib/bomb_defuser/request.rb', line 4

def initialize(resource, params = {})
  self.request_url = "#{Configuration::BASE_URL}/#{resource}/"
  self.request_params = build_params(params)
  self.logger = Configuration.logger
  self.http_client = Configuration.http_library_adapter
end

Instance Method Details

#get(response_handler = ResponseHandler.new) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/bomb_defuser/request.rb', line 11

def get(response_handler = ResponseHandler.new)
  url = build_url
  logger.info("GET on #{url}")

  response = http_client.http_get(url)
  response_handler.process(response)
end