module SmoothOperator::Operators::Faraday
Public Instance Methods
generate_connection(adapter = nil, options = nil)
click to toggle source
def generate_parallel_connection
generate_connection(:typhoeus)
end
# File lib/smooth_operator/operators/faraday.rb, line 20 def generate_connection(adapter = nil, options = nil) adapter ||= :net_http # new_connection = ::Faraday.new(url: options[:endpoint]) do |builder| new_connection = ::Faraday::Connection.new(options[:endpoint], options[:connection_options]) do |builder| builder.options[:timeout] = options[:timeout].to_i unless Helpers.blank?(options[:timeout]) builder.request :url_encoded builder.adapter adapter end ConnectionWrapper.new new_connection end
make_the_call(http_verb, resource_path, params, body, options) { |remote_call| ... }
click to toggle source
# File lib/smooth_operator/operators/faraday.rb, line 34 def make_the_call(http_verb, resource_path, params, body, options) connection, request_options, options = strip_options(options) remote_call = begin set_basic_authentication(connection, options) response = connection.send(http_verb, resource_path) do |request| request_configuration(request, request_options, options, 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