Module: SmoothOperator::Operators::Faraday
Instance Method Summary collapse
-
#generate_connection(adapter = nil, options = nil) ⇒ Object
def generate_parallel_connection generate_connection(:typhoeus) end.
- #make_the_call(http_verb, resource_path, params, body, options) ⇒ Object
Instance Method Details
#generate_connection(adapter = nil, options = nil) ⇒ Object
def generate_parallel_connection
generate_connection(:typhoeus)
end
17 18 19 20 21 22 23 24 25 |
# File 'lib/smooth_operator/operators/faraday.rb', line 17 def generate_connection(adapter = nil, = nil) adapter ||= :net_http ::Faraday.new(url: [:endpoint]) do |builder| builder.[:timeout] = [:timeout].to_i unless Helpers.blank?([:timeout]) builder.request :url_encoded builder.adapter adapter end end |
#make_the_call(http_verb, resource_path, params, body, options) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/smooth_operator/operators/faraday.rb', line 27 def make_the_call(http_verb, resource_path, params, body, ) connection, , = () remote_call = begin set_basic_authentication(connection, ) response = connection.send(http_verb, resource_path) do |request| request_configuration(request, , , params, body) end RemoteCall::Faraday.new(response) rescue ::Faraday::Error::ConnectionFailed RemoteCall::Errors::ConnectionFailed.new(response) rescue ::Faraday::Error::TimeoutError RemoteCall::Errors::Timeout.new(response) end block_given? ? yield(remote_call) : remote_call end |