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
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/smooth_operator/operators/faraday.rb', line 20 def generate_connection(adapter = nil, = nil) adapter ||= :net_http # new_connection = ::Faraday.new(url: options[:endpoint]) do |builder| new_connection = ::Faraday::Connection.new([:endpoint], [:connection_options]) do |builder| builder.[:timeout] = [:timeout].to_i unless Helpers.blank?([:timeout]) builder.request :url_encoded builder.adapter adapter end ConnectionWrapper.new new_connection end |
#make_the_call(http_verb, resource_path, params, body, options) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/smooth_operator/operators/faraday.rb', line 34 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 |