Class: Nfe::ConsumerInvoice
- Inherits:
-
Data
- Object
- Data
- Nfe::ConsumerInvoice
- Defined in:
- lib/nfe/resources/dto/consumer_invoice.rb,
sig/nfe/resources/dto/consumer_invoice.rbs
Overview
Immutable value object for a consumer invoice (NFC-e — Nota Fiscal de
Consumidor EletrĂ´nica) emitted through the NFE.io api.nfse.io v2 API.
Hand-written (rather than reusing the verbose generated nf-consumidor-v2
DTOs) so the public shape stays clean and snake_case. ConsumerInvoice.from_api maps the
API camelCase keys onto the snake_case members, drops unknown keys, and is
nil-tolerant (+from_api(nil)+ returns nil). The full parsed payload is
preserved under raw for forward compatibility.
Shape mirrors POST /v2/companies/{id}/consumerinvoices and
GET .../consumerinvoices/{id} per nf-consumidor-v2.yaml.
+number+/+serie+ are kept as returned (no Integer coercion) so leading zeros and string representations from the API survive untouched.
Instance Attribute Summary collapse
-
#access_key ⇒ String?
readonly
Returns the value of attribute access_key.
-
#cancelled_on ⇒ String?
readonly
Returns the value of attribute cancelled_on.
-
#created_on ⇒ String?
readonly
Returns the value of attribute created_on.
-
#environment ⇒ String?
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.
-
#modified_on ⇒ String?
readonly
Returns the value of attribute modified_on.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#raw ⇒ Hash[untyped, untyped]?
readonly
Returns the value of attribute raw.
-
#serie ⇒ Object
readonly
Returns the value of attribute serie.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#total_amount ⇒ Object
readonly
Returns the value of attribute total_amount.
Class Method Summary collapse
-
.from_api(payload) ⇒ Nfe::ConsumerInvoice?
Build a ConsumerInvoice from an API payload.
- .new ⇒ instance
Instance Method Summary collapse
-
#initialize ⇒ ConsumerInvoice
constructor
A new instance of ConsumerInvoice.
Constructor Details
#initialize ⇒ ConsumerInvoice
Returns a new instance of ConsumerInvoice.
22 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 22
def initialize: (id: String?, status: untyped, flow_status: String?, flow_message: String?, environment: String?, access_key: String?, number: untyped, serie: untyped, total_amount: untyped, issued_on: String?, created_on: String?, modified_on: String?, cancelled_on: String?, raw: Hash[untyped, untyped]?) -> void
|
Instance Attribute Details
#access_key ⇒ String? (readonly)
Returns the value of attribute access_key.
8 9 10 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 8 def access_key @access_key end |
#cancelled_on ⇒ String? (readonly)
Returns the value of attribute cancelled_on.
15 16 17 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 15 def cancelled_on @cancelled_on end |
#created_on ⇒ String? (readonly)
Returns the value of attribute created_on.
13 14 15 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 13 def created_on @created_on end |
#environment ⇒ String? (readonly)
Returns the value of attribute environment.
7 8 9 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 7 def environment @environment end |
#flow_message ⇒ String? (readonly)
Returns the value of attribute flow_message.
6 7 8 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 6 def @flow_message end |
#flow_status ⇒ String? (readonly)
Returns the value of attribute flow_status.
5 6 7 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 5 def flow_status @flow_status end |
#id ⇒ String? (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 3 def id @id end |
#issued_on ⇒ String? (readonly)
Returns the value of attribute issued_on.
12 13 14 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 12 def issued_on @issued_on end |
#modified_on ⇒ String? (readonly)
Returns the value of attribute modified_on.
14 15 16 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 14 def modified_on @modified_on end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
9 10 11 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 9 def number @number end |
#raw ⇒ Hash[untyped, untyped]? (readonly)
Returns the value of attribute raw.
16 17 18 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 16 def raw @raw end |
#serie ⇒ Object (readonly)
Returns the value of attribute serie.
10 11 12 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 10 def serie @serie end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 4 def status @status end |
#total_amount ⇒ Object (readonly)
Returns the value of attribute total_amount.
11 12 13 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 11 def total_amount @total_amount end |
Class Method Details
.from_api(payload) ⇒ Nfe::ConsumerInvoice?
Build a Nfe::ConsumerInvoice from an API payload.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/nfe/resources/dto/consumer_invoice.rb', line 38 def self.from_api(payload) return nil if payload.nil? new( id: payload["id"], status: payload["status"], flow_status: payload["flowStatus"], flow_message: payload["flowMessage"], environment: payload["environment"], access_key: payload["accessKey"], number: payload["number"], serie: payload["serie"], total_amount: payload["totalAmount"], issued_on: payload["issuedOn"], created_on: payload["createdOn"], modified_on: payload["modifiedOn"], cancelled_on: payload["cancelledOn"], raw: payload ) end |
.new ⇒ instance
20 |
# File 'sig/nfe/resources/dto/consumer_invoice.rbs', line 20
def self.new: (id: String?, status: untyped, flow_status: String?, flow_message: String?, environment: String?, access_key: String?, number: untyped, serie: untyped, total_amount: untyped, issued_on: String?, created_on: String?, modified_on: String?, cancelled_on: String?, raw: Hash[untyped, untyped]?) -> instance
|