Class: Nfe::Resources::TaxCodes

Inherits:
AbstractResource show all
Defined in:
lib/nfe/resources/tax_codes.rb,
sig/nfe/resources/tax_codes.rbs

Overview

CT-e tax-code lookup tables for the :cte host family (+https://api.nfse.io/tax-codes/...+). Exposes the four reference lists consumed when building a CT-e: operation codes, acquisition purposes, and the issuer/recipient tax profiles.

These endpoints paginate page-style (1-based +pageIndex+/+pageCount+), so every method returns an TaxCodePaginatedResponse (NOT an ListResponse); see that class for why this differs from the cursor-style lists elsewhere in the SDK.

Examples:

client.tax_codes.list_operation_codes(page_index: 2, page_count: 20)

Instance Attribute Summary

Attributes inherited from AbstractResource

#client

Instance Method Summary collapse

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_familySymbol

Returns:

  • (Symbol)


23
24
25
# File 'lib/nfe/resources/tax_codes.rb', line 23

def api_family
  :cte
end

#api_versionString

The :cte host (+api.nfse.io+) does not bake in a version and these tax-code paths carry none, so no version segment is prefixed.

Returns:

  • (String)


29
30
31
# File 'lib/nfe/resources/tax_codes.rb', line 29

def api_version
  ""
end

#list_acquisition_purposes(page_index: nil, page_count: nil) ⇒ Nfe::TaxCodePaginatedResponse

List CT-e acquisition purposes (Finalidade de Aquisição).

Parameters:

  • page_index (Integer, nil) (defaults to: nil)

    1-based page index (preserved as given).

  • page_count (Integer, nil) (defaults to: nil)

    page size.

  • page_index: (Integer, nil) (defaults to: nil)
  • page_count: (Integer, nil) (defaults to: nil)

Returns:



49
50
51
# File 'lib/nfe/resources/tax_codes.rb', line 49

def list_acquisition_purposes(page_index: nil, page_count: nil)
  list_tax_codes("/tax-codes/acquisition-purpose", page_index, page_count)
end

#list_issuer_tax_profiles(page_index: nil, page_count: nil) ⇒ Nfe::TaxCodePaginatedResponse

List CT-e issuer tax profiles (Perfil Tributário do Emitente).

Parameters:

  • page_index (Integer, nil) (defaults to: nil)

    1-based page index (preserved as given).

  • page_count (Integer, nil) (defaults to: nil)

    page size.

  • page_index: (Integer, nil) (defaults to: nil)
  • page_count: (Integer, nil) (defaults to: nil)

Returns:



58
59
60
# File 'lib/nfe/resources/tax_codes.rb', line 58

def list_issuer_tax_profiles(page_index: nil, page_count: nil)
  list_tax_codes("/tax-codes/issuer-tax-profile", page_index, page_count)
end

#list_operation_codes(page_index: nil, page_count: nil) ⇒ Nfe::TaxCodePaginatedResponse

List CT-e operation codes (Código de Operação).

Parameters:

  • page_index (Integer, nil) (defaults to: nil)

    1-based page index (preserved as given).

  • page_count (Integer, nil) (defaults to: nil)

    page size.

  • page_index: (Integer, nil) (defaults to: nil)
  • page_count: (Integer, nil) (defaults to: nil)

Returns:



40
41
42
# File 'lib/nfe/resources/tax_codes.rb', line 40

def list_operation_codes(page_index: nil, page_count: nil)
  list_tax_codes("/tax-codes/operation-code", page_index, page_count)
end

#list_recipient_tax_profiles(page_index: nil, page_count: nil) ⇒ Nfe::TaxCodePaginatedResponse

List CT-e recipient tax profiles (Perfil Tributário do Destinatário).

Parameters:

  • page_index (Integer, nil) (defaults to: nil)

    1-based page index (preserved as given).

  • page_count (Integer, nil) (defaults to: nil)

    page size.

  • page_index: (Integer, nil) (defaults to: nil)
  • page_count: (Integer, nil) (defaults to: nil)

Returns:



67
68
69
# File 'lib/nfe/resources/tax_codes.rb', line 67

def list_recipient_tax_profiles(page_index: nil, page_count: nil)
  list_tax_codes("/tax-codes/recipient-tax-profile", page_index, page_count)
end

#list_tax_codes(path, page_index, page_count) ⇒ Nfe::TaxCodePaginatedResponse?

Shared GET + page-style query builder for the four tax-code endpoints. Only the non-nil paging parameters are sent, keeping them out of the URL when omitted.

Parameters:

  • path (String)
  • page_index (Integer, nil)
  • page_count (Integer, nil)

Returns:



76
77
78
79
80
81
82
# File 'lib/nfe/resources/tax_codes.rb', line 76

def list_tax_codes(path, page_index, page_count)
  query = {} #: Hash[String, untyped]
  query["pageIndex"] = page_index unless page_index.nil?
  query["pageCount"] = page_count unless page_count.nil?
  response = get(path, query: query)
  hydrate(Nfe::TaxCodePaginatedResponse, parse_json(response.body))
end