Class: WalmartApIs::AddressInput

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

Overview

Specific details to identify a place (input variant — phone required).

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(address_line1:, city:, country_code:, name:, phone_number:, postal_code:, address_line2: SKIP, company_name: SKIP, district_or_county: SKIP, email: SKIP, state_or_province_code: SKIP, additional_properties: nil) ⇒ AddressInput

Returns a new instance of AddressInput.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/walmart_ap_is/models/address_input.rb', line 89

def initialize(address_line1:, city:, country_code:, name:, phone_number:,
               postal_code:, address_line2: SKIP, company_name: SKIP,
               district_or_county: SKIP, email: SKIP,
               state_or_province_code: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @address_line1 = address_line1
  @address_line2 = address_line2 unless address_line2 == SKIP
  @city = city
  @company_name = company_name unless company_name == SKIP
  @country_code = country_code
  @district_or_county = district_or_county unless district_or_county == SKIP
  @email = email unless email == SKIP
  @name = name
  @phone_number = phone_number
  @postal_code = postal_code
  @state_or_province_code = state_or_province_code unless state_or_province_code == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#address_line1String

Street address information.

Returns:

  • (String)


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

def address_line1
  @address_line1
end

#address_line2String

Additional street address information.

Returns:

  • (String)


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

def address_line2
  @address_line2
end

#cityString

The city.

Returns:

  • (String)


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

def city
  @city
end

#company_nameString

The name of the business.

Returns:

  • (String)


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

def company_name
  @company_name
end

#country_codeString

The country code in two-character ISO 3166-1 alpha-2 format.

Returns:

  • (String)


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

def country_code
  @country_code
end

#district_or_countyString

The district or county.

Returns:

  • (String)


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

def district_or_county
  @district_or_county
end

#emailString

The email address.

Returns:

  • (String)


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

def email
  @email
end

#nameString

The name of the individual who is the primary contact.

Returns:

  • (String)


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

def name
  @name
end

#phone_numberString

The phone number.

Returns:

  • (String)


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

def phone_number
  @phone_number
end

#postal_codeString

The postal code.

Returns:

  • (String)


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

def postal_code
  @postal_code
end

#state_or_province_codeString

The state or province code.

Returns:

  • (String)


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

def state_or_province_code
  @state_or_province_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/walmart_ap_is/models/address_input.rb', line 111

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  address_line1 = hash.key?('addressLine1') ? hash['addressLine1'] : nil
  city = hash.key?('city') ? hash['city'] : nil
  country_code = hash.key?('countryCode') ? hash['countryCode'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  phone_number = hash.key?('phoneNumber') ? hash['phoneNumber'] : nil
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : nil
  address_line2 = hash.key?('addressLine2') ? hash['addressLine2'] : SKIP
  company_name = hash.key?('companyName') ? hash['companyName'] : SKIP
  district_or_county =
    hash.key?('districtOrCounty') ? hash['districtOrCounty'] : SKIP
  email = hash.key?('email') ? hash['email'] : SKIP
  state_or_province_code =
    hash.key?('stateOrProvinceCode') ? hash['stateOrProvinceCode'] : 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.
  AddressInput.new(address_line1: address_line1,
                   city: city,
                   country_code: country_code,
                   name: name,
                   phone_number: phone_number,
                   postal_code: postal_code,
                   address_line2: address_line2,
                   company_name: company_name,
                   district_or_county: district_or_county,
                   email: email,
                   state_or_province_code: state_or_province_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/walmart_ap_is/models/address_input.rb', line 57

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['address_line1'] = 'addressLine1'
  @_hash['address_line2'] = 'addressLine2'
  @_hash['city'] = 'city'
  @_hash['company_name'] = 'companyName'
  @_hash['country_code'] = 'countryCode'
  @_hash['district_or_county'] = 'districtOrCounty'
  @_hash['email'] = 'email'
  @_hash['name'] = 'name'
  @_hash['phone_number'] = 'phoneNumber'
  @_hash['postal_code'] = 'postalCode'
  @_hash['state_or_province_code'] = 'stateOrProvinceCode'
  @_hash
end

.nullablesObject

An array for nullable fields



85
86
87
# File 'lib/walmart_ap_is/models/address_input.rb', line 85

def self.nullables
  []
end

.optionalsObject

An array for optional fields



74
75
76
77
78
79
80
81
82
# File 'lib/walmart_ap_is/models/address_input.rb', line 74

def self.optionals
  %w[
    address_line2
    company_name
    district_or_county
    email
    state_or_province_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



162
163
164
165
166
167
168
169
170
171
# File 'lib/walmart_ap_is/models/address_input.rb', line 162

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} address_line1: #{@address_line1.inspect}, address_line2:"\
  " #{@address_line2.inspect}, city: #{@city.inspect}, company_name: #{@company_name.inspect},"\
  " country_code: #{@country_code.inspect}, district_or_county:"\
  " #{@district_or_county.inspect}, email: #{@email.inspect}, name: #{@name.inspect},"\
  " phone_number: #{@phone_number.inspect}, postal_code: #{@postal_code.inspect},"\
  " state_or_province_code: #{@state_or_province_code.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



152
153
154
155
156
157
158
159
# File 'lib/walmart_ap_is/models/address_input.rb', line 152

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} address_line1: #{@address_line1}, address_line2: #{@address_line2}, city:"\
  " #{@city}, company_name: #{@company_name}, country_code: #{@country_code},"\
  " district_or_county: #{@district_or_county}, email: #{@email}, name: #{@name},"\
  " phone_number: #{@phone_number}, postal_code: #{@postal_code}, state_or_province_code:"\
  " #{@state_or_province_code}, additional_properties: #{@additional_properties}>"
end