Class: FaradayMiddleware::PaytureAuth

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/faraday/payture_auth.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, access_token = nil) ⇒ PaytureAuth

Returns a new instance of PaytureAuth.



20
21
22
23
# File 'lib/faraday/payture_auth.rb', line 20

def initialize(app, access_token=nil)
  @app = app
  @access_token = access_token
end

Instance Method Details

#call(env) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/faraday/payture_auth.rb', line 5

def call(env)

  if env[:url].query.nil?
    query = {}
  else
    query = Faraday::Utils.parse_query(env[:url].query)
  end

  if @access_token
    env[:url].query = Faraday::Utils.build_query(query.merge('VWID' => @access_token))
  end

  @app.call env
end