Class: BRL::Auth::AuthenticatedConnection
- Inherits:
-
Connection
- Object
- Flash::Integration::Connection
- Connection
- BRL::Auth::AuthenticatedConnection
- Defined in:
- lib/brl/auth/authenticated_connection.rb
Constant Summary collapse
- COOKIE_CACHE_KEY =
"BRL_AUTH_COOKIE_CACHE_KEY"
- CONTENT_TYPE =
"application/json"
Constants inherited from Connection
Instance Method Summary collapse
- #default_headers ⇒ Object
-
#initialize(token_service: BRL::Auth::TokenService.new, cache: defined?(Rails) ? Rails.cache : nil, request_class: Faraday, base_url: BRL::BASE_URL) ⇒ AuthenticatedConnection
constructor
A new instance of AuthenticatedConnection.
Constructor Details
#initialize(token_service: BRL::Auth::TokenService.new, cache: defined?(Rails) ? Rails.cache : nil, request_class: Faraday, base_url: BRL::BASE_URL) ⇒ AuthenticatedConnection
Returns a new instance of AuthenticatedConnection.
9 10 11 12 13 14 15 16 |
# File 'lib/brl/auth/authenticated_connection.rb', line 9 def initialize(token_service: BRL::Auth::TokenService.new, cache: defined?(Rails) ? Rails.cache : nil, request_class: Faraday, base_url: BRL::BASE_URL) super(request_class: request_class, base_url: base_url) @token_service = token_service @cache = cache end |
Instance Method Details
#default_headers ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/brl/auth/authenticated_connection.rb', line 18 def default_headers { "Accept": CONTENT_TYPE, "Authorization": (@cache ? cached_token : auth_token), "Content-Type": CONTENT_TYPE } end |