Class: UltracartClient::CartItem
- Inherits:
-
Object
- Object
- UltracartClient::CartItem
- Defined in:
- lib/ultracart_api/models/cart_item.rb
Instance Attribute Summary collapse
-
#arbitrary_unit_cost ⇒ Object
Returns the value of attribute arbitrary_unit_cost.
-
#attributes ⇒ Object
Attributes.
-
#auto_order_schedule ⇒ Object
Auto order schedule the customer selected.
-
#default_image_url ⇒ Object
URL to the default multimedia image.
-
#default_thumbnail_url ⇒ Object
URL to the default multimedia thumbnail.
-
#description ⇒ Object
Description of the item.
-
#discount ⇒ Object
Returns the value of attribute discount.
-
#extended_description ⇒ Object
Extended description of the item.
-
#item_id ⇒ Object
Item ID.
-
#item_oid ⇒ Object
Item object identifier.
-
#kit ⇒ Object
True if this item is a kit.
-
#kit_component_options ⇒ Object
Options associated with the kit components.
-
#manufacturer_suggested_retail_price ⇒ Object
Returns the value of attribute manufacturer_suggested_retail_price.
-
#maximum_quantity ⇒ Object
Maximum quantity the customer can purchase.
-
#minimum_quantity ⇒ Object
Minimum quantity the customer can purchase.
-
#multimedia ⇒ Object
Multimedia.
-
#options ⇒ Object
Options.
-
#phsyical ⇒ Object
Returns the value of attribute phsyical.
-
#position ⇒ Object
Position of the item in the cart.
-
#preorder ⇒ Object
True if this item is on pre-order.
-
#quantity ⇒ Object
quantity.
-
#schedules ⇒ Object
Customer selectable auto order schedules.
-
#total_cost ⇒ Object
Returns the value of attribute total_cost.
-
#total_cost_with_discount ⇒ Object
Returns the value of attribute total_cost_with_discount.
-
#unit_cost ⇒ Object
Returns the value of attribute unit_cost.
-
#unit_cost_with_discount ⇒ Object
Returns the value of attribute unit_cost_with_discount.
-
#upsell ⇒ Object
True if this item was added to the cart as part of an upsell.
-
#variations ⇒ Object
Variations.
-
#view_url ⇒ Object
URL to view the product on the site.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.swagger_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ CartItem
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ CartItem
Initializes the object
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 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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/ultracart_api/models/cart_item.rb', line 168 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'arbitrary_unit_cost') self.arbitrary_unit_cost = attributes[:'arbitrary_unit_cost'] end if attributes.has_key?(:'attributes') if (value = attributes[:'attributes']).is_a?(Array) self.attributes = value end end if attributes.has_key?(:'auto_order_schedule') self.auto_order_schedule = attributes[:'auto_order_schedule'] end if attributes.has_key?(:'default_image_url') self.default_image_url = attributes[:'default_image_url'] end if attributes.has_key?(:'default_thumbnail_url') self.default_thumbnail_url = attributes[:'default_thumbnail_url'] end if attributes.has_key?(:'description') self.description = attributes[:'description'] end if attributes.has_key?(:'discount') self.discount = attributes[:'discount'] end if attributes.has_key?(:'extended_description') self.extended_description = attributes[:'extended_description'] end if attributes.has_key?(:'item_id') self.item_id = attributes[:'item_id'] end if attributes.has_key?(:'item_oid') self.item_oid = attributes[:'item_oid'] end if attributes.has_key?(:'kit') self.kit = attributes[:'kit'] end if attributes.has_key?(:'kit_component_options') if (value = attributes[:'kit_component_options']).is_a?(Array) self. = value end end if attributes.has_key?(:'manufacturer_suggested_retail_price') self.manufacturer_suggested_retail_price = attributes[:'manufacturer_suggested_retail_price'] end if attributes.has_key?(:'maximum_quantity') self.maximum_quantity = attributes[:'maximum_quantity'] end if attributes.has_key?(:'minimum_quantity') self.minimum_quantity = attributes[:'minimum_quantity'] end if attributes.has_key?(:'multimedia') if (value = attributes[:'multimedia']).is_a?(Array) self.multimedia = value end end if attributes.has_key?(:'options') if (value = attributes[:'options']).is_a?(Array) self. = value end end if attributes.has_key?(:'phsyical') self.phsyical = attributes[:'phsyical'] end if attributes.has_key?(:'position') self.position = attributes[:'position'] end if attributes.has_key?(:'preorder') self.preorder = attributes[:'preorder'] end if attributes.has_key?(:'quantity') self.quantity = attributes[:'quantity'] end if attributes.has_key?(:'schedules') if (value = attributes[:'schedules']).is_a?(Array) self.schedules = value end end if attributes.has_key?(:'total_cost') self.total_cost = attributes[:'total_cost'] end if attributes.has_key?(:'total_cost_with_discount') self.total_cost_with_discount = attributes[:'total_cost_with_discount'] end if attributes.has_key?(:'unit_cost') self.unit_cost = attributes[:'unit_cost'] end if attributes.has_key?(:'unit_cost_with_discount') self.unit_cost_with_discount = attributes[:'unit_cost_with_discount'] end if attributes.has_key?(:'upsell') self.upsell = attributes[:'upsell'] end if attributes.has_key?(:'variations') if (value = attributes[:'variations']).is_a?(Array) self.variations = value end end if attributes.has_key?(:'view_url') self.view_url = attributes[:'view_url'] end end |
Instance Attribute Details
#arbitrary_unit_cost ⇒ Object
Returns the value of attribute arbitrary_unit_cost.
17 18 19 |
# File 'lib/ultracart_api/models/cart_item.rb', line 17 def arbitrary_unit_cost @arbitrary_unit_cost end |
#attributes ⇒ Object
Attributes
20 21 22 |
# File 'lib/ultracart_api/models/cart_item.rb', line 20 def attributes @attributes end |
#auto_order_schedule ⇒ Object
Auto order schedule the customer selected
23 24 25 |
# File 'lib/ultracart_api/models/cart_item.rb', line 23 def auto_order_schedule @auto_order_schedule end |
#default_image_url ⇒ Object
URL to the default multimedia image
26 27 28 |
# File 'lib/ultracart_api/models/cart_item.rb', line 26 def default_image_url @default_image_url end |
#default_thumbnail_url ⇒ Object
URL to the default multimedia thumbnail
29 30 31 |
# File 'lib/ultracart_api/models/cart_item.rb', line 29 def default_thumbnail_url @default_thumbnail_url end |
#description ⇒ Object
Description of the item
32 33 34 |
# File 'lib/ultracart_api/models/cart_item.rb', line 32 def description @description end |
#discount ⇒ Object
Returns the value of attribute discount.
34 35 36 |
# File 'lib/ultracart_api/models/cart_item.rb', line 34 def discount @discount end |
#extended_description ⇒ Object
Extended description of the item
37 38 39 |
# File 'lib/ultracart_api/models/cart_item.rb', line 37 def extended_description @extended_description end |
#item_id ⇒ Object
Item ID
40 41 42 |
# File 'lib/ultracart_api/models/cart_item.rb', line 40 def item_id @item_id end |
#item_oid ⇒ Object
Item object identifier
43 44 45 |
# File 'lib/ultracart_api/models/cart_item.rb', line 43 def item_oid @item_oid end |
#kit ⇒ Object
True if this item is a kit
46 47 48 |
# File 'lib/ultracart_api/models/cart_item.rb', line 46 def kit @kit end |
#kit_component_options ⇒ Object
Options associated with the kit components
49 50 51 |
# File 'lib/ultracart_api/models/cart_item.rb', line 49 def @kit_component_options end |
#manufacturer_suggested_retail_price ⇒ Object
Returns the value of attribute manufacturer_suggested_retail_price.
51 52 53 |
# File 'lib/ultracart_api/models/cart_item.rb', line 51 def manufacturer_suggested_retail_price @manufacturer_suggested_retail_price end |
#maximum_quantity ⇒ Object
Maximum quantity the customer can purchase
54 55 56 |
# File 'lib/ultracart_api/models/cart_item.rb', line 54 def maximum_quantity @maximum_quantity end |
#minimum_quantity ⇒ Object
Minimum quantity the customer can purchase
57 58 59 |
# File 'lib/ultracart_api/models/cart_item.rb', line 57 def minimum_quantity @minimum_quantity end |
#multimedia ⇒ Object
Multimedia
60 61 62 |
# File 'lib/ultracart_api/models/cart_item.rb', line 60 def multimedia @multimedia end |
#options ⇒ Object
Options
63 64 65 |
# File 'lib/ultracart_api/models/cart_item.rb', line 63 def @options end |
#phsyical ⇒ Object
Returns the value of attribute phsyical.
65 66 67 |
# File 'lib/ultracart_api/models/cart_item.rb', line 65 def phsyical @phsyical end |
#position ⇒ Object
Position of the item in the cart
68 69 70 |
# File 'lib/ultracart_api/models/cart_item.rb', line 68 def position @position end |
#preorder ⇒ Object
True if this item is on pre-order
71 72 73 |
# File 'lib/ultracart_api/models/cart_item.rb', line 71 def preorder @preorder end |
#quantity ⇒ Object
quantity
74 75 76 |
# File 'lib/ultracart_api/models/cart_item.rb', line 74 def quantity @quantity end |
#schedules ⇒ Object
Customer selectable auto order schedules
77 78 79 |
# File 'lib/ultracart_api/models/cart_item.rb', line 77 def schedules @schedules end |
#total_cost ⇒ Object
Returns the value of attribute total_cost.
79 80 81 |
# File 'lib/ultracart_api/models/cart_item.rb', line 79 def total_cost @total_cost end |
#total_cost_with_discount ⇒ Object
Returns the value of attribute total_cost_with_discount.
81 82 83 |
# File 'lib/ultracart_api/models/cart_item.rb', line 81 def total_cost_with_discount @total_cost_with_discount end |
#unit_cost ⇒ Object
Returns the value of attribute unit_cost.
83 84 85 |
# File 'lib/ultracart_api/models/cart_item.rb', line 83 def unit_cost @unit_cost end |
#unit_cost_with_discount ⇒ Object
Returns the value of attribute unit_cost_with_discount.
85 86 87 |
# File 'lib/ultracart_api/models/cart_item.rb', line 85 def unit_cost_with_discount @unit_cost_with_discount end |
#upsell ⇒ Object
True if this item was added to the cart as part of an upsell
88 89 90 |
# File 'lib/ultracart_api/models/cart_item.rb', line 88 def upsell @upsell end |
#variations ⇒ Object
Variations
91 92 93 |
# File 'lib/ultracart_api/models/cart_item.rb', line 91 def variations @variations end |
#view_url ⇒ Object
URL to view the product on the site
94 95 96 |
# File 'lib/ultracart_api/models/cart_item.rb', line 94 def view_url @view_url end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/ultracart_api/models/cart_item.rb', line 97 def self.attribute_map { :'arbitrary_unit_cost' => :'arbitrary_unit_cost', :'attributes' => :'attributes', :'auto_order_schedule' => :'auto_order_schedule', :'default_image_url' => :'default_image_url', :'default_thumbnail_url' => :'default_thumbnail_url', :'description' => :'description', :'discount' => :'discount', :'extended_description' => :'extended_description', :'item_id' => :'item_id', :'item_oid' => :'item_oid', :'kit' => :'kit', :'kit_component_options' => :'kit_component_options', :'manufacturer_suggested_retail_price' => :'manufacturer_suggested_retail_price', :'maximum_quantity' => :'maximum_quantity', :'minimum_quantity' => :'minimum_quantity', :'multimedia' => :'multimedia', :'options' => :'options', :'phsyical' => :'phsyical', :'position' => :'position', :'preorder' => :'preorder', :'quantity' => :'quantity', :'schedules' => :'schedules', :'total_cost' => :'total_cost', :'total_cost_with_discount' => :'total_cost_with_discount', :'unit_cost' => :'unit_cost', :'unit_cost_with_discount' => :'unit_cost_with_discount', :'upsell' => :'upsell', :'variations' => :'variations', :'view_url' => :'view_url' } end |
.swagger_types ⇒ Object
Attribute type mapping.
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 |
# File 'lib/ultracart_api/models/cart_item.rb', line 132 def self.swagger_types { :'arbitrary_unit_cost' => :'Currency', :'attributes' => :'Array<CartItemAttribute>', :'auto_order_schedule' => :'String', :'default_image_url' => :'String', :'default_thumbnail_url' => :'String', :'description' => :'String', :'discount' => :'Currency', :'extended_description' => :'String', :'item_id' => :'String', :'item_oid' => :'Integer', :'kit' => :'BOOLEAN', :'kit_component_options' => :'Array<CartKitComponentOption>', :'manufacturer_suggested_retail_price' => :'Currency', :'maximum_quantity' => :'Float', :'minimum_quantity' => :'Float', :'multimedia' => :'Array<CartItemMultimedia>', :'options' => :'Array<CartItemOption>', :'phsyical' => :'CartItemPhysical', :'position' => :'Integer', :'preorder' => :'BOOLEAN', :'quantity' => :'Float', :'schedules' => :'Array<String>', :'total_cost' => :'Currency', :'total_cost_with_discount' => :'Currency', :'unit_cost' => :'Currency', :'unit_cost_with_discount' => :'Currency', :'upsell' => :'BOOLEAN', :'variations' => :'Array<CartItemVariationSelection>', :'view_url' => :'String' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/ultracart_api/models/cart_item.rb', line 318 def ==(o) return true if self.equal?(o) self.class == o.class && arbitrary_unit_cost == o.arbitrary_unit_cost && attributes == o.attributes && auto_order_schedule == o.auto_order_schedule && default_image_url == o.default_image_url && default_thumbnail_url == o.default_thumbnail_url && description == o.description && discount == o.discount && extended_description == o.extended_description && item_id == o.item_id && item_oid == o.item_oid && kit == o.kit && == o. && manufacturer_suggested_retail_price == o.manufacturer_suggested_retail_price && maximum_quantity == o.maximum_quantity && minimum_quantity == o.minimum_quantity && multimedia == o.multimedia && == o. && phsyical == o.phsyical && position == o.position && preorder == o.preorder && quantity == o.quantity && schedules == o.schedules && total_cost == o.total_cost && total_cost_with_discount == o.total_cost_with_discount && unit_cost == o.unit_cost && unit_cost_with_discount == o.unit_cost_with_discount && upsell == o.upsell && variations == o.variations && view_url == o.view_url end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/ultracart_api/models/cart_item.rb', line 388 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = UltracartClient.const_get(type).new temp_model.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
454 455 456 457 458 459 460 461 462 463 464 465 466 |
# File 'lib/ultracart_api/models/cart_item.rb', line 454 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/ultracart_api/models/cart_item.rb', line 367 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end |
#eql?(o) ⇒ Boolean
354 355 356 |
# File 'lib/ultracart_api/models/cart_item.rb', line 354 def eql?(o) self == o end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
360 361 362 |
# File 'lib/ultracart_api/models/cart_item.rb', line 360 def hash [arbitrary_unit_cost, attributes, auto_order_schedule, default_image_url, default_thumbnail_url, description, discount, extended_description, item_id, item_oid, kit, , manufacturer_suggested_retail_price, maximum_quantity, minimum_quantity, multimedia, , phsyical, position, preorder, quantity, schedules, total_cost, total_cost_with_discount, unit_cost, unit_cost_with_discount, upsell, variations, view_url].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
305 306 307 308 |
# File 'lib/ultracart_api/models/cart_item.rb', line 305 def list_invalid_properties invalid_properties = Array.new invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
434 435 436 |
# File 'lib/ultracart_api/models/cart_item.rb', line 434 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
440 441 442 443 444 445 446 447 448 |
# File 'lib/ultracart_api/models/cart_item.rb', line 440 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
428 429 430 |
# File 'lib/ultracart_api/models/cart_item.rb', line 428 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
312 313 314 |
# File 'lib/ultracart_api/models/cart_item.rb', line 312 def valid? true end |