Class: Nfe::ProductInvoice
- Inherits:
-
Data
- Object
- Data
- Nfe::ProductInvoice
- Defined in:
- lib/nfe/resources/dto/product_invoice.rb,
sig/nfe/resources/dto/product_invoice.rbs
Overview
Immutable value object for a product invoice (NF-e) as returned by the
NFE.io api.nfse.io/v2 product-invoice API.
Hand-written (rather than reusing the verbose/mangled generated
nf_produto_v2 DTO names) so the public shape stays clean and snake_case.
ProductInvoice.from_api maps the API camelCase keys onto snake_case members, drops
unknown keys, and is nil-tolerant (+from_api(nil)+ returns nil).
flow_status drives the polling lifecycle; pass it to
FlowStatus.terminal? to decide when the document is settled.
Instance Attribute Summary collapse
-
#access_key ⇒ String?
readonly
Returns the value of attribute access_key.
-
#buyer ⇒ Object
readonly
Returns the value of attribute buyer.
-
#created_on ⇒ String?
readonly
Returns the value of attribute created_on.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#flow_message ⇒ String?
readonly
Returns the value of attribute flow_message.
-
#flow_status ⇒ String?
readonly
Returns the value of attribute flow_status.
-
#id ⇒ String?
readonly
Returns the value of attribute id.
-
#issued_on ⇒ String?
readonly
Returns the value of attribute issued_on.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#modified_on ⇒ String?
readonly
Returns the value of attribute modified_on.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#operation_nature ⇒ Object
readonly
Returns the value of attribute operation_nature.
-
#operation_type ⇒ Object
readonly
Returns the value of attribute operation_type.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#serie ⇒ Object
readonly
Returns the value of attribute serie.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#totals ⇒ Object
readonly
Returns the value of attribute totals.
Class Method Summary collapse
-
.from_api(payload) ⇒ Nfe::ProductInvoice?
Build a ProductInvoice from an API payload.
- .new ⇒ instance
Instance Method Summary collapse
-
#initialize ⇒ ProductInvoice
constructor
A new instance of ProductInvoice.
Constructor Details
#initialize ⇒ ProductInvoice
Returns a new instance of ProductInvoice.
24 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 24
def initialize: (id: String?, flow_status: String?, flow_message: String?, status: untyped, environment: untyped, serie: untyped, number: untyped, operation_nature: untyped, operation_type: untyped, access_key: String?, protocol: untyped, buyer: untyped, items: untyped, totals: untyped, issued_on: String?, created_on: String?, modified_on: String?) -> void
|
Instance Attribute Details
#access_key ⇒ String? (readonly)
Returns the value of attribute access_key.
12 13 14 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 12 def access_key @access_key end |
#buyer ⇒ Object (readonly)
Returns the value of attribute buyer.
14 15 16 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 14 def buyer @buyer end |
#created_on ⇒ String? (readonly)
Returns the value of attribute created_on.
18 19 20 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 18 def created_on @created_on end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
7 8 9 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 7 def environment @environment end |
#flow_message ⇒ String? (readonly)
Returns the value of attribute flow_message.
5 6 7 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 5 def @flow_message end |
#flow_status ⇒ String? (readonly)
Returns the value of attribute flow_status.
4 5 6 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 4 def flow_status @flow_status end |
#id ⇒ String? (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 3 def id @id end |
#issued_on ⇒ String? (readonly)
Returns the value of attribute issued_on.
17 18 19 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 17 def issued_on @issued_on end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
15 16 17 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 15 def items @items end |
#modified_on ⇒ String? (readonly)
Returns the value of attribute modified_on.
19 20 21 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 19 def modified_on @modified_on end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
9 10 11 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 9 def number @number end |
#operation_nature ⇒ Object (readonly)
Returns the value of attribute operation_nature.
10 11 12 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 10 def operation_nature @operation_nature end |
#operation_type ⇒ Object (readonly)
Returns the value of attribute operation_type.
11 12 13 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 11 def operation_type @operation_type end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
13 14 15 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 13 def protocol @protocol end |
#serie ⇒ Object (readonly)
Returns the value of attribute serie.
8 9 10 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 8 def serie @serie end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 6 def status @status end |
#totals ⇒ Object (readonly)
Returns the value of attribute totals.
16 17 18 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 16 def totals @totals end |
Class Method Details
.from_api(payload) ⇒ Nfe::ProductInvoice?
Build a Nfe::ProductInvoice from an API payload.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/nfe/resources/dto/product_invoice.rb', line 37 def self.from_api(payload) return nil if payload.nil? new( id: payload["id"], flow_status: payload["flowStatus"], flow_message: payload["flowMessage"], status: payload["status"], environment: payload["environment"], serie: payload["serie"], number: payload["number"], operation_nature: payload["operationNature"], operation_type: payload["operationType"], access_key: payload["accessKey"], protocol: payload["protocol"], buyer: payload["buyer"], items: payload["items"], totals: payload["totals"], issued_on: payload["issuedOn"], created_on: payload["createdOn"], modified_on: payload["modifiedOn"] ) end |
.new ⇒ instance
23 |
# File 'sig/nfe/resources/dto/product_invoice.rbs', line 23
def self.new: (id: String?, flow_status: String?, flow_message: String?, status: untyped, environment: untyped, serie: untyped, number: untyped, operation_nature: untyped, operation_type: untyped, access_key: String?, protocol: untyped, buyer: untyped, items: untyped, totals: untyped, issued_on: String?, created_on: String?, modified_on: String?) -> instance
|