Class: Nfe::Resources::NaturalPersonLookup

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

Overview

Read-only lookups against the naturalperson data API (+https://naturalperson.api.nfe.io+). The version segment is embedded in the request path, so api_version is "".

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)


28
# File 'lib/nfe/resources/natural_person_lookup.rb', line 28

def api_family = :natural_person

#api_versionString

This family's host embeds the version in the path, so no version segment is prefixed to the request path.

Returns:

  • (String)


32
# File 'lib/nfe/resources/natural_person_lookup.rb', line 32

def api_version = ""

#get_status(federal_tax_number, birth_date) ⇒ Nfe::NaturalPersonStatusResponse?

Fetch the registration status of a natural person (CPF) at the federal tax authority. The CPF is normalized to 11 digits and the birth date to YYYY-MM-DD before the request is issued (fail-fast).

Parameters:

  • federal_tax_number (String)

    the CPF (with or without separators).

  • birth_date (String, Date, Time, DateTime)

    the person's birth date.

Returns:



19
20
21
22
23
24
# File 'lib/nfe/resources/natural_person_lookup.rb', line 19

def get_status(federal_tax_number, birth_date)
  cpf = Nfe::IdValidator.cpf(federal_tax_number)
  date = Nfe::DateNormalizer.to_iso_date(birth_date)
  response = get("/v1/naturalperson/status/#{cpf}/#{date}")
  hydrate(Nfe::NaturalPersonStatusResponse, parse_json(response.body))
end