Class: WalmartApIs::Address1

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/walmart_ap_is/models/address1.rb

Overview

Address1 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(name:, address_line1:, city:, state_or_region:, postal_code:, country_code: 'US', address_line2: SKIP, address_line3: SKIP, county: SKIP, district: SKIP, municipality: SKIP, phone: SKIP, is_commercial_address: SKIP, additional_properties: nil) ⇒ Address1

Returns a new instance of Address1.



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

def initialize(name:, address_line1:, city:, state_or_region:, postal_code:,
               country_code: 'US', address_line2: SKIP, address_line3: SKIP,
               county: SKIP, district: SKIP, municipality: SKIP,
               phone: SKIP, is_commercial_address: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @name = name
  @address_line1 = address_line1
  @address_line2 = address_line2 unless address_line2 == SKIP
  @address_line3 = address_line3 unless address_line3 == SKIP
  @city = city
  @county = county unless county == SKIP
  @district = district unless district == SKIP
  @state_or_region = state_or_region
  @municipality = municipality unless municipality == SKIP
  @postal_code = postal_code
  @country_code = country_code
  @phone = phone unless phone == SKIP
  @is_commercial_address = is_commercial_address unless is_commercial_address == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#address_line1String

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/walmart_ap_is/models/address1.rb', line 18

def address_line1
  @address_line1
end

#address_line2String

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/walmart_ap_is/models/address1.rb', line 22

def address_line2
  @address_line2
end

#address_line3String

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/walmart_ap_is/models/address1.rb', line 26

def address_line3
  @address_line3
end

#cityString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/walmart_ap_is/models/address1.rb', line 30

def city
  @city
end

#country_codeString

TODO: Write general description for this method

Returns:

  • (String)


54
55
56
# File 'lib/walmart_ap_is/models/address1.rb', line 54

def country_code
  @country_code
end

#countyString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/walmart_ap_is/models/address1.rb', line 34

def county
  @county
end

#districtString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/walmart_ap_is/models/address1.rb', line 38

def district
  @district
end

#is_commercial_addressTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


62
63
64
# File 'lib/walmart_ap_is/models/address1.rb', line 62

def is_commercial_address
  @is_commercial_address
end

#municipalityString

TODO: Write general description for this method

Returns:

  • (String)


46
47
48
# File 'lib/walmart_ap_is/models/address1.rb', line 46

def municipality
  @municipality
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/walmart_ap_is/models/address1.rb', line 14

def name
  @name
end

#phoneString

TODO: Write general description for this method

Returns:

  • (String)


58
59
60
# File 'lib/walmart_ap_is/models/address1.rb', line 58

def phone
  @phone
end

#postal_codeString

TODO: Write general description for this method

Returns:

  • (String)


50
51
52
# File 'lib/walmart_ap_is/models/address1.rb', line 50

def postal_code
  @postal_code
end

#state_or_regionString

TODO: Write general description for this method

Returns:

  • (String)


42
43
44
# File 'lib/walmart_ap_is/models/address1.rb', line 42

def state_or_region
  @state_or_region
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/walmart_ap_is/models/address1.rb', line 126

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  address_line1 = hash.key?('addressLine1') ? hash['addressLine1'] : nil
  city = hash.key?('city') ? hash['city'] : nil
  state_or_region = hash.key?('stateOrRegion') ? hash['stateOrRegion'] : nil
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : nil
  country_code = hash['countryCode'] ||= 'US'
  address_line2 = hash.key?('addressLine2') ? hash['addressLine2'] : SKIP
  address_line3 = hash.key?('addressLine3') ? hash['addressLine3'] : SKIP
  county = hash.key?('county') ? hash['county'] : SKIP
  district = hash.key?('district') ? hash['district'] : SKIP
  municipality = hash.key?('municipality') ? hash['municipality'] : SKIP
  phone = hash.key?('phone') ? hash['phone'] : SKIP
  is_commercial_address =
    hash.key?('isCommercialAddress') ? hash['isCommercialAddress'] : 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.
  Address1.new(name: name,
               address_line1: address_line1,
               city: city,
               state_or_region: state_or_region,
               postal_code: postal_code,
               country_code: country_code,
               address_line2: address_line2,
               address_line3: address_line3,
               county: county,
               district: district,
               municipality: municipality,
               phone: phone,
               is_commercial_address: is_commercial_address,
               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/walmart_ap_is/models/address1.rb', line 65

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['address_line1'] = 'addressLine1'
  @_hash['address_line2'] = 'addressLine2'
  @_hash['address_line3'] = 'addressLine3'
  @_hash['city'] = 'city'
  @_hash['county'] = 'county'
  @_hash['district'] = 'district'
  @_hash['state_or_region'] = 'stateOrRegion'
  @_hash['municipality'] = 'municipality'
  @_hash['postal_code'] = 'postalCode'
  @_hash['country_code'] = 'countryCode'
  @_hash['phone'] = 'phone'
  @_hash['is_commercial_address'] = 'isCommercialAddress'
  @_hash
end

.nullablesObject

An array for nullable fields



97
98
99
# File 'lib/walmart_ap_is/models/address1.rb', line 97

def self.nullables
  []
end

.optionalsObject

An array for optional fields



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/walmart_ap_is/models/address1.rb', line 84

def self.optionals
  %w[
    address_line2
    address_line3
    county
    district
    municipality
    phone
    is_commercial_address
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



181
182
183
184
185
186
187
188
189
190
# File 'lib/walmart_ap_is/models/address1.rb', line 181

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name.inspect}, address_line1: #{@address_line1.inspect},"\
  " address_line2: #{@address_line2.inspect}, address_line3: #{@address_line3.inspect}, city:"\
  " #{@city.inspect}, county: #{@county.inspect}, district: #{@district.inspect},"\
  " state_or_region: #{@state_or_region.inspect}, municipality: #{@municipality.inspect},"\
  " postal_code: #{@postal_code.inspect}, country_code: #{@country_code.inspect}, phone:"\
  " #{@phone.inspect}, is_commercial_address: #{@is_commercial_address.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



170
171
172
173
174
175
176
177
178
# File 'lib/walmart_ap_is/models/address1.rb', line 170

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name}, address_line1: #{@address_line1}, address_line2:"\
  " #{@address_line2}, address_line3: #{@address_line3}, city: #{@city}, county: #{@county},"\
  " district: #{@district}, state_or_region: #{@state_or_region}, municipality:"\
  " #{@municipality}, postal_code: #{@postal_code}, country_code: #{@country_code}, phone:"\
  " #{@phone}, is_commercial_address: #{@is_commercial_address}, additional_properties:"\
  " #{@additional_properties}>"
end