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
|
# File 'lib/monkey_patch/sparkpost/client.rb', line 9
def call(opts)
method = opts[:method]
path = opts[:path]
body_values = opts[:body_values] || {}
query_params = opts[:query_values] || {}
= opts[:extract_results].nil? ? true : opts[:extract_results]
path = "#{@base_path}#{path}"
params = { path: path, headers: }
params[:body] = JSON.generate(body_values) unless body_values.empty?
params[:query] = query_params unless query_params.empty?
if @debug
logger.debug("Calling #{method}")
logger.debug(params)
end
response = @session.send(method.to_s, params)
if @debug
logger.debug("Response #{response.status}")
logger.debug(response)
end
fail Exceptions::GatewayTimeoutExceeded, "Received 504 from SparkPost API" if response.status == 504
process_response(response, )
rescue Excon::Errors::Timeout
raise Exceptions::GatewayTimeoutExceeded
end
|