Class: Nfe::TaxCoupon
- Inherits:
-
Data
- Object
- Data
- Nfe::TaxCoupon
- Defined in:
- lib/nfe/resources/dto/consumer_invoice_query/tax_coupon.rb,
sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs
Overview
Immutable value object for a consumer-invoice tax coupon (CFe-SAT)
returned by the nfe.api.nfe.io query API
(+GET /v1/consumerinvoices/coupon/accessKey+).
This is the QUERY (consulta) of an already-issued coupon by access key and is DISTINCT from ConsumerInvoice (the emission model handled by Resources::ConsumerInvoices) — different host and API version.
All fields are optional; TaxCoupon.from_api maps the API camelCase keys onto the
snake_case members, hydrates the nested value objects, and is nil-tolerant
(+from_api(nil)+ returns nil). The nested objects (Issuer, Buyer,
Total, Delivery, AdditionalInformation, Item, Payment) keep only a
pragmatic subset of the most common fields, mapped against the real CFe-SAT
TaxCouponResource shape.
Defined Under Namespace
Classes: AdditionalInformation, Address, Buyer, Delivery, Issuer, Item, Payment, PaymentDetail, Total
Instance Attribute Summary collapse
-
#access_key ⇒ Object
readonly
Returns the value of attribute access_key.
-
#additional_information ⇒ Nfe::TaxCoupon::AdditionalInformation?
readonly
Returns the value of attribute additional_information.
-
#buyer ⇒ Nfe::TaxCoupon::Buyer?
readonly
Returns the value of attribute buyer.
-
#cashier ⇒ Object
readonly
Returns the value of attribute cashier.
-
#created_on ⇒ String?
readonly
Returns the value of attribute created_on.
-
#current_status ⇒ Object
readonly
Returns the value of attribute current_status.
-
#delivery ⇒ Nfe::TaxCoupon::Delivery?
readonly
Returns the value of attribute delivery.
-
#issued_on ⇒ String?
readonly
Returns the value of attribute issued_on.
-
#issuer ⇒ Nfe::TaxCoupon::Issuer?
readonly
Returns the value of attribute issuer.
-
#items ⇒ Array[Nfe::TaxCoupon::Item?]
readonly
Returns the value of attribute items.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#payment ⇒ Nfe::TaxCoupon::Payment?
readonly
Returns the value of attribute payment.
-
#sat_serie ⇒ Object
readonly
Returns the value of attribute sat_serie.
-
#software_federal_tax_number ⇒ Object
readonly
Returns the value of attribute software_federal_tax_number.
-
#software_version ⇒ String?
readonly
Returns the value of attribute software_version.
-
#totals ⇒ Nfe::TaxCoupon::Total?
readonly
Returns the value of attribute totals.
-
#xml_version ⇒ String?
readonly
Returns the value of attribute xml_version.
Class Method Summary collapse
-
.from_api(payload) ⇒ Nfe::TaxCoupon?
Build a TaxCoupon from an API payload.
- .new ⇒ instance
Instance Method Summary collapse
-
#initialize ⇒ TaxCoupon
constructor
A new instance of TaxCoupon.
Constructor Details
#initialize ⇒ TaxCoupon
Returns a new instance of TaxCoupon.
115 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 115
def initialize: (current_status: untyped, number: untyped, sat_serie: untyped, software_version: String?, software_federal_tax_number: untyped, access_key: untyped, cashier: untyped, issued_on: String?, created_on: String?, xml_version: String?, issuer: Nfe::TaxCoupon::Issuer?, buyer: Nfe::TaxCoupon::Buyer?, totals: Nfe::TaxCoupon::Total?, delivery: Nfe::TaxCoupon::Delivery?, additional_information: Nfe::TaxCoupon::AdditionalInformation?, items: Array[Nfe::TaxCoupon::Item?], payment: Nfe::TaxCoupon::Payment?) -> void
|
Instance Attribute Details
#access_key ⇒ Object (readonly)
Returns the value of attribute access_key.
100 101 102 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 100 def access_key @access_key end |
#additional_information ⇒ Nfe::TaxCoupon::AdditionalInformation? (readonly)
Returns the value of attribute additional_information.
109 110 111 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 109 def additional_information @additional_information end |
#buyer ⇒ Nfe::TaxCoupon::Buyer? (readonly)
Returns the value of attribute buyer.
106 107 108 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 106 def buyer @buyer end |
#cashier ⇒ Object (readonly)
Returns the value of attribute cashier.
101 102 103 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 101 def cashier @cashier end |
#created_on ⇒ String? (readonly)
Returns the value of attribute created_on.
103 104 105 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 103 def created_on @created_on end |
#current_status ⇒ Object (readonly)
Returns the value of attribute current_status.
95 96 97 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 95 def current_status @current_status end |
#delivery ⇒ Nfe::TaxCoupon::Delivery? (readonly)
Returns the value of attribute delivery.
108 109 110 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 108 def delivery @delivery end |
#issued_on ⇒ String? (readonly)
Returns the value of attribute issued_on.
102 103 104 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 102 def issued_on @issued_on end |
#issuer ⇒ Nfe::TaxCoupon::Issuer? (readonly)
Returns the value of attribute issuer.
105 106 107 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 105 def issuer @issuer end |
#items ⇒ Array[Nfe::TaxCoupon::Item?] (readonly)
Returns the value of attribute items.
110 111 112 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 110 def items @items end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
96 97 98 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 96 def number @number end |
#payment ⇒ Nfe::TaxCoupon::Payment? (readonly)
Returns the value of attribute payment.
111 112 113 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 111 def payment @payment end |
#sat_serie ⇒ Object (readonly)
Returns the value of attribute sat_serie.
97 98 99 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 97 def sat_serie @sat_serie end |
#software_federal_tax_number ⇒ Object (readonly)
Returns the value of attribute software_federal_tax_number.
99 100 101 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 99 def software_federal_tax_number @software_federal_tax_number end |
#software_version ⇒ String? (readonly)
Returns the value of attribute software_version.
98 99 100 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 98 def software_version @software_version end |
#totals ⇒ Nfe::TaxCoupon::Total? (readonly)
Returns the value of attribute totals.
107 108 109 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 107 def totals @totals end |
#xml_version ⇒ String? (readonly)
Returns the value of attribute xml_version.
104 105 106 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 104 def xml_version @xml_version end |
Class Method Details
.from_api(payload) ⇒ Nfe::TaxCoupon?
Build a Nfe::TaxCoupon from an API payload.
rubocop:disable Metrics/AbcSize -- wide value-object mapping kept inline for Steep keyword-arg verification
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/nfe/resources/dto/consumer_invoice_query/tax_coupon.rb', line 165 def self.from_api(payload) return nil if payload.nil? new( current_status: payload["currentStatus"], number: payload["number"], sat_serie: payload["satSerie"]&.to_s, software_version: payload["softwareVersion"], software_federal_tax_number: payload["softwareFederalTaxNumber"]&.to_s, access_key: payload["accessKey"]&.to_s, cashier: payload["cashier"], issued_on: payload["issuedOn"], created_on: payload["createdOn"], xml_version: payload["xmlVersion"], issuer: Issuer.from_api(payload["issuer"]), buyer: Buyer.from_api(payload["buyer"]), totals: Total.from_api(payload["totals"]), delivery: Delivery.from_api(payload["delivery"]), additional_information: AdditionalInformation.from_api(payload["additionalInformation"]), items: (payload["items"] || []).map { |i| Item.from_api(i) }, payment: Payment.from_api(payload["payment"]) ) end |
.new ⇒ instance
114 |
# File 'sig/nfe/resources/dto/consumer_invoice_query/tax_coupon.rbs', line 114
def self.new: (current_status: untyped, number: untyped, sat_serie: untyped, software_version: String?, software_federal_tax_number: untyped, access_key: untyped, cashier: untyped, issued_on: String?, created_on: String?, xml_version: String?, issuer: Nfe::TaxCoupon::Issuer?, buyer: Nfe::TaxCoupon::Buyer?, totals: Nfe::TaxCoupon::Total?, delivery: Nfe::TaxCoupon::Delivery?, additional_information: Nfe::TaxCoupon::AdditionalInformation?, items: Array[Nfe::TaxCoupon::Item?], payment: Nfe::TaxCoupon::Payment?) -> instance
|