Class: Nfe::Resources::LegalEntityLookup
- Inherits:
-
AbstractResource
- Object
- AbstractResource
- Nfe::Resources::LegalEntityLookup
- Defined in:
- lib/nfe/resources/legal_entity_lookup.rb,
sig/nfe/resources/legal_entity_lookup.rbs
Overview
Legal-entity (pessoa jurÃdica) lookup against the :legal_entity data
family (+legalentity.api.nfe.io+). The version segment is embedded in
each request path (+/v2/legalentities/...+), so #api_version is "".
Instance Attribute Summary
Attributes inherited from AbstractResource
Instance Method Summary collapse
- #api_family ⇒ Symbol
-
#api_version ⇒ String
The version segment is embedded in each request path, so no version prefix is added by AbstractResource#full_path.
-
#get_basic_info(federal_tax_number, update_address: nil, update_city_code: nil) ⇒ Nfe::LegalEntityBasicInfoResponse
Retrieve basic registration info for a CNPJ.
-
#get_state_tax_for_invoice(state, federal_tax_number) ⇒ Nfe::LegalEntityStateTaxForInvoiceResponse
Retrieve the state-tax info suitable for invoicing.
-
#get_state_tax_info(state, federal_tax_number) ⇒ Nfe::LegalEntityStateTaxResponse
Retrieve state-tax registration info for a state + CNPJ.
-
#get_suggested_state_tax_for_invoice(state, federal_tax_number) ⇒ Nfe::LegalEntityStateTaxForInvoiceResponse
Retrieve the suggested state-tax info for invoicing.
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
67 68 69 |
# File 'lib/nfe/resources/legal_entity_lookup.rb', line 67 def api_family :legal_entity end |
#api_version ⇒ String
The version segment is embedded in each request path, so no version prefix is added by AbstractResource#full_path.
73 74 75 |
# File 'lib/nfe/resources/legal_entity_lookup.rb', line 73 def api_version "" end |
#get_basic_info(federal_tax_number, update_address: nil, update_city_code: nil) ⇒ Nfe::LegalEntityBasicInfoResponse
Retrieve basic registration info for a CNPJ.
19 20 21 22 23 24 |
# File 'lib/nfe/resources/legal_entity_lookup.rb', line 19 def get_basic_info(federal_tax_number, update_address: nil, update_city_code: nil) cnpj = Nfe::IdValidator.cnpj(federal_tax_number) query = { "updateAddress" => update_address, "updateCityCode" => update_city_code }.compact response = get("/v2/legalentities/basicInfo/#{cnpj}", query: query) hydrate(Nfe::LegalEntityBasicInfoResponse, parse_json(response.body)) end |
#get_state_tax_for_invoice(state, federal_tax_number) ⇒ Nfe::LegalEntityStateTaxForInvoiceResponse
Retrieve the state-tax info suitable for invoicing.
45 46 47 48 49 50 |
# File 'lib/nfe/resources/legal_entity_lookup.rb', line 45 def get_state_tax_for_invoice(state, federal_tax_number) uf = Nfe::IdValidator.state(state) cnpj = Nfe::IdValidator.cnpj(federal_tax_number) response = get("/v2/legalentities/stateTaxForInvoice/#{uf}/#{cnpj}") hydrate(Nfe::LegalEntityStateTaxForInvoiceResponse, parse_json(response.body)) end |
#get_state_tax_info(state, federal_tax_number) ⇒ Nfe::LegalEntityStateTaxResponse
Retrieve state-tax registration info for a state + CNPJ.
32 33 34 35 36 37 |
# File 'lib/nfe/resources/legal_entity_lookup.rb', line 32 def get_state_tax_info(state, federal_tax_number) uf = Nfe::IdValidator.state(state) cnpj = Nfe::IdValidator.cnpj(federal_tax_number) response = get("/v2/legalentities/stateTaxInfo/#{uf}/#{cnpj}") hydrate(Nfe::LegalEntityStateTaxResponse, parse_json(response.body)) end |
#get_suggested_state_tax_for_invoice(state, federal_tax_number) ⇒ Nfe::LegalEntityStateTaxForInvoiceResponse
Retrieve the suggested state-tax info for invoicing.
58 59 60 61 62 63 |
# File 'lib/nfe/resources/legal_entity_lookup.rb', line 58 def get_suggested_state_tax_for_invoice(state, federal_tax_number) uf = Nfe::IdValidator.state(state) cnpj = Nfe::IdValidator.cnpj(federal_tax_number) response = get("/v2/legalentities/stateTaxSuggestedForInvoice/#{uf}/#{cnpj}") hydrate(Nfe::LegalEntityStateTaxForInvoiceResponse, parse_json(response.body)) end |