Class: Pickpoint::Auth::State
- Inherits:
-
Object
- Object
- Pickpoint::Auth::State
- Defined in:
- lib/pickpoint/auth.rb
Instance Method Summary collapse
- #apply!(headers) ⇒ Object
- #bearer? ⇒ Boolean
-
#initialize(api_key: nil, session: nil) ⇒ State
constructor
A new instance of State.
- #refresh_after_unauthorized ⇒ Object
Constructor Details
#initialize(api_key: nil, session: nil) ⇒ State
Returns a new instance of State.
37 38 39 40 |
# File 'lib/pickpoint/auth.rb', line 37 def initialize(api_key: nil, session: nil) @api_key = api_key @session = session end |
Instance Method Details
#apply!(headers) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/pickpoint/auth.rb', line 46 def apply!(headers) headers["Accept"] = "application/json" if @api_key headers["x-api-key"] = @api_key return end headers["Authorization"] = "Bearer #{@session.token}" end |
#bearer? ⇒ Boolean
42 43 44 |
# File 'lib/pickpoint/auth.rb', line 42 def bearer? !@session.nil? end |
#refresh_after_unauthorized ⇒ Object
55 56 57 58 59 |
# File 'lib/pickpoint/auth.rb', line 55 def return false if @session.nil? @session. end |