Class: AtlasEngine::AddressValidation::ConcernRecord

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
app/models/atlas_engine/address_validation/concern_record.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_id: nil, timestamp: Time.zone.now, origin: "", address1: "", street_name: "", street_number: "", address2: "", line2: "", neighborhood: "", city: "", province_code: "", country_code: "", zip: "", phone: "", result: Result.new) ⇒ ConcernRecord

Returns a new instance of ConcernRecord.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 101

def initialize(
  request_id: nil,
  timestamp: Time.zone.now,
  origin: "",
  address1: "",
  street_name: "",
  street_number: "",
  address2: "",
  line2: "",
  neighborhood: "",
  city: "",
  province_code: "",
  country_code: "",
  zip: "",
  phone: "",
  result: Result.new
)
  @request_id = request_id
  @client_request_id = T.let(result.client_request_id, T.nilable(String))
  @timestamp = timestamp
  @origin = origin
  @address1 = address1
  @street_name = street_name
  @street_number = street_number
  @address2 = address2
  @line2 = line2
  @neighborhood = neighborhood
  @city = city
  @province_code = province_code
  @country_code = country_code
  @zip = zip
  @phone = phone
  @result = result
  @version = T.let(Rails.configuration.version, T.nilable(String))
end

Instance Attribute Details

#address1Object (readonly)

Returns the value of attribute address1.



10
11
12
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 10

def address1
  @address1
end

#address2Object (readonly)

Returns the value of attribute address2.



19
20
21
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 19

def address2
  @address2
end

#cityObject (readonly)

Returns the value of attribute city.



28
29
30
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 28

def city
  @city
end

#client_request_idObject (readonly)

Returns the value of attribute client_request_id.



52
53
54
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 52

def client_request_id
  @client_request_id
end

#country_codeObject (readonly)

Returns the value of attribute country_code.



31
32
33
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 31

def country_code
  @country_code
end

#line2Object (readonly)

Returns the value of attribute line2.



22
23
24
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 22

def line2
  @line2
end

#neighborhoodObject (readonly)

Returns the value of attribute neighborhood.



25
26
27
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 25

def neighborhood
  @neighborhood
end

#originObject (readonly)

Returns the value of attribute origin.



58
59
60
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 58

def origin
  @origin
end

#phoneObject (readonly)

Returns the value of attribute phone.



40
41
42
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 40

def phone
  @phone
end

#province_codeObject (readonly)

Returns the value of attribute province_code.



34
35
36
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 34

def province_code
  @province_code
end

#request_idObject (readonly)

Returns the value of attribute request_id.



49
50
51
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 49

def request_id
  @request_id
end

#resultObject (readonly)

Returns the value of attribute result.



43
44
45
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 43

def result
  @result
end

#street_nameObject (readonly)

Returns the value of attribute street_name.



13
14
15
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 13

def street_name
  @street_name
end

#street_numberObject (readonly)

Returns the value of attribute street_number.



16
17
18
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 16

def street_number
  @street_number
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



55
56
57
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 55

def timestamp
  @timestamp
end

#versionObject (readonly)

Returns the value of attribute version.



46
47
48
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 46

def version
  @version
end

#zipObject (readonly)

Returns the value of attribute zip.



37
38
39
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 37

def zip
  @zip
end

Class Method Details

.duplicate(obj) ⇒ Object



77
78
79
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 77

def duplicate(obj)
  Marshal.load(Marshal.dump(obj))
end

.from_result(result, context = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 64

def from_result(result, context = {})
  new(
    **T.unsafe(
      {
        result: duplicate(result),
        **result.address,
        **context.except(:client_request_id),
      },
    ),
  )
end

Instance Method Details

#address_attributesObject



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 138

def address_attributes
  {
    address1: address1,
    street_name: street_name,
    street_number: street_number,
    address2: address2,
    line2: line2,
    neighborhood: neighborhood,
    city: city,
    province_code: province_code,
    zip: zip,
    country_code: country_code,
    phone: phone,
  }
end