Class: AtlasEngine::AddressValidation::Suggestion
- Inherits:
-
Object
- Object
- AtlasEngine::AddressValidation::Suggestion
- Extended by:
- T::Sig
- Defined in:
- app/models/atlas_engine/address_validation/suggestion.rb
Instance Attribute Summary collapse
-
#address1 ⇒ Object
Returns the value of attribute address1.
-
#address2 ⇒ Object
Returns the value of attribute address2.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#line2 ⇒ Object
Returns the value of attribute line2.
-
#neighborhood ⇒ Object
Returns the value of attribute neighborhood.
- #province_code ⇒ Object
-
#street_name ⇒ Object
Returns the value of attribute street_name.
-
#street_number ⇒ Object
Returns the value of attribute street_number.
-
#zip ⇒ Object
Returns the value of attribute zip.
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(address1: nil, street_name: nil, street_number: nil, address2: nil, line2: nil, neighborhood: nil, city: nil, zip: nil, province_code: nil, country_code: nil) ⇒ Suggestion
constructor
A new instance of Suggestion.
- #province ⇒ Object
Constructor Details
#initialize(address1: nil, street_name: nil, street_number: nil, address2: nil, line2: nil, neighborhood: nil, city: nil, zip: nil, province_code: nil, country_code: nil) ⇒ Suggestion
Returns a new instance of Suggestion.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 56 def initialize(address1: nil, street_name: nil, street_number: nil, address2: nil, line2: nil, neighborhood: nil, city: nil, zip: nil, province_code: nil, country_code: nil) @address1 = address1 @street_name = street_name @street_number = street_number @address2 = address2 @line2 = line2 @neighborhood = neighborhood @city = city @zip = zip @province_code = province_code @original_country_code = country_code @country_code = country_code # generate_id uses the values of the attributes to calculate the UUID, so must be called after they're set @id = T.let(generate_id, String) end |
Instance Attribute Details
#address1 ⇒ Object
Returns the value of attribute address1.
13 14 15 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 13 def address1 @address1 end |
#address2 ⇒ Object
Returns the value of attribute address2.
22 23 24 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 22 def address2 @address2 end |
#city ⇒ Object
Returns the value of attribute city.
31 32 33 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 31 def city @city end |
#country_code ⇒ Object
Returns the value of attribute country_code.
40 41 42 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 40 def country_code @country_code end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 10 def id @id end |
#line2 ⇒ Object
Returns the value of attribute line2.
25 26 27 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 25 def line2 @line2 end |
#neighborhood ⇒ Object
Returns the value of attribute neighborhood.
28 29 30 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 28 def neighborhood @neighborhood end |
#province_code ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 101 def province_code return @province_code if @province_code.blank? # This hack is required since checkout-web is using province codes differently for Japan Vs Other countries # Japan province codes are expected as full ISO codes (JP-14) # while other countries are expected as 2 digit subdivision codes (e.g. ON) # we can remove this logic if the client can accept 2 digit subdivision codes / ISO codes as standard response province = Worldwide.region(code: @original_country_code)&.zone(code: @province_code) return @province_code unless province.province? province.legacy_code end |
#street_name ⇒ Object
Returns the value of attribute street_name.
16 17 18 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 16 def street_name @street_name end |
#street_number ⇒ Object
Returns the value of attribute street_number.
19 20 21 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 19 def street_number @street_number end |
#zip ⇒ Object
Returns the value of attribute zip.
34 35 36 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 34 def zip @zip end |
Instance Method Details
#attributes ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 75 def attributes { id: id, address1: address1, street_name: street_name, street_number: street_number, address2: address2, line2: line2, neighborhood: neighborhood, city: city, zip: zip, province_code: province_code, province: province, country_code: country_code, } end |
#province ⇒ Object
93 94 95 96 97 98 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 93 def province return if @original_country_code.nil? || @province_code.nil? province = Worldwide.region(code: @original_country_code)&.zone(code: @province_code) province.province? ? province.full_name : nil end |