3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/ext/activemerchant/connection.rb', line 3
def request(method, body, = {})
request_start = Time.now.to_f
retry_exceptions(:max_retries => max_retries, :logger => logger, :tag => tag) do
begin
info "connection_http_method=#{method.to_s.upcase} connection_uri=#{endpoint}", tag
result = nil
realtime = Benchmark.realtime do
result = case method
when :get
raise ArgumentError, "GET requests do not support a request body" if body
http.get(endpoint.request_uri, )
when :post
debug body
http.post(endpoint.request_uri, body, RUBY_184_POST_HEADERS.merge())
when :patch
debug body
http.patch(endpoint.request_uri, body, )
when :put
debug body
http.put(endpoint.request_uri, body, )
when :delete
raise ArgumentError, "DELETE requests do not support a request body" if body
http.delete(endpoint.request_uri, )
else
raise ArgumentError, "Unsupported request method #{method.to_s.upcase}"
end
end
info "--> %d %s (%d %.4fs)" % [result.code, result.message, result.body ? result.body.length : 0, realtime], tag
debug result.body
result
end
end
ensure
info "connection_request_total_time=%.4fs" % [Time.now.to_f - request_start], tag
end
|