Class: NewStoreApi::Product
- Defined in:
- lib/new_store_api/models/product.rb
Overview
Product Model.
Instance Attribute Summary collapse
-
#currency ⇒ CurrencyEnum
TODO: Write general description for this method.
-
#customs_info ⇒ OptionProductCustoms
TODO: Write general description for this method.
-
#dimension_height ⇒ Float
TODO: Write general description for this method.
-
#dimension_length ⇒ Float
TODO: Write general description for this method.
-
#dimension_unit ⇒ String
TODO: Write general description for this method.
-
#dimension_width ⇒ Float
TODO: Write general description for this method.
-
#external_identifiers ⇒ Hash[String, Object]
TODO: Write general description for this method.
-
#id ⇒ String
It should be the NewStore imported catalog ID.
-
#price ⇒ Float
It should be the NewStore imported catalog ID.
-
#quantity ⇒ Integer
It should be the NewStore imported catalog ID.
-
#weight ⇒ Float
It should be the NewStore imported catalog ID.
-
#weight_unit ⇒ String
It should be the NewStore imported catalog ID.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(currency = nil, id = nil, price = nil, quantity = nil, customs_info = SKIP, dimension_height = SKIP, dimension_length = SKIP, dimension_unit = SKIP, dimension_width = SKIP, external_identifiers = SKIP, weight = SKIP, weight_unit = SKIP) ⇒ Product
constructor
A new instance of Product.
-
#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(currency = nil, id = nil, price = nil, quantity = nil, customs_info = SKIP, dimension_height = SKIP, dimension_length = SKIP, dimension_unit = SKIP, dimension_width = SKIP, external_identifiers = SKIP, weight = SKIP, weight_unit = SKIP) ⇒ Product
Returns a new instance of Product.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/new_store_api/models/product.rb', line 106 def initialize(currency = nil, id = nil, price = nil, quantity = nil, customs_info = SKIP, dimension_height = SKIP, dimension_length = SKIP, dimension_unit = SKIP, dimension_width = SKIP, external_identifiers = SKIP, weight = SKIP, weight_unit = SKIP) @currency = currency @customs_info = customs_info unless customs_info == SKIP @dimension_height = dimension_height unless dimension_height == SKIP @dimension_length = dimension_length unless dimension_length == SKIP @dimension_unit = dimension_unit unless dimension_unit == SKIP @dimension_width = dimension_width unless dimension_width == SKIP @external_identifiers = external_identifiers unless external_identifiers == SKIP @id = id @price = price @quantity = quantity @weight = weight unless weight == SKIP @weight_unit = weight_unit unless weight_unit == SKIP end |
Instance Attribute Details
#currency ⇒ CurrencyEnum
TODO: Write general description for this method
14 15 16 |
# File 'lib/new_store_api/models/product.rb', line 14 def currency @currency end |
#customs_info ⇒ OptionProductCustoms
TODO: Write general description for this method
18 19 20 |
# File 'lib/new_store_api/models/product.rb', line 18 def customs_info @customs_info end |
#dimension_height ⇒ Float
TODO: Write general description for this method
22 23 24 |
# File 'lib/new_store_api/models/product.rb', line 22 def dimension_height @dimension_height end |
#dimension_length ⇒ Float
TODO: Write general description for this method
26 27 28 |
# File 'lib/new_store_api/models/product.rb', line 26 def dimension_length @dimension_length end |
#dimension_unit ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/new_store_api/models/product.rb', line 30 def dimension_unit @dimension_unit end |
#dimension_width ⇒ Float
TODO: Write general description for this method
34 35 36 |
# File 'lib/new_store_api/models/product.rb', line 34 def dimension_width @dimension_width end |
#external_identifiers ⇒ Hash[String, Object]
TODO: Write general description for this method
38 39 40 |
# File 'lib/new_store_api/models/product.rb', line 38 def external_identifiers @external_identifiers end |
#id ⇒ String
It should be the NewStore imported catalog ID
42 43 44 |
# File 'lib/new_store_api/models/product.rb', line 42 def id @id end |
#price ⇒ Float
It should be the NewStore imported catalog ID
46 47 48 |
# File 'lib/new_store_api/models/product.rb', line 46 def price @price end |
#quantity ⇒ Integer
It should be the NewStore imported catalog ID
50 51 52 |
# File 'lib/new_store_api/models/product.rb', line 50 def quantity @quantity end |
#weight ⇒ Float
It should be the NewStore imported catalog ID
54 55 56 |
# File 'lib/new_store_api/models/product.rb', line 54 def weight @weight end |
#weight_unit ⇒ String
It should be the NewStore imported catalog ID
58 59 60 |
# File 'lib/new_store_api/models/product.rb', line 58 def weight_unit @weight_unit 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 |
# File 'lib/new_store_api/models/product.rb', line 126 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. currency = hash.key?('currency') ? hash['currency'] : nil id = hash.key?('id') ? hash['id'] : nil price = hash.key?('price') ? hash['price'] : nil quantity = hash.key?('quantity') ? hash['quantity'] : nil customs_info = OptionProductCustoms.from_hash(hash['customs_info']) if hash['customs_info'] dimension_height = hash.key?('dimension_height') ? hash['dimension_height'] : SKIP dimension_length = hash.key?('dimension_length') ? hash['dimension_length'] : SKIP dimension_unit = hash.key?('dimension_unit') ? hash['dimension_unit'] : SKIP dimension_width = hash.key?('dimension_width') ? hash['dimension_width'] : SKIP external_identifiers = hash.key?('external_identifiers') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:ProductExternalIdentifiers), hash['external_identifiers'] ) : SKIP weight = hash.key?('weight') ? hash['weight'] : SKIP weight_unit = hash.key?('weight_unit') ? hash['weight_unit'] : SKIP # Create object from extracted values. Product.new(currency, id, price, quantity, customs_info, dimension_height, dimension_length, dimension_unit, dimension_width, external_identifiers, weight, weight_unit) end |
.names ⇒ Object
A mapping from model property names to API property names.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/new_store_api/models/product.rb', line 61 def self.names @_hash = {} if @_hash.nil? @_hash['currency'] = 'currency' @_hash['customs_info'] = 'customs_info' @_hash['dimension_height'] = 'dimension_height' @_hash['dimension_length'] = 'dimension_length' @_hash['dimension_unit'] = 'dimension_unit' @_hash['dimension_width'] = 'dimension_width' @_hash['external_identifiers'] = 'external_identifiers' @_hash['id'] = 'id' @_hash['price'] = 'price' @_hash['quantity'] = 'quantity' @_hash['weight'] = 'weight' @_hash['weight_unit'] = 'weight_unit' @_hash end |
.nullables ⇒ Object
An array for nullable fields
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/new_store_api/models/product.rb', line 93 def self.nullables %w[ customs_info dimension_height dimension_length dimension_unit dimension_width external_identifiers weight weight_unit ] end |
.optionals ⇒ Object
An array for optional fields
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/new_store_api/models/product.rb', line 79 def self.optionals %w[ customs_info dimension_height dimension_length dimension_unit dimension_width external_identifiers weight weight_unit ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/new_store_api/models/product.rb', line 166 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.currency, ->(val) { CurrencyEnum.validate(val) }) and APIHelper.valid_type?(value.id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.price, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.quantity, ->(val) { val.instance_of? Integer }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['currency'], ->(val) { CurrencyEnum.validate(val) }) and APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['price'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['quantity'], ->(val) { val.instance_of? Integer }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
205 206 207 208 209 210 211 212 213 |
# File 'lib/new_store_api/models/product.rb', line 205 def inspect class_name = self.class.name.split('::').last "<#{class_name} currency: #{@currency.inspect}, customs_info: #{@customs_info.inspect},"\ " dimension_height: #{@dimension_height.inspect}, dimension_length:"\ " #{@dimension_length.inspect}, dimension_unit: #{@dimension_unit.inspect}, dimension_width:"\ " #{@dimension_width.inspect}, external_identifiers: #{@external_identifiers.inspect}, id:"\ " #{@id.inspect}, price: #{@price.inspect}, quantity: #{@quantity.inspect}, weight:"\ " #{@weight.inspect}, weight_unit: #{@weight_unit.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
195 196 197 198 199 200 201 202 |
# File 'lib/new_store_api/models/product.rb', line 195 def to_s class_name = self.class.name.split('::').last "<#{class_name} currency: #{@currency}, customs_info: #{@customs_info}, dimension_height:"\ " #{@dimension_height}, dimension_length: #{@dimension_length}, dimension_unit:"\ " #{@dimension_unit}, dimension_width: #{@dimension_width}, external_identifiers:"\ " #{@external_identifiers}, id: #{@id}, price: #{@price}, quantity: #{@quantity}, weight:"\ " #{@weight}, weight_unit: #{@weight_unit}>" end |