Class: Nfe::Address
- Inherits:
-
Data
- Object
- Data
- Nfe::Address
- Defined in:
- lib/nfe/resources/dto/addresses/address_lookup_response.rb,
sig/nfe/resources/dto/addresses/address_lookup_response.rbs
Overview
Immutable value object for a single address as returned by the NFE.io
address.api.nfe.io/v2 lookup API. All fields are optional; Address.from_api
maps API camelCase keys onto snake_case members and is nil-tolerant
(+from_api(nil)+ returns nil).
city is hydrated into a nested City value object
(+name+). postal_code, number, number_min and number_max
are kept as String, never coerced to Integer (preserves leading zeros).
Defined Under Namespace
Classes: City
Instance Attribute Summary collapse
-
#additional_information ⇒ String?
readonly
Returns the value of attribute additional_information.
-
#city ⇒ Nfe::Address::City?
readonly
Returns the value of attribute city.
-
#country ⇒ String?
readonly
Returns the value of attribute country.
-
#district ⇒ String?
readonly
Returns the value of attribute district.
-
#number ⇒ String?
readonly
Returns the value of attribute number.
-
#number_max ⇒ String?
readonly
Returns the value of attribute number_max.
-
#number_min ⇒ String?
readonly
Returns the value of attribute number_min.
-
#postal_code ⇒ String?
readonly
Returns the value of attribute postal_code.
-
#state ⇒ String?
readonly
Returns the value of attribute state.
-
#street ⇒ String?
readonly
Returns the value of attribute street.
-
#street_suffix ⇒ String?
readonly
Returns the value of attribute street_suffix.
Class Method Summary collapse
-
.from_api(payload) ⇒ Nfe::Address?
nilwhenpayloadisnil. - .new ⇒ instance
Instance Method Summary collapse
-
#initialize ⇒ Address
constructor
A new instance of Address.
Constructor Details
#initialize ⇒ Address
Returns a new instance of Address.
28 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 28
def initialize: (street: String?, street_suffix: String?, number: String?, number_min: String?, number_max: String?, additional_information: String?, district: String?, postal_code: String?, city: Nfe::Address::City?, state: String?, country: String?) -> void
|
Instance Attribute Details
#additional_information ⇒ String? (readonly)
Returns the value of attribute additional_information.
17 18 19 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 17 def additional_information @additional_information end |
#city ⇒ Nfe::Address::City? (readonly)
Returns the value of attribute city.
20 21 22 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 20 def city @city end |
#country ⇒ String? (readonly)
Returns the value of attribute country.
22 23 24 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 22 def country @country end |
#district ⇒ String? (readonly)
Returns the value of attribute district.
18 19 20 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 18 def district @district end |
#number ⇒ String? (readonly)
Returns the value of attribute number.
14 15 16 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 14 def number @number end |
#number_max ⇒ String? (readonly)
Returns the value of attribute number_max.
16 17 18 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 16 def number_max @number_max end |
#number_min ⇒ String? (readonly)
Returns the value of attribute number_min.
15 16 17 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 15 def number_min @number_min end |
#postal_code ⇒ String? (readonly)
Returns the value of attribute postal_code.
19 20 21 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 19 def postal_code @postal_code end |
#state ⇒ String? (readonly)
Returns the value of attribute state.
21 22 23 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 21 def state @state end |
#street ⇒ String? (readonly)
Returns the value of attribute street.
12 13 14 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 12 def street @street end |
#street_suffix ⇒ String? (readonly)
Returns the value of attribute street_suffix.
13 14 15 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 13 def street_suffix @street_suffix end |
Class Method Details
.from_api(payload) ⇒ Nfe::Address?
Returns nil when payload is nil.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nfe/resources/dto/addresses/address_lookup_response.rb', line 42 def self.from_api(payload) return nil if payload.nil? new( street: payload["street"], street_suffix: payload["streetSuffix"], number: payload["number"]&.to_s, number_min: payload["numberMin"]&.to_s, number_max: payload["numberMax"]&.to_s, additional_information: payload["additionalInformation"], district: payload["district"], postal_code: payload["postalCode"]&.to_s, city: Nfe::Address::City.from_api(payload["city"]), state: payload["state"], country: payload["country"] ) end |
.new ⇒ instance
26 |
# File 'sig/nfe/resources/dto/addresses/address_lookup_response.rbs', line 26
def self.new: (street: String?, street_suffix: String?, number: String?, number_min: String?, number_max: String?, additional_information: String?, district: String?, postal_code: String?, city: Nfe::Address::City?, state: String?, country: String?) -> instance
|