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: "", address2: "", city: "", province_code: "", country_code: "", zip: "", phone: "", result: Result.new) ⇒ ConcernRecord

Returns a new instance of ConcernRecord.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 85

def initialize(
  request_id: nil,
  timestamp: Time.zone.now,
  origin: "",
  address1: "",
  address2: "",
  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
  @address2 = address2
  @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.



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

def address2
  @address2
end

#cityObject (readonly)

Returns the value of attribute city.



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

def city
  @city
end

#client_request_idObject (readonly)

Returns the value of attribute client_request_id.



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

def client_request_id
  @client_request_id
end

#country_codeObject (readonly)

Returns the value of attribute country_code.



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

def country_code
  @country_code
end

#originObject (readonly)

Returns the value of attribute origin.



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

def origin
  @origin
end

#phoneObject (readonly)

Returns the value of attribute phone.



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

def phone
  @phone
end

#province_codeObject (readonly)

Returns the value of attribute province_code.



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

def province_code
  @province_code
end

#request_idObject (readonly)

Returns the value of attribute request_id.



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

def request_id
  @request_id
end

#resultObject (readonly)

Returns the value of attribute result.



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

def result
  @result
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



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

def timestamp
  @timestamp
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

#zipObject (readonly)

Returns the value of attribute zip.



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

def zip
  @zip
end

Class Method Details

.duplicate(obj) ⇒ Object



65
66
67
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 65

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

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



52
53
54
55
56
57
58
59
60
61
62
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 52

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

Instance Method Details

#address_attributesObject



114
115
116
117
118
119
120
121
122
123
124
# File 'app/models/atlas_engine/address_validation/concern_record.rb', line 114

def address_attributes
  {
    address1: address1,
    address2: address2,
    city: city,
    province_code: province_code,
    zip: zip,
    country_code: country_code,
    phone: phone,
  }
end