Class: Idnow::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/idnow/http_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(host:) ⇒ HttpClient

Returns a new instance of HttpClient.



3
4
5
# File 'lib/idnow/http_client.rb', line 3

def initialize(host:)
  @uri = URI.parse(host)
end

Instance Method Details

#execute(request, headers = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/idnow/http_client.rb', line 7

def execute(request, headers = {})
  headers.each do |k, v|
    request[k] = v
  end
  begin
    client.request(request)
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
         Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
    raise Idnow::ConnectionException, e
  end
end