Class: Ksef::Sessions::InvoiceState
- Inherits:
-
Data
- Object
- Data
- Ksef::Sessions::InvoiceState
- Defined in:
- lib/ksef/sessions/invoice_state.rb
Overview
The response to GET /sessions/{ref}/invoices/{invoiceRef} — the contract's
SessionInvoiceStatusResponse (docs/REFERENCE.md §12, §12.1).
Two fields repay attention.
upo_download_url arrives here, so the per-invoice UPO needs no separate call. It
is a pre-signed storage link with the same rules as UpoPage: no bearer token, verify
x-ms-meta-hash, and it expires.
extensions is populated only for a duplicate. On status 440 KSeF returns the
original submission's KSeF number and session reference, which is what lets a caller
reconcile a resend instead of guessing. Nothing else fills it in.
Instance Attribute Summary collapse
-
#acquisition_date ⇒ Object
readonly
Returns the value of attribute acquisition_date.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#invoice_number ⇒ Object
readonly
Returns the value of attribute invoice_number.
-
#ksef_number ⇒ Object
readonly
Returns the value of attribute ksef_number.
-
#reference_number ⇒ Object
readonly
Returns the value of attribute reference_number.
-
#upo_download_url ⇒ Object
readonly
Returns the value of attribute upo_download_url.
-
#upo_download_url_expires_at ⇒ Object
readonly
Returns the value of attribute upo_download_url_expires_at.
Class Method Summary collapse
Instance Method Summary collapse
- #duplicate? ⇒ Boolean
-
#explain ⇒ Object
Prefers KSeF's own wording; falls back to our table when it sends none.
- #in_progress? ⇒ Boolean
-
#inspect ⇒ Object
Redacted for the same reason UpoPage redacts its link, and this docstring said so before the code did:
upo_download_urlis pre-signed, carrying its own authorisation in the query string, so it is a credential and must not reach a log line (DESIGN.md §4.5). -
#ksef_number_parsed ⇒ Ksef::KsefNumber?
Parsed rather than returned raw, so the CRC-8 is checked and the acceptance date is a Date.
- #original_ksef_number ⇒ Object
- #original_session_reference ⇒ Object
- #retryable? ⇒ Boolean
- #success? ⇒ Boolean
- #terminal? ⇒ Boolean
- #to_s ⇒ Object
Instance Attribute Details
#acquisition_date ⇒ Object (readonly)
Returns the value of attribute acquisition_date
17 18 19 |
# File 'lib/ksef/sessions/invoice_state.rb', line 17 def acquisition_date @acquisition_date end |
#code ⇒ Object (readonly)
Returns the value of attribute code
17 18 19 |
# File 'lib/ksef/sessions/invoice_state.rb', line 17 def code @code end |
#description ⇒ Object (readonly)
Returns the value of attribute description
17 18 19 |
# File 'lib/ksef/sessions/invoice_state.rb', line 17 def description @description end |
#details ⇒ Object (readonly)
Returns the value of attribute details
17 18 19 |
# File 'lib/ksef/sessions/invoice_state.rb', line 17 def details @details end |
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions
17 18 19 |
# File 'lib/ksef/sessions/invoice_state.rb', line 17 def extensions @extensions end |
#invoice_number ⇒ Object (readonly)
Returns the value of attribute invoice_number
17 18 19 |
# File 'lib/ksef/sessions/invoice_state.rb', line 17 def invoice_number @invoice_number end |
#ksef_number ⇒ Object (readonly)
Returns the value of attribute ksef_number
17 18 19 |
# File 'lib/ksef/sessions/invoice_state.rb', line 17 def ksef_number @ksef_number end |
#reference_number ⇒ Object (readonly)
Returns the value of attribute reference_number
17 18 19 |
# File 'lib/ksef/sessions/invoice_state.rb', line 17 def reference_number @reference_number end |
#upo_download_url ⇒ Object (readonly)
Returns the value of attribute upo_download_url
17 18 19 |
# File 'lib/ksef/sessions/invoice_state.rb', line 17 def upo_download_url @upo_download_url end |
#upo_download_url_expires_at ⇒ Object (readonly)
Returns the value of attribute upo_download_url_expires_at
17 18 19 |
# File 'lib/ksef/sessions/invoice_state.rb', line 17 def upo_download_url_expires_at @upo_download_url_expires_at end |
Class Method Details
.from(payload) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ksef/sessions/invoice_state.rb', line 21 def self.from(payload) new( reference_number: payload["referenceNumber"], ksef_number: payload["ksefNumber"], invoice_number: payload["invoiceNumber"], **Sessions.status_info(payload), extensions: (payload.dig("status", "extensions") || {}).freeze, acquisition_date: Ksef::Auth.time(payload["acquisitionDate"]), upo_download_url: payload["upoDownloadUrl"], upo_download_url_expires_at: Ksef::Auth.time(payload["upoDownloadUrlExpirationDate"]) ) end |
Instance Method Details
#duplicate? ⇒ Boolean
42 |
# File 'lib/ksef/sessions/invoice_state.rb', line 42 def duplicate? = code == InvoiceCodes::DUPLICATE |
#explain ⇒ Object
Prefers KSeF's own wording; falls back to our table when it sends none.
40 |
# File 'lib/ksef/sessions/invoice_state.rb', line 40 def explain = description.to_s.empty? ? InvoiceCodes.describe(code) : description |
#in_progress? ⇒ Boolean
34 |
# File 'lib/ksef/sessions/invoice_state.rb', line 34 def in_progress? = InvoiceCodes.in_progress?(code) |
#inspect ⇒ Object
Redacted for the same reason UpoPage redacts its link, and this docstring said so
before the code did: upo_download_url is pre-signed, carrying its own
authorisation in the query string, so it is a credential and must not reach a log
line (DESIGN.md §4.5). Everything else stays visible, because the status and the
duplicate extensions are exactly what a reader needs.
51 52 53 54 55 56 57 |
# File 'lib/ksef/sessions/invoice_state.rb', line 51 def inspect link = upo_download_url.nil? ? "nil" : "[PRE-SIGNED]" "#<data Ksef::Sessions::InvoiceState reference_number=#{reference_number.inspect} " \ "ksef_number=#{ksef_number.inspect} code=#{code.inspect} " \ "description=#{description.inspect} details=#{details.inspect} " \ "extensions=#{extensions.inspect} upo_download_url=#{link}>" end |
#ksef_number_parsed ⇒ Ksef::KsefNumber?
Parsed rather than returned raw, so the CRC-8 is checked and the acceptance date is
a Date. nil until the invoice is accepted.
63 |
# File 'lib/ksef/sessions/invoice_state.rb', line 63 def ksef_number_parsed = ksef_number.nil? ? nil : KsefNumber.parse(ksef_number) |
#original_ksef_number ⇒ Object
43 |
# File 'lib/ksef/sessions/invoice_state.rb', line 43 def original_ksef_number = extensions["originalKsefNumber"] |
#original_session_reference ⇒ Object
44 |
# File 'lib/ksef/sessions/invoice_state.rb', line 44 def original_session_reference = extensions["originalSessionReferenceNumber"] |
#retryable? ⇒ Boolean
37 |
# File 'lib/ksef/sessions/invoice_state.rb', line 37 def retryable? = InvoiceCodes.retryable?(code) |
#success? ⇒ Boolean
35 |
# File 'lib/ksef/sessions/invoice_state.rb', line 35 def success? = InvoiceCodes.success?(code) |
#terminal? ⇒ Boolean
36 |
# File 'lib/ksef/sessions/invoice_state.rb', line 36 def terminal? = InvoiceCodes.terminal?(code) |
#to_s ⇒ Object
65 |
# File 'lib/ksef/sessions/invoice_state.rb', line 65 def to_s = reference_number.to_s |