Class: CyberSourceMergedSpec::StandardAddress

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/standard_address.rb

Overview

StandardAddress Model.

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(address1: SKIP, address2: SKIP, address3: SKIP, address4: SKIP, locality: SKIP, county: SKIP, country: SKIP, csz: SKIP, iso_country: SKIP, administrative_area: SKIP, postal_code: SKIP, additional_properties: nil) ⇒ StandardAddress

Returns a new instance of StandardAddress.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 95

def initialize(address1: SKIP, address2: SKIP, address3: SKIP,
               address4: SKIP, locality: SKIP, county: SKIP, country: SKIP,
               csz: SKIP, iso_country: SKIP, administrative_area: SKIP,
               postal_code: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @address1 = address1 unless address1 == SKIP
  @address2 = address2 unless address2 == SKIP
  @address3 = address3 unless address3 == SKIP
  @address4 = address4 unless address4 == SKIP
  @locality = locality unless locality == SKIP
  @county = county unless county == SKIP
  @country = country unless country == SKIP
  @csz = csz unless csz == SKIP
  @iso_country = iso_country unless iso_country == SKIP
  @administrative_area = administrative_area unless administrative_area == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#address1Address1

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 14

def address1
  @address1
end

#address2String

Second line of the standardized address.

Returns:

  • (String)


18
19
20
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 18

def address2
  @address2
end

#address3String

Third line of the standardized address.

Returns:

  • (String)


22
23
24
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 22

def address3
  @address3
end

#address4String

Fourth line of the standardized address.

Returns:

  • (String)


26
27
28
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 26

def address4
  @address4
end

#administrative_areaString

U.S.P.S. standardized state or province abbreviation.

Returns:

  • (String)


50
51
52
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 50

def administrative_area
  @administrative_area
end

#countryString

Standardized country name.

Returns:

  • (String)


38
39
40
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 38

def country
  @country
end

#countyString

U.S. county if available.

Returns:

  • (String)


34
35
36
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 34

def county
  @county
end

#cszString

Standardized city, state or province, and ZIP +4 code or postal code line.

Returns:

  • (String)


42
43
44
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 42

def csz
  @csz
end

#iso_countryString

Standardized two-character ISO country code.

Returns:

  • (String)


46
47
48
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 46

def iso_country
  @iso_country
end

#localityString

Standardized city name.

Returns:

  • (String)


30
31
32
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 30

def locality
  @locality
end

#postal_codeString

Standardized U.S. ZIP + 4 postal code.

Returns:

  • (String)


54
55
56
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 54

def postal_code
  @postal_code
end

Class Method Details

.from_element(root) ⇒ Object



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 156

def self.from_element(root)
  address1 = XmlUtilities.from_element(root, 'Address1', Address1)
  address2 = XmlUtilities.from_element(root, 'address2', String)
  address3 = XmlUtilities.from_element(root, 'address3', String)
  address4 = XmlUtilities.from_element(root, 'address4', String)
  locality = XmlUtilities.from_element(root, 'locality', String)
  county = XmlUtilities.from_element(root, 'county', String)
  country = XmlUtilities.from_element(root, 'country', String)
  csz = XmlUtilities.from_element(root, 'csz', String)
  iso_country = XmlUtilities.from_element(root, 'isoCountry', String)
  administrative_area = XmlUtilities.from_element(root,
                                                  'administrativeArea',
                                                  String)
  postal_code = XmlUtilities.from_element(root, 'postalCode', String)

  new(address1: address1,
      address2: address2,
      address3: address3,
      address4: address4,
      locality: locality,
      county: county,
      country: country,
      csz: csz,
      iso_country: iso_country,
      administrative_area: administrative_area,
      postal_code: postal_code,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



117
118
119
120
121
122
123
124
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
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 117

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  address1 = Address1.from_hash(hash['address1']) if hash['address1']
  address2 = hash.key?('address2') ? hash['address2'] : SKIP
  address3 = hash.key?('address3') ? hash['address3'] : SKIP
  address4 = hash.key?('address4') ? hash['address4'] : SKIP
  locality = hash.key?('locality') ? hash['locality'] : SKIP
  county = hash.key?('county') ? hash['county'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  csz = hash.key?('csz') ? hash['csz'] : SKIP
  iso_country = hash.key?('isoCountry') ? hash['isoCountry'] : SKIP
  administrative_area =
    hash.key?('administrativeArea') ? hash['administrativeArea'] : SKIP
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : 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.
  StandardAddress.new(address1: address1,
                      address2: address2,
                      address3: address3,
                      address4: address4,
                      locality: locality,
                      county: county,
                      country: country,
                      csz: csz,
                      iso_country: iso_country,
                      administrative_area: administrative_area,
                      postal_code: postal_code,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 57

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['address1'] = 'address1'
  @_hash['address2'] = 'address2'
  @_hash['address3'] = 'address3'
  @_hash['address4'] = 'address4'
  @_hash['locality'] = 'locality'
  @_hash['county'] = 'county'
  @_hash['country'] = 'country'
  @_hash['csz'] = 'csz'
  @_hash['iso_country'] = 'isoCountry'
  @_hash['administrative_area'] = 'administrativeArea'
  @_hash['postal_code'] = 'postalCode'
  @_hash
end

.nullablesObject

An array for nullable fields



91
92
93
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 91

def self.nullables
  []
end

.optionalsObject

An array for optional fields



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 74

def self.optionals
  %w[
    address1
    address2
    address3
    address4
    locality
    county
    country
    csz
    iso_country
    administrative_area
    postal_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



216
217
218
219
220
221
222
223
224
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 216

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} address1: #{@address1.inspect}, address2: #{@address2.inspect}, address3:"\
  " #{@address3.inspect}, address4: #{@address4.inspect}, locality: #{@locality.inspect},"\
  " county: #{@county.inspect}, country: #{@country.inspect}, csz: #{@csz.inspect},"\
  " iso_country: #{@iso_country.inspect}, administrative_area:"\
  " #{@administrative_area.inspect}, postal_code: #{@postal_code.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



207
208
209
210
211
212
213
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 207

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} address1: #{@address1}, address2: #{@address2}, address3: #{@address3},"\
  " address4: #{@address4}, locality: #{@locality}, county: #{@county}, country: #{@country},"\
  " csz: #{@csz}, iso_country: #{@iso_country}, administrative_area: #{@administrative_area},"\
  " postal_code: #{@postal_code}, additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/cyber_source_merged_spec/models/standard_address.rb', line 185

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'Address1', address1)
  XmlUtilities.add_as_subelement(doc, root, 'address2', address2)
  XmlUtilities.add_as_subelement(doc, root, 'address3', address3)
  XmlUtilities.add_as_subelement(doc, root, 'address4', address4)
  XmlUtilities.add_as_subelement(doc, root, 'locality', locality)
  XmlUtilities.add_as_subelement(doc, root, 'county', county)
  XmlUtilities.add_as_subelement(doc, root, 'country', country)
  XmlUtilities.add_as_subelement(doc, root, 'csz', csz)
  XmlUtilities.add_as_subelement(doc, root, 'isoCountry', iso_country)
  XmlUtilities.add_as_subelement(doc, root, 'administrativeArea',
                                 administrative_area)
  XmlUtilities.add_as_subelement(doc, root, 'postalCode', postal_code)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end