class Payments::Client::Gateway
Public Class Methods
new(adapter, config, *adapter_options, connection: nil)
click to toggle source
# File lib/payments/client/gateway.rb, line 9 def initialize(adapter, config, *adapter_options, connection: nil) @config = config @adapter = adapter @adapter_options = adapter_options @connection = connection end
Public Instance Methods
with_middleware(keep: true, response: nil)
click to toggle source
# File lib/payments/client/gateway.rb, line 28 def with_middleware(keep: true, response: nil) new_connection = connection.dup new_connection.build(keep: keep) do |builder| Array(response).each do |middleware| builder.response middleware end end self.class.new( @adapter, @config, *@adapter_options, connection: new_connection, ) end
Private Instance Methods
connection()
click to toggle source
# File lib/payments/client/gateway.rb, line 50 def connection @connection ||= Faraday.new(url: @config.host) do |connection| connection.request :json connection.basic_auth @config.username, @config.password connection.use :instrumentation, name: "client.payments" connection.adapter @adapter, *@adapter_options end end
prefix(path)
click to toggle source
# File lib/payments/client/gateway.rb, line 46 def prefix(path) @config.path_prefix + path end