Class: Nfe::LegalPerson
- Inherits:
-
Data
- Object
- Data
- Nfe::LegalPerson
- Defined in:
- lib/nfe/resources/dto/legal_person.rb,
sig/nfe/resources/dto/legal_person.rbs
Overview
Immutable value object for a legal person (pessoa jurÃdica) tied to a company. LegalPerson.from_api maps API camelCase onto snake_case, drops unknown keys, and is nil-tolerant.
federal_tax_number is kept as a String (CNPJ), never coerced to Integer.
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#created_on ⇒ String?
readonly
Returns the value of attribute created_on.
-
#email ⇒ String?
readonly
Returns the value of attribute email.
-
#federal_tax_number ⇒ String?
readonly
Returns the value of attribute federal_tax_number.
-
#id ⇒ String?
readonly
Returns the value of attribute id.
-
#modified_on ⇒ String?
readonly
Returns the value of attribute modified_on.
-
#name ⇒ String?
readonly
Returns the value of attribute name.
-
#trade_name ⇒ String?
readonly
Returns the value of attribute trade_name.
Class Method Summary collapse
-
.from_api(payload) ⇒ Nfe::LegalPerson?
nilwhenpayloadisnil. - .new ⇒ instance
Instance Method Summary collapse
-
#initialize ⇒ LegalPerson
constructor
A new instance of LegalPerson.
Constructor Details
#initialize ⇒ LegalPerson
Returns a new instance of LegalPerson.
16 |
# File 'sig/nfe/resources/dto/legal_person.rbs', line 16
def initialize: (id: String?, name: String?, trade_name: String?, federal_tax_number: String?, email: String?, address: untyped, created_on: String?, modified_on: String?) -> void
|
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
8 9 10 |
# File 'sig/nfe/resources/dto/legal_person.rbs', line 8 def address @address end |
#created_on ⇒ String? (readonly)
Returns the value of attribute created_on.
9 10 11 |
# File 'sig/nfe/resources/dto/legal_person.rbs', line 9 def created_on @created_on end |
#email ⇒ String? (readonly)
Returns the value of attribute email.
7 8 9 |
# File 'sig/nfe/resources/dto/legal_person.rbs', line 7 def email @email end |
#federal_tax_number ⇒ String? (readonly)
Returns the value of attribute federal_tax_number.
6 7 8 |
# File 'sig/nfe/resources/dto/legal_person.rbs', line 6 def federal_tax_number @federal_tax_number end |
#id ⇒ String? (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'sig/nfe/resources/dto/legal_person.rbs', line 3 def id @id end |
#modified_on ⇒ String? (readonly)
Returns the value of attribute modified_on.
10 11 12 |
# File 'sig/nfe/resources/dto/legal_person.rbs', line 10 def modified_on @modified_on end |
#name ⇒ String? (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'sig/nfe/resources/dto/legal_person.rbs', line 4 def name @name end |
#trade_name ⇒ String? (readonly)
Returns the value of attribute trade_name.
5 6 7 |
# File 'sig/nfe/resources/dto/legal_person.rbs', line 5 def trade_name @trade_name end |
Class Method Details
.from_api(payload) ⇒ Nfe::LegalPerson?
Returns nil when payload is nil.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nfe/resources/dto/legal_person.rb', line 21 def self.from_api(payload) return nil if payload.nil? new( id: payload["id"], name: payload["name"], trade_name: payload["tradeName"], federal_tax_number: payload["federalTaxNumber"]&.to_s, email: payload["email"], address: payload["address"], created_on: payload["createdOn"], modified_on: payload["modifiedOn"] ) end |
.new ⇒ instance
14 |
# File 'sig/nfe/resources/dto/legal_person.rbs', line 14
def self.new: (id: String?, name: String?, trade_name: String?, federal_tax_number: String?, email: String?, address: untyped, created_on: String?, modified_on: String?) -> instance
|