Class: Nfe::Resources::ConsumerInvoiceQuery
- Inherits:
-
AbstractResource
- Object
- AbstractResource
- Nfe::Resources::ConsumerInvoiceQuery
- Defined in:
- lib/nfe/resources/consumer_invoice_query.rb,
sig/nfe/resources/consumer_invoice_query.rbs
Overview
Query (consulta) of consumer invoices — NFC-e tax coupons (CFe-SAT) — by
access key, served by the :nfe_query family (+nfe.api.nfe.io+, /v1,
/coupon/ path).
This is DISTINCT from ConsumerInvoices (NFC-e emission,
add-invoice-resources): different host and API version. Here we only
retrieve and download an already-issued coupon.
Instance Attribute Summary
Attributes inherited from AbstractResource
Instance Method Summary collapse
- #api_family ⇒ Symbol
-
#api_version ⇒ String
The version segment (+v1+) is embedded in the request path, so no version prefix is added by the base class.
-
#download_xml(access_key) ⇒ String
Download the raw XML for a consumer-invoice tax coupon.
-
#retrieve(access_key) ⇒ Nfe::TaxCoupon
Retrieve a consumer-invoice tax coupon by its access key.
Methods inherited from AbstractResource
#build_list_page, #build_multipart_body, #cursor_list_page, #delete, #dig_key, #download, #extract_invoice_id, #full_path, #get, #handle_async_response, #hydrate, #hydrate_list, #initialize, #multipart_part, #page_list_page, #parse_json, #post, #put, #unwrap, #upload_multipart
Constructor Details
This class inherits a constructor from Nfe::Resources::AbstractResource
Instance Method Details
#api_family ⇒ Symbol
18 |
# File 'lib/nfe/resources/consumer_invoice_query.rb', line 18 def api_family = :nfe_query |
#api_version ⇒ String
The version segment (+v1+) is embedded in the request path, so no version prefix is added by the base class.
22 |
# File 'lib/nfe/resources/consumer_invoice_query.rb', line 22 def api_version = "" |
#download_xml(access_key) ⇒ String
Download the raw XML for a consumer-invoice tax coupon.
39 40 41 42 |
# File 'lib/nfe/resources/consumer_invoice_query.rb', line 39 def download_xml(access_key) key = Nfe::IdValidator.access_key(access_key) download("/v1/consumerinvoices/coupon/#{key}.xml", headers: { "Accept" => "application/xml" }) end |
#retrieve(access_key) ⇒ Nfe::TaxCoupon
Retrieve a consumer-invoice tax coupon by its access key.
30 31 32 33 |
# File 'lib/nfe/resources/consumer_invoice_query.rb', line 30 def retrieve(access_key) key = Nfe::IdValidator.access_key(access_key) hydrate(Nfe::TaxCoupon, parse_json(get("/v1/consumerinvoices/coupon/#{key}").body)) end |