Class: UspsApi::ChangeOfAddress

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/change_of_address.rb

Overview

Information pertaining to the Change of address

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(beyond_months:, return_code:, error_code: SKIP, error_description: SKIP, move_effective_date: SKIP, move_type: SKIP, orig_full_name: SKIP, matched_business_name: SKIP, matched_first_name: SKIP, matched_last_name: SKIP, matched_suffix_name: SKIP, middle_name_two_chars: SKIP, additional_properties: nil) ⇒ ChangeOfAddress

Returns a new instance of ChangeOfAddress.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/usps_api/models/change_of_address.rb', line 100

def initialize(beyond_months:, return_code:, error_code: SKIP,
               error_description: SKIP, move_effective_date: SKIP,
               move_type: SKIP, orig_full_name: SKIP,
               matched_business_name: SKIP, matched_first_name: SKIP,
               matched_last_name: SKIP, matched_suffix_name: SKIP,
               middle_name_two_chars: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @error_code = error_code unless error_code == SKIP
  @error_description = error_description unless error_description == SKIP
  @beyond_months = beyond_months
  @return_code = return_code
  @move_effective_date = move_effective_date unless move_effective_date == SKIP
  @move_type = move_type unless move_type == SKIP
  @orig_full_name = orig_full_name unless orig_full_name == SKIP
  @matched_business_name = matched_business_name unless matched_business_name == SKIP
  @matched_first_name = matched_first_name unless matched_first_name == SKIP
  @matched_last_name = matched_last_name unless matched_last_name == SKIP
  @matched_suffix_name = matched_suffix_name unless matched_suffix_name == SKIP
  @middle_name_two_chars = middle_name_two_chars unless middle_name_two_chars == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#beyond_monthsString

Change of address is beyond requested number of months. New address will not be returned.

Returns:

  • (String)


23
24
25
# File 'lib/usps_api/models/change_of_address.rb', line 23

def beyond_months
  @beyond_months
end

#error_codeString

Processing Error Code

Returns:

  • (String)


14
15
16
# File 'lib/usps_api/models/change_of_address.rb', line 14

def error_code
  @error_code
end

#error_descriptionString

Processing Error Description

Returns:

  • (String)


18
19
20
# File 'lib/usps_api/models/change_of_address.rb', line 18

def error_description
  @error_description
end

#matched_business_nameString

Returned result of the matched Business Name.

Returns:

  • (String)


43
44
45
# File 'lib/usps_api/models/change_of_address.rb', line 43

def matched_business_name
  @matched_business_name
end

#matched_first_nameString

Returned result of the matched First Name.

Returns:

  • (String)


47
48
49
# File 'lib/usps_api/models/change_of_address.rb', line 47

def matched_first_name
  @matched_first_name
end

#matched_last_nameString

Returned result of the matched Last Name.

Returns:

  • (String)


51
52
53
# File 'lib/usps_api/models/change_of_address.rb', line 51

def matched_last_name
  @matched_last_name
end

#matched_suffix_nameString

Returned result of the matched Suffix Name.

Returns:

  • (String)


55
56
57
# File 'lib/usps_api/models/change_of_address.rb', line 55

def matched_suffix_name
  @matched_suffix_name
end

#middle_name_two_charsString

Returned result of the matched Middle Name,

Returns:

  • (String)


59
60
61
# File 'lib/usps_api/models/change_of_address.rb', line 59

def middle_name_two_chars
  @middle_name_two_chars
end

#move_effective_dateDate

Change of address Move Effective Date: YYYY-MM-DD.

Returns:

  • (Date)


31
32
33
# File 'lib/usps_api/models/change_of_address.rb', line 31

def move_effective_date
  @move_effective_date
end

#move_typeMoveType

Indicates the type of move Business (B), Family (F) or Individual (I).

Returns:



35
36
37
# File 'lib/usps_api/models/change_of_address.rb', line 35

def move_type
  @move_type
end

#orig_full_nameString

Change of Address Original Full Name

Returns:

  • (String)


39
40
41
# File 'lib/usps_api/models/change_of_address.rb', line 39

def orig_full_name
  @orig_full_name
end

#return_codeString

NCOA Return Code - status of match to NCOA.

Returns:

  • (String)


27
28
29
# File 'lib/usps_api/models/change_of_address.rb', line 27

def return_code
  @return_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/usps_api/models/change_of_address.rb', line 125

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  beyond_months = hash.key?('beyondMonths') ? hash['beyondMonths'] : nil
  return_code = hash.key?('returnCode') ? hash['returnCode'] : nil
  error_code = hash.key?('errorCode') ? hash['errorCode'] : SKIP
  error_description =
    hash.key?('errorDescription') ? hash['errorDescription'] : SKIP
  move_effective_date =
    hash.key?('moveEffectiveDate') ? hash['moveEffectiveDate'] : SKIP
  move_type = hash.key?('moveType') ? hash['moveType'] : SKIP
  orig_full_name = hash.key?('origFullName') ? hash['origFullName'] : SKIP
  matched_business_name =
    hash.key?('matchedBusinessName') ? hash['matchedBusinessName'] : SKIP
  matched_first_name =
    hash.key?('matchedFirstName') ? hash['matchedFirstName'] : SKIP
  matched_last_name =
    hash.key?('matchedLastName') ? hash['matchedLastName'] : SKIP
  matched_suffix_name =
    hash.key?('matchedSuffixName') ? hash['matchedSuffixName'] : SKIP
  middle_name_two_chars =
    hash.key?('middleNameTwoChars') ? hash['middleNameTwoChars'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  ChangeOfAddress.new(beyond_months: beyond_months,
                      return_code: return_code,
                      error_code: error_code,
                      error_description: error_description,
                      move_effective_date: move_effective_date,
                      move_type: move_type,
                      orig_full_name: orig_full_name,
                      matched_business_name: matched_business_name,
                      matched_first_name: matched_first_name,
                      matched_last_name: matched_last_name,
                      matched_suffix_name: matched_suffix_name,
                      middle_name_two_chars: middle_name_two_chars,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/usps_api/models/change_of_address.rb', line 62

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['error_code'] = 'errorCode'
  @_hash['error_description'] = 'errorDescription'
  @_hash['beyond_months'] = 'beyondMonths'
  @_hash['return_code'] = 'returnCode'
  @_hash['move_effective_date'] = 'moveEffectiveDate'
  @_hash['move_type'] = 'moveType'
  @_hash['orig_full_name'] = 'origFullName'
  @_hash['matched_business_name'] = 'matchedBusinessName'
  @_hash['matched_first_name'] = 'matchedFirstName'
  @_hash['matched_last_name'] = 'matchedLastName'
  @_hash['matched_suffix_name'] = 'matchedSuffixName'
  @_hash['middle_name_two_chars'] = 'middleNameTwoChars'
  @_hash
end

.nullablesObject

An array for nullable fields



96
97
98
# File 'lib/usps_api/models/change_of_address.rb', line 96

def self.nullables
  []
end

.optionalsObject

An array for optional fields



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/usps_api/models/change_of_address.rb', line 80

def self.optionals
  %w[
    error_code
    error_description
    move_effective_date
    move_type
    orig_full_name
    matched_business_name
    matched_first_name
    matched_last_name
    matched_suffix_name
    middle_name_two_chars
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



185
186
187
188
189
190
191
192
193
194
195
# File 'lib/usps_api/models/change_of_address.rb', line 185

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} error_code: #{@error_code.inspect}, error_description:"\
  " #{@error_description.inspect}, beyond_months: #{@beyond_months.inspect}, return_code:"\
  " #{@return_code.inspect}, move_effective_date: #{@move_effective_date.inspect}, move_type:"\
  " #{@move_type.inspect}, orig_full_name: #{@orig_full_name.inspect}, matched_business_name:"\
  " #{@matched_business_name.inspect}, matched_first_name: #{@matched_first_name.inspect},"\
  " matched_last_name: #{@matched_last_name.inspect}, matched_suffix_name:"\
  " #{@matched_suffix_name.inspect}, middle_name_two_chars: #{@middle_name_two_chars.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



173
174
175
176
177
178
179
180
181
182
# File 'lib/usps_api/models/change_of_address.rb', line 173

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} error_code: #{@error_code}, error_description: #{@error_description},"\
  " beyond_months: #{@beyond_months}, return_code: #{@return_code}, move_effective_date:"\
  " #{@move_effective_date}, move_type: #{@move_type}, orig_full_name: #{@orig_full_name},"\
  " matched_business_name: #{@matched_business_name}, matched_first_name:"\
  " #{@matched_first_name}, matched_last_name: #{@matched_last_name}, matched_suffix_name:"\
  " #{@matched_suffix_name}, middle_name_two_chars: #{@middle_name_two_chars},"\
  " additional_properties: #{@additional_properties}>"
end