Class: AtlasEngine::AddressValidation::Result
- Inherits:
-
Object
- Object
- AtlasEngine::AddressValidation::Result
- Extended by:
- T::Sig
- Defined in:
- app/models/atlas_engine/address_validation/result.rb
Constant Summary collapse
- SORTED_VALIDATION_SCOPES =
T.let( [:country_code, :province_code, :zip, :city, :address1, :address2, :phone].freeze, T::Array[Symbol], )
Instance Attribute Summary collapse
-
#candidate ⇒ Object
Returns the value of attribute candidate.
-
#client_request_id ⇒ Object
Returns the value of attribute client_request_id.
-
#concerns ⇒ Object
Returns the value of attribute concerns.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#matching_strategy ⇒ Object
readonly
Returns the value of attribute matching_strategy.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#suggestions ⇒ Object
Returns the value of attribute suggestions.
-
#validation_scope ⇒ Object
Returns the value of attribute validation_scope.
Instance Method Summary collapse
- #add_concern(code:, type:, type_level:, suggestion_ids:, field_names:, message:) ⇒ Object
- #add_suggestions(suggestions_to_add) ⇒ Object
- #address ⇒ Object
- #attributes ⇒ Object
- #completion_service ⇒ Object
-
#initialize(client_request_id: nil, origin: nil, fields: [], concerns: [], suggestions: [], validation_scope: [], errors: [], locale: "en", candidate: nil, matching_strategy: nil) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(client_request_id: nil, origin: nil, fields: [], concerns: [], suggestions: [], validation_scope: [], errors: [], locale: "en", candidate: nil, matching_strategy: nil) ⇒ Result
Returns a new instance of Result.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 63 def initialize( client_request_id: nil, origin: nil, fields: [], concerns: [], suggestions: [], validation_scope: [], errors: [], locale: "en", candidate: nil, matching_strategy: nil ) @origin = origin @client_request_id = client_request_id @fields = fields @concerns = concerns @suggestions = suggestions @validation_scope = validation_scope @errors = errors @locale = locale @candidate = candidate @matching_strategy = matching_strategy # For now, this UUID isn't predicated on anything and is random. # There could be need in the future to help make this unique on all requests. # For now, what is important is that it one is simply generated and assigned. @id = T.let(generate_id, String) end |
Instance Attribute Details
#candidate ⇒ Object
Returns the value of attribute candidate.
36 37 38 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 36 def candidate @candidate end |
#client_request_id ⇒ Object
Returns the value of attribute client_request_id.
15 16 17 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 15 def client_request_id @client_request_id end |
#concerns ⇒ Object
Returns the value of attribute concerns.
24 25 26 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 24 def concerns @concerns end |
#errors ⇒ Object
Returns the value of attribute errors.
39 40 41 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 39 def errors @errors end |
#fields ⇒ Object
Returns the value of attribute fields.
21 22 23 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 21 def fields @fields end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
42 43 44 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 42 def id @id end |
#locale ⇒ Object
Returns the value of attribute locale.
33 34 35 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 33 def locale @locale end |
#matching_strategy ⇒ Object (readonly)
Returns the value of attribute matching_strategy.
45 46 47 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 45 def matching_strategy @matching_strategy end |
#origin ⇒ Object
Returns the value of attribute origin.
18 19 20 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 18 def origin @origin end |
#suggestions ⇒ Object
Returns the value of attribute suggestions.
27 28 29 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 27 def suggestions @suggestions end |
#validation_scope ⇒ Object
Returns the value of attribute validation_scope.
30 31 32 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 30 def validation_scope @validation_scope end |
Instance Method Details
#add_concern(code:, type:, type_level:, suggestion_ids:, field_names:, message:) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 114 def add_concern(code:, type:, type_level:, suggestion_ids:, field_names:, message:) new_concern = Concern.new( field_names: field_names, code: code, type: type, type_level: type_level, suggestion_ids: suggestion_ids, message: , ) concerns << new_concern new_concern end |
#add_suggestions(suggestions_to_add) ⇒ Object
130 131 132 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 130 def add_suggestions(suggestions_to_add) suggestions_to_add.map { |suggestion| suggestions << suggestion } end |
#address ⇒ Object
140 141 142 143 144 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 140 def address fields.each_with_object({}) do |field, hash| hash[field.name.to_sym] = field.value.to_s end end |
#attributes ⇒ Object
93 94 95 96 97 98 99 100 101 102 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 93 def attributes { id: id, fields: fields.map(&:attributes), concerns: concerns.map(&:attributes), suggestions: suggestions.map(&:attributes), validation_scope: validation_scope, locale: locale, } end |
#completion_service ⇒ Object
135 136 137 |
# File 'app/models/atlas_engine/address_validation/result.rb', line 135 def completion_service "AddressValidation" end |