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.
- #province_code ⇒ Object
-
#zip ⇒ Object
Returns the value of attribute zip.
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(address1: nil, address2: 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, address2: nil, city: nil, zip: nil, province_code: nil, country_code: nil) ⇒ Suggestion
Returns a new instance of Suggestion.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 40 def initialize(address1: nil, address2: nil, city: nil, zip: nil, province_code: nil, country_code: nil) @address1 = address1 @address2 = address2 @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.
16 17 18 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 16 def address2 @address2 end |
#city ⇒ Object
Returns the value of attribute city.
19 20 21 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 19 def city @city end |
#country_code ⇒ Object
Returns the value of attribute country_code.
28 29 30 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 28 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 |
#province_code ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 76 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 |
#zip ⇒ Object
Returns the value of attribute zip.
22 23 24 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 22 def zip @zip end |
Instance Method Details
#attributes ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 54 def attributes { id: id, address1: address1, address2: address2, city: city, zip: zip, province_code: province_code, province: province, country_code: country_code, } end |
#province ⇒ Object
68 69 70 71 72 73 |
# File 'app/models/atlas_engine/address_validation/suggestion.rb', line 68 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 |