Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
gingr / lib / faraday / auth.rb
Size: Mime:
module FaradayMiddleware
  # TODO: This class may or may not be needed. It depends on how the target API handles authentication.
  # TODO: If you remove this class remember to also remove it from the Connection Faraday configuration.
  class GingrAuth < Faraday::Middleware

    # TODO: Pass in whatever tokens, keys needed to connect to the target API. These should be available
    # TODO: from the Configuration class.
    def initialize(app, api_key, company_app_name)
      @app          = app
      @api_key      = api_key
      @company_app_name  = company_app_name
    end

    # TODO: Faraday will call this for each request. Setup whatever authorization is required by the
    # TODO: target API.
    def call(env)
      env[:request_headers] = env[:request_headers].merge('key' => "#{@api_key}")
      env[:request_headers] = env[:request_headers].merge('company_app_name' => "#{@company_app_name}")
      @app.call env
    end

  end
end