Class: Ksef::Sessions::SessionState
- Inherits:
-
Data
- Object
- Data
- Ksef::Sessions::SessionState
- Defined in:
- lib/ksef/sessions/session_state.rb
Overview
The response to GET /sessions/{ref} — the contract's SessionStatusResponse
(docs/REFERENCE.md §12).
The transition worth understanding is 170 → 200. Closing a session starts
asynchronous generation of the collective UPO, so "closed" is one step short of
"the UPO exists" — #closed? and #success? are deliberately separate, and
#upo_pages is empty until the latter.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#failed_count ⇒ Object
readonly
Returns the value of attribute failed_count.
-
#invoice_count ⇒ Object
readonly
Returns the value of attribute invoice_count.
-
#reference_number ⇒ Object
readonly
Returns the value of attribute reference_number.
-
#successful_count ⇒ Object
readonly
Returns the value of attribute successful_count.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#upo_pages ⇒ Object
readonly
Returns the value of attribute upo_pages.
-
#valid_until ⇒ Object
readonly
Returns the value of attribute valid_until.
Class Method Summary collapse
Instance Method Summary collapse
-
#closed? ⇒ Boolean
Closed, but the collective UPO is still being generated — not the end state.
-
#explain ⇒ Object
Prefers KSeF's own wording; falls back to our table when it sends none.
- #in_progress? ⇒ Boolean
-
#key_rejected? ⇒ Boolean
The symmetric key was rejected at open, so nothing in this session was readable.
- #success? ⇒ Boolean
- #terminal? ⇒ Boolean
- #to_s ⇒ Object
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code
12 13 14 |
# File 'lib/ksef/sessions/session_state.rb', line 12 def code @code end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at
12 13 14 |
# File 'lib/ksef/sessions/session_state.rb', line 12 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description
12 13 14 |
# File 'lib/ksef/sessions/session_state.rb', line 12 def description @description end |
#details ⇒ Object (readonly)
Returns the value of attribute details
12 13 14 |
# File 'lib/ksef/sessions/session_state.rb', line 12 def details @details end |
#failed_count ⇒ Object (readonly)
Returns the value of attribute failed_count
12 13 14 |
# File 'lib/ksef/sessions/session_state.rb', line 12 def failed_count @failed_count end |
#invoice_count ⇒ Object (readonly)
Returns the value of attribute invoice_count
12 13 14 |
# File 'lib/ksef/sessions/session_state.rb', line 12 def invoice_count @invoice_count end |
#reference_number ⇒ Object (readonly)
Returns the value of attribute reference_number
12 13 14 |
# File 'lib/ksef/sessions/session_state.rb', line 12 def reference_number @reference_number end |
#successful_count ⇒ Object (readonly)
Returns the value of attribute successful_count
12 13 14 |
# File 'lib/ksef/sessions/session_state.rb', line 12 def successful_count @successful_count end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at
12 13 14 |
# File 'lib/ksef/sessions/session_state.rb', line 12 def updated_at @updated_at end |
#upo_pages ⇒ Object (readonly)
Returns the value of attribute upo_pages
12 13 14 |
# File 'lib/ksef/sessions/session_state.rb', line 12 def upo_pages @upo_pages end |
#valid_until ⇒ Object (readonly)
Returns the value of attribute valid_until
12 13 14 |
# File 'lib/ksef/sessions/session_state.rb', line 12 def valid_until @valid_until end |
Class Method Details
.from(payload, reference_number) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ksef/sessions/session_state.rb', line 16 def self.from(payload, reference_number) new( reference_number: reference_number, **Sessions.status_info(payload), created_at: Ksef::Auth.time(payload["dateCreated"]), updated_at: Ksef::Auth.time(payload["dateUpdated"]), valid_until: Ksef::Auth.time(payload["validUntil"]), invoice_count: payload["invoiceCount"], successful_count: payload["successfulInvoiceCount"], failed_count: payload["failedInvoiceCount"], upo_pages: Array(payload.dig("upo", "pages")).map { |page| UpoPage.from(page) }.freeze ) end |
Instance Method Details
#closed? ⇒ Boolean
Closed, but the collective UPO is still being generated — not the end state.
35 |
# File 'lib/ksef/sessions/session_state.rb', line 35 def closed? = SessionCodes.closed?(code) |
#explain ⇒ Object
Prefers KSeF's own wording; falls back to our table when it sends none.
43 |
# File 'lib/ksef/sessions/session_state.rb', line 43 def explain = description.to_s.empty? ? SessionCodes.describe(code) : description |
#in_progress? ⇒ Boolean
30 |
# File 'lib/ksef/sessions/session_state.rb', line 30 def in_progress? = SessionCodes.in_progress?(code) |
#key_rejected? ⇒ Boolean
The symmetric key was rejected at open, so nothing in this session was readable. Distinct from a per-invoice decryption failure, which is the AES payload rather than the RSA-OAEP key wrap.
40 |
# File 'lib/ksef/sessions/session_state.rb', line 40 def key_rejected? = SessionCodes.key_rejected?(code) |
#success? ⇒ Boolean
31 |
# File 'lib/ksef/sessions/session_state.rb', line 31 def success? = SessionCodes.success?(code) |
#terminal? ⇒ Boolean
32 |
# File 'lib/ksef/sessions/session_state.rb', line 32 def terminal? = SessionCodes.terminal?(code) |
#to_s ⇒ Object
45 |
# File 'lib/ksef/sessions/session_state.rb', line 45 def to_s = reference_number.to_s |