Class: FaradayMiddleware::Invoice2goAuth

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

Instance Method Summary collapse

Constructor Details

#initialize(app, api_key) ⇒ Invoice2goAuth

Returns a new instance of Invoice2goAuth.



4
5
6
7
# File 'lib/faraday/auth.rb', line 4

def initialize(app, api_key)
  @app          = app
  @api_key      = api_key
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
# File 'lib/faraday/auth.rb', line 9

def call(env)
  env[:request_headers] = env[:request_headers].merge('Authorization' => "Bearer #{@api_key}")
  @app.call env
end