Class: Nfe::LegalEntity

Inherits:
Data
  • Object
show all
Defined in:
lib/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rb,
sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs

Overview

Immutable value object for a legal entity (pessoa jurídica) as returned by the NFE.io legalentity.api.nfe.io basicInfo lookup. All fields are optional; LegalEntity.from_api maps API camelCase keys onto snake_case members and is nil-tolerant (+from_api(nil)+ returns nil).

federal_tax_number is kept as a String (CNPJ), never coerced to Integer, preserving future alphanumeric CNPJ. address, phones, partners and economic_activities are passed through opaquely.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLegalEntity

Returns a new instance of LegalEntity.

Parameters:

  • federal_tax_number: (String, nil)
  • name: (String, nil)
  • trade_name: (String, nil)
  • status: (Object)
  • status_on: (String, nil)
  • status_reason: (String, nil)
  • legal_nature: (Object)
  • size: (Object)
  • opened_on: (String, nil)
  • issued_on: (String, nil)
  • special_status: (String, nil)
  • special_status_on: (String, nil)
  • responsable_entity: (String, nil)
  • share_capital: (Object)
  • registration_unit: (String, nil)
  • unit: (Object)
  • address: (Object)
  • phones: (Object)
  • email: (String, nil)
  • economic_activities: (Object)
  • partners: (Object)


29
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 29

def initialize: (federal_tax_number: String?, name: String?, trade_name: String?, status: untyped, status_on: String?, status_reason: String?, legal_nature: untyped, size: untyped, opened_on: String?, issued_on: String?, special_status: String?, special_status_on: String?, responsable_entity: String?, share_capital: untyped, registration_unit: String?, unit: untyped, address: untyped, phones: untyped, email: String?, economic_activities: untyped, partners: untyped) -> void

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.

Returns:

  • (Object)


19
20
21
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 19

def address
  @address
end

#economic_activitiesObject (readonly)

Returns the value of attribute economic_activities.

Returns:

  • (Object)


22
23
24
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 22

def economic_activities
  @economic_activities
end

#emailString? (readonly)

Returns the value of attribute email.

Returns:

  • (String, nil)


21
22
23
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 21

def email
  @email
end

#federal_tax_numberString? (readonly)

Returns the value of attribute federal_tax_number.

Returns:

  • (String, nil)


3
4
5
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 3

def federal_tax_number
  @federal_tax_number
end

#issued_onString? (readonly)

Returns the value of attribute issued_on.

Returns:

  • (String, nil)


12
13
14
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 12

def issued_on
  @issued_on
end

Returns the value of attribute legal_nature.

Returns:

  • (Object)


9
10
11
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 9

def legal_nature
  @legal_nature
end

#nameString? (readonly)

Returns the value of attribute name.

Returns:

  • (String, nil)


4
5
6
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 4

def name
  @name
end

#opened_onString? (readonly)

Returns the value of attribute opened_on.

Returns:

  • (String, nil)


11
12
13
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 11

def opened_on
  @opened_on
end

#partnersObject (readonly)

Returns the value of attribute partners.

Returns:

  • (Object)


23
24
25
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 23

def partners
  @partners
end

#phonesObject (readonly)

Returns the value of attribute phones.

Returns:

  • (Object)


20
21
22
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 20

def phones
  @phones
end

#registration_unitString? (readonly)

Returns the value of attribute registration_unit.

Returns:

  • (String, nil)


17
18
19
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 17

def registration_unit
  @registration_unit
end

#responsable_entityString? (readonly)

Returns the value of attribute responsable_entity.

Returns:

  • (String, nil)


15
16
17
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 15

def responsable_entity
  @responsable_entity
end

#share_capitalObject (readonly)

Returns the value of attribute share_capital.

Returns:

  • (Object)


16
17
18
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 16

def share_capital
  @share_capital
end

#sizeObject (readonly)

Returns the value of attribute size.

Returns:

  • (Object)


10
11
12
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 10

def size
  @size
end

#special_statusString? (readonly)

Returns the value of attribute special_status.

Returns:

  • (String, nil)


13
14
15
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 13

def special_status
  @special_status
end

#special_status_onString? (readonly)

Returns the value of attribute special_status_on.

Returns:

  • (String, nil)


14
15
16
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 14

def special_status_on
  @special_status_on
end

#statusObject (readonly)

Returns the value of attribute status.

Returns:

  • (Object)


6
7
8
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 6

def status
  @status
end

#status_onString? (readonly)

Returns the value of attribute status_on.

Returns:

  • (String, nil)


7
8
9
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 7

def status_on
  @status_on
end

#status_reasonString? (readonly)

Returns the value of attribute status_reason.

Returns:

  • (String, nil)


8
9
10
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 8

def status_reason
  @status_reason
end

#trade_nameString? (readonly)

Returns the value of attribute trade_name.

Returns:

  • (String, nil)


5
6
7
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 5

def trade_name
  @trade_name
end

#unitObject (readonly)

Returns the value of attribute unit.

Returns:

  • (Object)


18
19
20
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 18

def unit
  @unit
end

Class Method Details

.from_api(payload) ⇒ Nfe::LegalEntity?

Returns nil when payload is nil.

Parameters:

  • payload (Hash, nil)

    the unwrapped legal-entity object.

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rb', line 39

def self.from_api(payload)
  return nil if payload.nil?

  new(
    federal_tax_number: payload["federalTaxNumber"]&.to_s,
    name: payload["name"],
    trade_name: payload["tradeName"],
    status: payload["status"],
    status_on: payload["statusOn"],
    status_reason: payload["statusReason"],
    legal_nature: payload["legalNature"],
    size: payload["size"],
    opened_on: payload["openedOn"],
    issued_on: payload["issuedOn"],
    special_status: payload["specialStatus"],
    special_status_on: payload["specialStatusOn"],
    responsable_entity: payload["responsableEntity"],
    share_capital: payload["shareCapital"],
    registration_unit: payload["registrationUnit"],
    unit: payload["unit"],
    address: payload["address"],
    phones: payload["phones"],
    email: payload["email"],
    economic_activities: payload["economicActivities"],
    partners: payload["partners"]
  )
end

.newinstance

Parameters:

  • federal_tax_number: (String, nil)
  • name: (String, nil)
  • trade_name: (String, nil)
  • status: (Object)
  • status_on: (String, nil)
  • status_reason: (String, nil)
  • legal_nature: (Object)
  • size: (Object)
  • opened_on: (String, nil)
  • issued_on: (String, nil)
  • special_status: (String, nil)
  • special_status_on: (String, nil)
  • responsable_entity: (String, nil)
  • share_capital: (Object)
  • registration_unit: (String, nil)
  • unit: (Object)
  • address: (Object)
  • phones: (Object)
  • email: (String, nil)
  • economic_activities: (Object)
  • partners: (Object)

Returns:

  • (instance)


27
# File 'sig/nfe/resources/dto/legal_entity_lookup/legal_entity_responses.rbs', line 27

def self.new: (federal_tax_number: String?, name: String?, trade_name: String?, status: untyped, status_on: String?, status_reason: String?, legal_nature: untyped, size: untyped, opened_on: String?, issued_on: String?, special_status: String?, special_status_on: String?, responsable_entity: String?, share_capital: untyped, registration_unit: String?, unit: untyped, address: untyped, phones: untyped, email: String?, economic_activities: untyped, partners: untyped) -> instance