Class: Ksef::Sessions::UpoPage

Inherits:
Data
  • Object
show all
Defined in:
lib/ksef/sessions/upo_page.rb

Overview

One page of a collective UPO (docs/REFERENCE.md §12, §14.2).

A collective UPO holds at most 10 000 invoice entries, which is why a session's upo.pages is an array: a client that reads only the first page silently loses proof of receipt for every invoice beyond it.

download_url is a pre-signed storage link, not an API route. Follow it as an opaque URI, send no bearer token — sending one leaks the credential to third-party storage — and verify the x-ms-meta-hash header against the bytes received. It is regenerated on every status query and expires at #expires_at, so it must never be logged or persisted as a durable reference.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#download_url ⇒ Object (readonly)

Returns the value of attribute download_url

Returns:

  • (Object) —

    the current value of download_url



16
17
18
# File 'lib/ksef/sessions/upo_page.rb', line 16

def download_url
  @download_url
end

#expires_at ⇒ Object (readonly)

Returns the value of attribute expires_at

Returns:

  • (Object) —

    the current value of expires_at



16
17
18
# File 'lib/ksef/sessions/upo_page.rb', line 16

def expires_at
  @expires_at
end

#reference_number ⇒ Object (readonly)

Returns the value of attribute reference_number

Returns:

  • (Object) —

    the current value of reference_number



16
17
18
# File 'lib/ksef/sessions/upo_page.rb', line 16

def reference_number
  @reference_number
end

Class Method Details

.from(payload) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/ksef/sessions/upo_page.rb', line 17

def self.from(payload)
  new(
    reference_number: payload["referenceNumber"],
    download_url: payload["downloadUrl"],
    expires_at: Ksef::Auth.time(payload["downloadUrlExpirationDate"])
  )
end

Instance Method Details

#expired?(now = Time.now) ⇒ Boolean

Returns:

  • (Boolean)


25
# File 'lib/ksef/sessions/upo_page.rb', line 25

def expired?(now = Time.now) = !expires_at.nil? && expires_at <= now

#inspect ⇒ Object



30
31
32
33
# File 'lib/ksef/sessions/upo_page.rb', line 30

def inspect
  "#<data Ksef::Sessions::UpoPage reference_number=#{reference_number.inspect} " \
    "download_url=[PRE-SIGNED] expires_at=#{expires_at.inspect}>"
end

#to_s ⇒ Object

The link is credential-bearing, so it stays out of any log line by default.



28
# File 'lib/ksef/sessions/upo_page.rb', line 28

def to_s = reference_number.to_s