Class: NewStoreApi::Product1
- Defined in:
- lib/new_store_api/models/product1.rb
Overview
Product1 Model.
Instance Attribute Summary collapse
-
#addon_parent_item_id ⇒ String
establish the relationship between this item and its parent, using the item_id of a parent product.
-
#currency ⇒ CurrencyEnum
establish the relationship between this item and its parent, using the item_id of a parent product.
-
#customs_info ⇒ OptionProductCustoms
establish the relationship between this item and its parent, using the item_id of a parent product.
-
#dimension_height ⇒ Float
establish the relationship between this item and its parent, using the item_id of a parent product.
-
#dimension_length ⇒ Float
establish the relationship between this item and its parent, using the item_id of a parent product.
-
#dimension_unit ⇒ String
establish the relationship between this item and its parent, using the item_id of a parent product.
-
#dimension_width ⇒ Float
establish the relationship between this item and its parent, using the item_id of a parent product.
-
#external_identifiers ⇒ Hash[String, Object]
establish the relationship between this item and its parent, using the item_id of a parent product.
-
#id ⇒ String
It should be the NewStore imported catalog ID.
-
#is_preorder ⇒ TrueClass | FalseClass
Indicates if the product is a pre-order and is available only in a future date.
-
#item_id ⇒ String
unique item id of this product instance.
-
#online_from ⇒ DateTime
The date when the product can be sold if pre-ordering.
-
#price ⇒ Float
The date when the product can be sold if pre-ordering.
-
#weight ⇒ Float
The date when the product can be sold if pre-ordering.
-
#weight_unit ⇒ String
The date when the product can be sold if pre-ordering.
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, addon_parent_item_id = SKIP, customs_info = SKIP, dimension_height = SKIP, dimension_length = SKIP, dimension_unit = SKIP, dimension_width = SKIP, external_identifiers = SKIP, is_preorder = false, item_id = SKIP, online_from = SKIP, weight = SKIP, weight_unit = SKIP) ⇒ Product1
constructor
A new instance of Product1.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_online_from ⇒ Object
-
#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, addon_parent_item_id = SKIP, customs_info = SKIP, dimension_height = SKIP, dimension_length = SKIP, dimension_unit = SKIP, dimension_width = SKIP, external_identifiers = SKIP, is_preorder = false, item_id = SKIP, online_from = SKIP, weight = SKIP, weight_unit = SKIP) ⇒ Product1
Returns a new instance of Product1.
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/new_store_api/models/product1.rb', line 146 def initialize(currency = nil, id = nil, price = nil, addon_parent_item_id = SKIP, customs_info = SKIP, dimension_height = SKIP, dimension_length = SKIP, dimension_unit = SKIP, dimension_width = SKIP, external_identifiers = SKIP, is_preorder = false, item_id = SKIP, online_from = SKIP, weight = SKIP, weight_unit = SKIP) @addon_parent_item_id = addon_parent_item_id unless addon_parent_item_id == 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 @is_preorder = is_preorder unless is_preorder == SKIP @item_id = item_id unless item_id == SKIP @online_from = online_from unless online_from == SKIP @price = price @weight = weight unless weight == SKIP @weight_unit = weight_unit unless weight_unit == SKIP end |
Instance Attribute Details
#addon_parent_item_id ⇒ String
establish the relationship between this item and its parent, using the item_id of a parent product. this implies the parent has its item_id defined.
17 18 19 |
# File 'lib/new_store_api/models/product1.rb', line 17 def addon_parent_item_id @addon_parent_item_id end |
#currency ⇒ CurrencyEnum
establish the relationship between this item and its parent, using the item_id of a parent product. this implies the parent has its item_id defined.
23 24 25 |
# File 'lib/new_store_api/models/product1.rb', line 23 def currency @currency end |
#customs_info ⇒ OptionProductCustoms
establish the relationship between this item and its parent, using the item_id of a parent product. this implies the parent has its item_id defined.
29 30 31 |
# File 'lib/new_store_api/models/product1.rb', line 29 def customs_info @customs_info end |
#dimension_height ⇒ Float
establish the relationship between this item and its parent, using the item_id of a parent product. this implies the parent has its item_id defined.
35 36 37 |
# File 'lib/new_store_api/models/product1.rb', line 35 def dimension_height @dimension_height end |
#dimension_length ⇒ Float
establish the relationship between this item and its parent, using the item_id of a parent product. this implies the parent has its item_id defined.
41 42 43 |
# File 'lib/new_store_api/models/product1.rb', line 41 def dimension_length @dimension_length end |
#dimension_unit ⇒ String
establish the relationship between this item and its parent, using the item_id of a parent product. this implies the parent has its item_id defined.
47 48 49 |
# File 'lib/new_store_api/models/product1.rb', line 47 def dimension_unit @dimension_unit end |
#dimension_width ⇒ Float
establish the relationship between this item and its parent, using the item_id of a parent product. this implies the parent has its item_id defined.
53 54 55 |
# File 'lib/new_store_api/models/product1.rb', line 53 def dimension_width @dimension_width end |
#external_identifiers ⇒ Hash[String, Object]
establish the relationship between this item and its parent, using the item_id of a parent product. this implies the parent has its item_id defined.
59 60 61 |
# File 'lib/new_store_api/models/product1.rb', line 59 def external_identifiers @external_identifiers end |
#id ⇒ String
It should be the NewStore imported catalog ID
63 64 65 |
# File 'lib/new_store_api/models/product1.rb', line 63 def id @id end |
#is_preorder ⇒ TrueClass | FalseClass
Indicates if the product is a pre-order and is available only in a future date
68 69 70 |
# File 'lib/new_store_api/models/product1.rb', line 68 def is_preorder @is_preorder end |
#item_id ⇒ String
unique item id of this product instance.
72 73 74 |
# File 'lib/new_store_api/models/product1.rb', line 72 def item_id @item_id end |
#online_from ⇒ DateTime
The date when the product can be sold if pre-ordering
76 77 78 |
# File 'lib/new_store_api/models/product1.rb', line 76 def online_from @online_from end |
#price ⇒ Float
The date when the product can be sold if pre-ordering
80 81 82 |
# File 'lib/new_store_api/models/product1.rb', line 80 def price @price end |
#weight ⇒ Float
The date when the product can be sold if pre-ordering
84 85 86 |
# File 'lib/new_store_api/models/product1.rb', line 84 def weight @weight end |
#weight_unit ⇒ String
The date when the product can be sold if pre-ordering
88 89 90 |
# File 'lib/new_store_api/models/product1.rb', line 88 def weight_unit @weight_unit end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/new_store_api/models/product1.rb', line 171 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 addon_parent_item_id = hash.key?('addon_parent_item_id') ? hash['addon_parent_item_id'] : SKIP 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(:Product1ExternalIdentifiers), hash['external_identifiers'] ) : SKIP is_preorder = hash['is_preorder'] ||= false item_id = hash.key?('item_id') ? hash['item_id'] : SKIP online_from = if hash.key?('online_from') (DateTimeHelper.from_rfc3339(hash['online_from']) if hash['online_from']) else SKIP end weight = hash.key?('weight') ? hash['weight'] : SKIP weight_unit = hash.key?('weight_unit') ? hash['weight_unit'] : SKIP # Create object from extracted values. Product1.new(currency, id, price, addon_parent_item_id, customs_info, dimension_height, dimension_length, dimension_unit, dimension_width, external_identifiers, is_preorder, item_id, online_from, weight, weight_unit) end |
.names ⇒ Object
A mapping from model property names to API property names.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/new_store_api/models/product1.rb', line 91 def self.names @_hash = {} if @_hash.nil? @_hash['addon_parent_item_id'] = 'addon_parent_item_id' @_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['is_preorder'] = 'is_preorder' @_hash['item_id'] = 'item_id' @_hash['online_from'] = 'online_from' @_hash['price'] = 'price' @_hash['weight'] = 'weight' @_hash['weight_unit'] = 'weight_unit' @_hash end |
.nullables ⇒ Object
An array for nullable fields
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/new_store_api/models/product1.rb', line 130 def self.nullables %w[ addon_parent_item_id customs_info dimension_height dimension_length dimension_unit dimension_width external_identifiers item_id online_from weight weight_unit ] end |
.optionals ⇒ Object
An array for optional fields
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/new_store_api/models/product1.rb', line 112 def self.optionals %w[ addon_parent_item_id customs_info dimension_height dimension_length dimension_unit dimension_width external_identifiers is_preorder item_id online_from weight weight_unit ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/new_store_api/models/product1.rb', line 226 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 }) ) 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 }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/new_store_api/models/product1.rb', line 262 def inspect class_name = self.class.name.split('::').last "<#{class_name} addon_parent_item_id: #{@addon_parent_item_id.inspect}, 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}, is_preorder:"\ " #{@is_preorder.inspect}, item_id: #{@item_id.inspect}, online_from:"\ " #{@online_from.inspect}, price: #{@price.inspect}, weight: #{@weight.inspect},"\ " weight_unit: #{@weight_unit.inspect}>" end |
#to_custom_online_from ⇒ Object
220 221 222 |
# File 'lib/new_store_api/models/product1.rb', line 220 def to_custom_online_from DateTimeHelper.to_rfc3339(online_from) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
251 252 253 254 255 256 257 258 259 |
# File 'lib/new_store_api/models/product1.rb', line 251 def to_s class_name = self.class.name.split('::').last "<#{class_name} addon_parent_item_id: #{@addon_parent_item_id}, 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},"\ " is_preorder: #{@is_preorder}, item_id: #{@item_id}, online_from: #{@online_from}, price:"\ " #{@price}, weight: #{@weight}, weight_unit: #{@weight_unit}>" end |