Class: WalmartApIs::Address2
- Defined in:
- lib/walmart_ap_is/models/address2.rb
Overview
Address2 Model.
Instance Attribute Summary collapse
-
#address_line1 ⇒ String
TODO: Write general description for this method.
-
#address_line2 ⇒ String
TODO: Write general description for this method.
-
#city ⇒ String
TODO: Write general description for this method.
-
#country ⇒ String
TODO: Write general description for this method.
-
#name ⇒ String
TODO: Write general description for this method.
-
#postal_code ⇒ String
TODO: Write general description for this method.
-
#state ⇒ String
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(name: SKIP, address_line1: SKIP, address_line2: SKIP, city: SKIP, state: SKIP, postal_code: SKIP, country: 'US', additional_properties: nil) ⇒ Address2
constructor
A new instance of Address2.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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: SKIP, address_line1: SKIP, address_line2: SKIP, city: SKIP, state: SKIP, postal_code: SKIP, country: 'US', additional_properties: nil) ⇒ Address2
Returns a new instance of Address2.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/walmart_ap_is/models/address2.rb', line 71 def initialize(name: SKIP, address_line1: SKIP, address_line2: SKIP, city: SKIP, state: SKIP, postal_code: SKIP, country: 'US', additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @name = name unless name == SKIP @address_line1 = address_line1 unless address_line1 == SKIP @address_line2 = address_line2 unless address_line2 == SKIP @city = city unless city == SKIP @state = state unless state == SKIP @postal_code = postal_code unless postal_code == SKIP @country = country unless country == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#address_line1 ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/walmart_ap_is/models/address2.rb', line 18 def address_line1 @address_line1 end |
#address_line2 ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/walmart_ap_is/models/address2.rb', line 22 def address_line2 @address_line2 end |
#city ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/walmart_ap_is/models/address2.rb', line 26 def city @city end |
#country ⇒ String
TODO: Write general description for this method
38 39 40 |
# File 'lib/walmart_ap_is/models/address2.rb', line 38 def country @country end |
#name ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/walmart_ap_is/models/address2.rb', line 14 def name @name end |
#postal_code ⇒ String
TODO: Write general description for this method
34 35 36 |
# File 'lib/walmart_ap_is/models/address2.rb', line 34 def postal_code @postal_code end |
#state ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/walmart_ap_is/models/address2.rb', line 30 def state @state end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/walmart_ap_is/models/address2.rb', line 88 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : SKIP address_line1 = hash.key?('addressLine1') ? hash['addressLine1'] : SKIP address_line2 = hash.key?('addressLine2') ? hash['addressLine2'] : SKIP city = hash.key?('city') ? hash['city'] : SKIP state = hash.key?('state') ? hash['state'] : SKIP postal_code = hash.key?('postalCode') ? hash['postalCode'] : SKIP country = hash['country'] ||= 'US' # 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. Address2.new(name: name, address_line1: address_line1, address_line2: address_line2, city: city, state: state, postal_code: postal_code, country: country, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/walmart_ap_is/models/address2.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['address_line1'] = 'addressLine1' @_hash['address_line2'] = 'addressLine2' @_hash['city'] = 'city' @_hash['state'] = 'state' @_hash['postal_code'] = 'postalCode' @_hash['country'] = 'country' @_hash end |
.nullables ⇒ Object
An array for nullable fields
67 68 69 |
# File 'lib/walmart_ap_is/models/address2.rb', line 67 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/walmart_ap_is/models/address2.rb', line 54 def self.optionals %w[ name address_line1 address_line2 city state postal_code country ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
127 128 129 130 131 132 133 |
# File 'lib/walmart_ap_is/models/address2.rb', line 127 def inspect class_name = self.class.name.split('::').last "<#{class_name} name: #{@name.inspect}, address_line1: #{@address_line1.inspect},"\ " address_line2: #{@address_line2.inspect}, city: #{@city.inspect}, state:"\ " #{@state.inspect}, postal_code: #{@postal_code.inspect}, country: #{@country.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
119 120 121 122 123 124 |
# File 'lib/walmart_ap_is/models/address2.rb', line 119 def to_s class_name = self.class.name.split('::').last "<#{class_name} name: #{@name}, address_line1: #{@address_line1}, address_line2:"\ " #{@address_line2}, city: #{@city}, state: #{@state}, postal_code: #{@postal_code},"\ " country: #{@country}, additional_properties: #{@additional_properties}>" end |