Class: CreditGateway::FaradayAuth
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- CreditGateway::FaradayAuth
- Defined in:
- lib/credit_gateway/faraday_auth.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, client_id, client_secret, country, options = {}) ⇒ FaradayAuth
constructor
A new instance of FaradayAuth.
Constructor Details
#initialize(app, client_id, client_secret, country, options = {}) ⇒ FaradayAuth
Returns a new instance of FaradayAuth.
9 10 11 12 13 14 15 16 |
# File 'lib/credit_gateway/faraday_auth.rb', line 9 def initialize(app, client_id, client_secret, country, = {}) super(app) @client_id = client_id @client_secret = client_secret @country = country = @token = nil end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/credit_gateway/faraday_auth.rb', line 18 def call(env) @token ||= authenticate env[:request_headers]['Authorization'] = "Bearer #{@token}" env[:request_headers]['X-Country'] = @country env[:request_headers]['Content-Type'] = 'application/json' env[:request_headers]['User-Agent'] = "finpoint/#{CreditGateway::VERSION}" @app.call(env) end |