Class: Nfe::ProductInvoiceDetails
- Inherits:
-
Data
- Object
- Data
- Nfe::ProductInvoiceDetails
- Defined in:
- lib/nfe/resources/dto/product_invoice_query/product_invoice_details.rb,
sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs
Overview
Immutable value object for the details of a product invoice (NF-e) fetched
from the nfe.api.nfe.io distribution/query API by its access key
(+GET /v2/productinvoices/accessKey+).
Hand-written (the consulta_nfe_distribuicao_v1 generated schema does not
cover this pragmatic shape). ProductInvoiceDetails.from_api maps the API camelCase keys onto the
snake_case members, hydrates the nested value objects, drops unknown keys,
and is nil-tolerant (+from_api(nil)+ returns nil). All fields are optional.
The access key is NOT a body field — it is the path parameter the caller
already holds — so it is intentionally not exposed here. current_status is
the real top-level field (+currentStatus+, enum +unknown+/+authorized+/
canceled). The nested objects (Issuer, Buyer, Totals) keep only a
pragmatic subset of the most common fields; items is kept as the raw
payload array (free-form line bodies), normalized to [] when missing.
Defined Under Namespace
Classes: Buyer, Issuer, Totals
Instance Attribute Summary collapse
-
#buyer ⇒ Nfe::ProductInvoiceDetails::Buyer?
readonly
Returns the value of attribute buyer.
-
#check_code ⇒ String?
readonly
Returns the value of attribute check_code.
-
#current_status ⇒ String?
readonly
Returns the value of attribute current_status.
-
#issued_on ⇒ String?
readonly
Returns the value of attribute issued_on.
-
#issuer ⇒ Nfe::ProductInvoiceDetails::Issuer?
readonly
Returns the value of attribute issuer.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#operation_nature ⇒ String?
readonly
Returns the value of attribute operation_nature.
-
#operation_on ⇒ String?
readonly
Returns the value of attribute operation_on.
-
#serie ⇒ Object
readonly
Returns the value of attribute serie.
-
#state_code ⇒ Object
readonly
Returns the value of attribute state_code.
-
#totals ⇒ Nfe::ProductInvoiceDetails::Totals?
readonly
Returns the value of attribute totals.
Class Method Summary collapse
-
.from_api(payload) ⇒ Nfe::ProductInvoiceDetails?
Build a ProductInvoiceDetails from an API payload.
- .new ⇒ instance
Instance Method Summary collapse
-
#initialize ⇒ ProductInvoiceDetails
constructor
A new instance of ProductInvoiceDetails.
Constructor Details
#initialize ⇒ ProductInvoiceDetails
Returns a new instance of ProductInvoiceDetails.
51 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 51
def initialize: (current_status: String?, state_code: untyped, check_code: String?, operation_nature: String?, serie: untyped, number: untyped, issued_on: String?, operation_on: String?, issuer: Nfe::ProductInvoiceDetails::Issuer?, buyer: Nfe::ProductInvoiceDetails::Buyer?, totals: Nfe::ProductInvoiceDetails::Totals?, items: untyped) -> void
|
Instance Attribute Details
#buyer ⇒ Nfe::ProductInvoiceDetails::Buyer? (readonly)
Returns the value of attribute buyer.
45 46 47 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 45 def buyer @buyer end |
#check_code ⇒ String? (readonly)
Returns the value of attribute check_code.
38 39 40 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 38 def check_code @check_code end |
#current_status ⇒ String? (readonly)
Returns the value of attribute current_status.
36 37 38 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 36 def current_status @current_status end |
#issued_on ⇒ String? (readonly)
Returns the value of attribute issued_on.
42 43 44 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 42 def issued_on @issued_on end |
#issuer ⇒ Nfe::ProductInvoiceDetails::Issuer? (readonly)
Returns the value of attribute issuer.
44 45 46 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 44 def issuer @issuer end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
47 48 49 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 47 def items @items end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
41 42 43 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 41 def number @number end |
#operation_nature ⇒ String? (readonly)
Returns the value of attribute operation_nature.
39 40 41 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 39 def operation_nature @operation_nature end |
#operation_on ⇒ String? (readonly)
Returns the value of attribute operation_on.
43 44 45 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 43 def operation_on @operation_on end |
#serie ⇒ Object (readonly)
Returns the value of attribute serie.
40 41 42 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 40 def serie @serie end |
#state_code ⇒ Object (readonly)
Returns the value of attribute state_code.
37 38 39 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 37 def state_code @state_code end |
#totals ⇒ Nfe::ProductInvoiceDetails::Totals? (readonly)
Returns the value of attribute totals.
46 47 48 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 46 def totals @totals end |
Class Method Details
.from_api(payload) ⇒ Nfe::ProductInvoiceDetails?
Build a Nfe::ProductInvoiceDetails from an API payload.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/nfe/resources/dto/product_invoice_query/product_invoice_details.rb', line 80 def self.from_api(payload) return nil if payload.nil? new( current_status: payload["currentStatus"], state_code: payload["stateCode"], check_code: payload["checkCode"]&.to_s, operation_nature: payload["operationNature"], serie: payload["serie"], number: payload["number"], issued_on: payload["issuedOn"], operation_on: payload["operationOn"], issuer: Issuer.from_api(payload["issuer"]), buyer: Buyer.from_api(payload["buyer"]), totals: Totals.from_api(payload["totals"]), items: payload["items"] || [] ) end |
.new ⇒ instance
50 |
# File 'sig/nfe/resources/dto/product_invoice_query/product_invoice_details.rbs', line 50
def self.new: (current_status: String?, state_code: untyped, check_code: String?, operation_nature: String?, serie: untyped, number: untyped, issued_on: String?, operation_on: String?, issuer: Nfe::ProductInvoiceDetails::Issuer?, buyer: Nfe::ProductInvoiceDetails::Buyer?, totals: Nfe::ProductInvoiceDetails::Totals?, items: untyped) -> instance
|