Class: Ksef::Session
- Inherits:
-
Object
- Object
- Ksef::Session
- Defined in:
- lib/ksef/session.rb
Overview
An open authenticated session against the KSeF API.
Holds the access/refresh tokens minted by ‘/auth/token/redeem` together with the authentication operation’s reference number. Instances are produced by Ksef::Sessions#open (or #with_interactive) and consumed by resource classes through Client#current_session.
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#access_token_valid_until ⇒ Object
readonly
Returns the value of attribute access_token_valid_until.
-
#reference_number ⇒ Object
readonly
Returns the value of attribute reference_number.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#refresh_token_valid_until ⇒ Object
readonly
Returns the value of attribute refresh_token_valid_until.
Instance Method Summary collapse
-
#initialize(reference_number:, access_token:, refresh_token:, access_token_valid_until: nil, refresh_token_valid_until: nil) ⇒ Session
constructor
A new instance of Session.
-
#mark_terminated! ⇒ Object
Marks the session as closed locally.
- #terminated? ⇒ Boolean
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(reference_number:, access_token:, refresh_token:, access_token_valid_until: nil, refresh_token_valid_until: nil) ⇒ Session
Returns a new instance of Session.
15 16 17 18 19 20 21 22 23 |
# File 'lib/ksef/session.rb', line 15 def initialize(reference_number:, access_token:, refresh_token:, access_token_valid_until: nil, refresh_token_valid_until: nil) @reference_number = reference_number @access_token = access_token @refresh_token = refresh_token @access_token_valid_until = access_token_valid_until @refresh_token_valid_until = refresh_token_valid_until @terminated = false end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
11 12 13 |
# File 'lib/ksef/session.rb', line 11 def access_token @access_token end |
#access_token_valid_until ⇒ Object (readonly)
Returns the value of attribute access_token_valid_until.
11 12 13 |
# File 'lib/ksef/session.rb', line 11 def access_token_valid_until @access_token_valid_until end |
#reference_number ⇒ Object (readonly)
Returns the value of attribute reference_number.
11 12 13 |
# File 'lib/ksef/session.rb', line 11 def reference_number @reference_number end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
11 12 13 |
# File 'lib/ksef/session.rb', line 11 def refresh_token @refresh_token end |
#refresh_token_valid_until ⇒ Object (readonly)
Returns the value of attribute refresh_token_valid_until.
11 12 13 |
# File 'lib/ksef/session.rb', line 11 def refresh_token_valid_until @refresh_token_valid_until end |
Instance Method Details
#mark_terminated! ⇒ Object
Marks the session as closed locally. Network teardown is performed by Ksef::Sessions#terminate.
31 32 33 |
# File 'lib/ksef/session.rb', line 31 def mark_terminated! @terminated = true end |
#terminated? ⇒ Boolean
25 26 27 |
# File 'lib/ksef/session.rb', line 25 def terminated? @terminated end |
#to_s ⇒ Object Also known as: inspect
35 36 37 38 |
# File 'lib/ksef/session.rb', line 35 def to_s "#<Ksef::Session reference_number=#{@reference_number.inspect} " \ "terminated=#{@terminated}>" end |