Class: Apis::Adapter::NetHTTP
Instance Attribute Summary
Attributes inherited from Abstract
#uri
Instance Method Summary
collapse
Methods inherited from Abstract
#initialize
Instance Method Details
#connection ⇒ Object
6
7
8
|
# File 'lib/apis/adapter/net_http.rb', line 6
def connection
Net::HTTP.start(uri.host, uri.port)
end
|
#run(method, path, params = {}, headers = {}) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/apis/adapter/net_http.rb', line 10
def run(method, path, params = {}, = {})
_module = Net::HTTP.const_get(method.to_s.capitalize)
request = _module.new(path)
response = connection.request(
request,
params.empty? ? nil : Addressable::URI.new.tap { |uri| uri.query_values = params }.query
)
[response.code.to_i] + response
end
|