Class: Nfe::NfeFileResource
- Inherits:
-
Data
- Object
- Data
- Nfe::NfeFileResource
- Defined in:
- lib/nfe/resources/dto/nfe_file_resource.rb,
sig/nfe/resources/dto/nfe_file_resource.rbs
Overview
Immutable value object describing a downloadable file as returned by the
api.nfse.io/v2 product-invoice download endpoints, which respond with a
JSON envelope carrying a uri to the file rather than the raw bytes.
This is what distinguishes Resources::ProductInvoices downloads
(which return a NfeFileResource) from the byte-returning downloads on the
other invoice resources. NfeFileResource.from_api maps camelCase keys onto snake_case
members, drops unknown keys, and is nil-tolerant.
Instance Attribute Summary collapse
-
#content_type ⇒ String?
readonly
Returns the value of attribute content_type.
-
#name ⇒ String?
readonly
Returns the value of attribute name.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#uri ⇒ String?
readonly
Returns the value of attribute uri.
Class Method Summary collapse
-
.from_api(payload) ⇒ Nfe::NfeFileResource?
Build a NfeFileResource from an API payload.
- .new ⇒ instance
Instance Method Summary collapse
-
#initialize ⇒ NfeFileResource
constructor
A new instance of NfeFileResource.
Constructor Details
#initialize ⇒ NfeFileResource
Returns a new instance of NfeFileResource.
11 |
# File 'sig/nfe/resources/dto/nfe_file_resource.rbs', line 11
def initialize: (?uri: String?, ?name: String?, ?content_type: String?, ?size: untyped) -> void
|
Instance Attribute Details
#content_type ⇒ String? (readonly)
Returns the value of attribute content_type.
5 6 7 |
# File 'sig/nfe/resources/dto/nfe_file_resource.rbs', line 5 def content_type @content_type end |
#name ⇒ String? (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'sig/nfe/resources/dto/nfe_file_resource.rbs', line 4 def name @name end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
6 7 8 |
# File 'sig/nfe/resources/dto/nfe_file_resource.rbs', line 6 def size @size end |
#uri ⇒ String? (readonly)
Returns the value of attribute uri.
3 4 5 |
# File 'sig/nfe/resources/dto/nfe_file_resource.rbs', line 3 def uri @uri end |
Class Method Details
.from_api(payload) ⇒ Nfe::NfeFileResource?
Build a Nfe::NfeFileResource from an API payload.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nfe/resources/dto/nfe_file_resource.rb', line 17 def self.from_api(payload) return nil if payload.nil? new( uri: payload["uri"] || payload["url"], name: payload["name"], content_type: payload["contentType"], size: payload["size"] ) end |
.new ⇒ instance
10 |
# File 'sig/nfe/resources/dto/nfe_file_resource.rbs', line 10
def self.new: (?uri: String?, ?name: String?, ?content_type: String?, ?size: untyped) -> instance
|