Class: PecCalcClient::Connector

Inherits:
Object
  • Object
show all
Defined in:
lib/pec_calc_client/connector.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Connector

Returns a new instance of Connector.



6
7
8
# File 'lib/pec_calc_client/connector.rb', line 6

def initialize(url)
  @url = url.to_s
end

Instance Method Details

#request(params = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/pec_calc_client/connector.rb', line 10

def request(params = {})
  prepare_params params
  begin
    response = Net::HTTP.get_response(URI(url_with_params))
  rescue
    raise PecCalcClient::ConnectionError, 'Bad connection'
  end
  Response.new response
end