Class: Nfe::NaturalPerson
- Inherits:
-
Data
- Object
- Data
- Nfe::NaturalPerson
- Defined in:
- lib/nfe/resources/dto/natural_person.rb,
sig/nfe/resources/dto/natural_person.rbs
Overview
Immutable value object for a natural person (pessoa fĂsica) tied to a company. NaturalPerson.from_api maps API camelCase onto snake_case, drops unknown keys, and is nil-tolerant.
federal_tax_number is kept as a String (CPF), 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.
Class Method Summary collapse
-
.from_api(payload) ⇒ Nfe::NaturalPerson?
nilwhenpayloadisnil. - .new ⇒ instance
Instance Method Summary collapse
-
#initialize ⇒ NaturalPerson
constructor
A new instance of NaturalPerson.
Constructor Details
#initialize ⇒ NaturalPerson
Returns a new instance of NaturalPerson.
15 |
# File 'sig/nfe/resources/dto/natural_person.rbs', line 15
def initialize: (id: String?, 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.
7 8 9 |
# File 'sig/nfe/resources/dto/natural_person.rbs', line 7 def address @address end |
#created_on ⇒ String? (readonly)
Returns the value of attribute created_on.
8 9 10 |
# File 'sig/nfe/resources/dto/natural_person.rbs', line 8 def created_on @created_on end |
#email ⇒ String? (readonly)
Returns the value of attribute email.
6 7 8 |
# File 'sig/nfe/resources/dto/natural_person.rbs', line 6 def email @email end |
#federal_tax_number ⇒ String? (readonly)
Returns the value of attribute federal_tax_number.
5 6 7 |
# File 'sig/nfe/resources/dto/natural_person.rbs', line 5 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/natural_person.rbs', line 3 def id @id end |
#modified_on ⇒ String? (readonly)
Returns the value of attribute modified_on.
9 10 11 |
# File 'sig/nfe/resources/dto/natural_person.rbs', line 9 def modified_on @modified_on end |
#name ⇒ String? (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'sig/nfe/resources/dto/natural_person.rbs', line 4 def name @name end |
Class Method Details
.from_api(payload) ⇒ Nfe::NaturalPerson?
Returns nil when payload is nil.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nfe/resources/dto/natural_person.rb', line 20 def self.from_api(payload) return nil if payload.nil? new( id: payload["id"], name: payload["name"], federal_tax_number: payload["federalTaxNumber"]&.to_s, email: payload["email"], address: payload["address"], created_on: payload["createdOn"], modified_on: payload["modifiedOn"] ) end |
.new ⇒ instance
13 |
# File 'sig/nfe/resources/dto/natural_person.rbs', line 13
def self.new: (id: String?, name: String?, federal_tax_number: String?, email: String?, address: untyped, created_on: String?, modified_on: String?) -> instance
|