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.
-
#properties ⇒ Object
Properties associated with the item.
-
#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
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_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 ⇒ Integer
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
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 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/ultracart_api/models/cart_item.rb', line 185 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::CartItem` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::CartItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'arbitrary_unit_cost') self.arbitrary_unit_cost = attributes[:'arbitrary_unit_cost'] end if attributes.key?(:'attributes') if (value = attributes[:'attributes']).is_a?(Array) self.attributes = value end end if attributes.key?(:'auto_order_schedule') self.auto_order_schedule = attributes[:'auto_order_schedule'] end if attributes.key?(:'default_image_url') self.default_image_url = attributes[:'default_image_url'] end if attributes.key?(:'default_thumbnail_url') self.default_thumbnail_url = attributes[:'default_thumbnail_url'] end if attributes.key?(:'description') self.description = attributes[:'description'] end if attributes.key?(:'discount') self.discount = attributes[:'discount'] end if attributes.key?(:'extended_description') self.extended_description = attributes[:'extended_description'] end if attributes.key?(:'item_id') self.item_id = attributes[:'item_id'] end if attributes.key?(:'item_oid') self.item_oid = attributes[:'item_oid'] end if attributes.key?(:'kit') self.kit = attributes[:'kit'] end if attributes.key?(:'kit_component_options') if (value = attributes[:'kit_component_options']).is_a?(Array) self. = value end end if attributes.key?(:'manufacturer_suggested_retail_price') self.manufacturer_suggested_retail_price = attributes[:'manufacturer_suggested_retail_price'] end if attributes.key?(:'maximum_quantity') self.maximum_quantity = attributes[:'maximum_quantity'] end if attributes.key?(:'minimum_quantity') self.minimum_quantity = attributes[:'minimum_quantity'] end if attributes.key?(:'multimedia') if (value = attributes[:'multimedia']).is_a?(Array) self.multimedia = value end end if attributes.key?(:'options') if (value = attributes[:'options']).is_a?(Array) self. = value end end if attributes.key?(:'phsyical') self.phsyical = attributes[:'phsyical'] end if attributes.key?(:'position') self.position = attributes[:'position'] end if attributes.key?(:'preorder') self.preorder = attributes[:'preorder'] end if attributes.key?(:'properties') if (value = attributes[:'properties']).is_a?(Array) self.properties = value end end if attributes.key?(:'quantity') self.quantity = attributes[:'quantity'] end if attributes.key?(:'schedules') if (value = attributes[:'schedules']).is_a?(Array) self.schedules = value end end if attributes.key?(:'total_cost') self.total_cost = attributes[:'total_cost'] end if attributes.key?(:'total_cost_with_discount') self.total_cost_with_discount = attributes[:'total_cost_with_discount'] end if attributes.key?(:'unit_cost') self.unit_cost = attributes[:'unit_cost'] end if attributes.key?(:'unit_cost_with_discount') self.unit_cost_with_discount = attributes[:'unit_cost_with_discount'] end if attributes.key?(:'upsell') self.upsell = attributes[:'upsell'] end if attributes.key?(:'variations') if (value = attributes[:'variations']).is_a?(Array) self.variations = value end end if attributes.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.
18 19 20 |
# File 'lib/ultracart_api/models/cart_item.rb', line 18 def arbitrary_unit_cost @arbitrary_unit_cost end |
#attributes ⇒ Object
Attributes
21 22 23 |
# File 'lib/ultracart_api/models/cart_item.rb', line 21 def attributes @attributes end |
#auto_order_schedule ⇒ Object
Auto order schedule the customer selected
24 25 26 |
# File 'lib/ultracart_api/models/cart_item.rb', line 24 def auto_order_schedule @auto_order_schedule end |
#default_image_url ⇒ Object
URL to the default multimedia image
27 28 29 |
# File 'lib/ultracart_api/models/cart_item.rb', line 27 def default_image_url @default_image_url end |
#default_thumbnail_url ⇒ Object
URL to the default multimedia thumbnail
30 31 32 |
# File 'lib/ultracart_api/models/cart_item.rb', line 30 def default_thumbnail_url @default_thumbnail_url end |
#description ⇒ Object
Description of the item
33 34 35 |
# File 'lib/ultracart_api/models/cart_item.rb', line 33 def description @description end |
#discount ⇒ Object
Returns the value of attribute discount.
35 36 37 |
# File 'lib/ultracart_api/models/cart_item.rb', line 35 def discount @discount end |
#extended_description ⇒ Object
Extended description of the item
38 39 40 |
# File 'lib/ultracart_api/models/cart_item.rb', line 38 def extended_description @extended_description end |
#item_id ⇒ Object
Item ID
41 42 43 |
# File 'lib/ultracart_api/models/cart_item.rb', line 41 def item_id @item_id end |
#item_oid ⇒ Object
Item object identifier
44 45 46 |
# File 'lib/ultracart_api/models/cart_item.rb', line 44 def item_oid @item_oid end |
#kit ⇒ Object
True if this item is a kit
47 48 49 |
# File 'lib/ultracart_api/models/cart_item.rb', line 47 def kit @kit end |
#kit_component_options ⇒ Object
Options associated with the kit components
50 51 52 |
# File 'lib/ultracart_api/models/cart_item.rb', line 50 def end |
#manufacturer_suggested_retail_price ⇒ Object
Returns the value of attribute manufacturer_suggested_retail_price.
52 53 54 |
# File 'lib/ultracart_api/models/cart_item.rb', line 52 def manufacturer_suggested_retail_price @manufacturer_suggested_retail_price end |
#maximum_quantity ⇒ Object
Maximum quantity the customer can purchase
55 56 57 |
# File 'lib/ultracart_api/models/cart_item.rb', line 55 def maximum_quantity @maximum_quantity end |
#minimum_quantity ⇒ Object
Minimum quantity the customer can purchase
58 59 60 |
# File 'lib/ultracart_api/models/cart_item.rb', line 58 def minimum_quantity @minimum_quantity end |
#multimedia ⇒ Object
Multimedia
61 62 63 |
# File 'lib/ultracart_api/models/cart_item.rb', line 61 def multimedia @multimedia end |
#options ⇒ Object
Options
64 65 66 |
# File 'lib/ultracart_api/models/cart_item.rb', line 64 def end |
#phsyical ⇒ Object
Returns the value of attribute phsyical.
66 67 68 |
# File 'lib/ultracart_api/models/cart_item.rb', line 66 def phsyical @phsyical end |
#position ⇒ Object
Position of the item in the cart
69 70 71 |
# File 'lib/ultracart_api/models/cart_item.rb', line 69 def position @position end |
#preorder ⇒ Object
True if this item is on pre-order
72 73 74 |
# File 'lib/ultracart_api/models/cart_item.rb', line 72 def preorder @preorder end |
#properties ⇒ Object
Properties associated with the item
75 76 77 |
# File 'lib/ultracart_api/models/cart_item.rb', line 75 def properties @properties end |
#quantity ⇒ Object
quantity
78 79 80 |
# File 'lib/ultracart_api/models/cart_item.rb', line 78 def quantity @quantity end |
#schedules ⇒ Object
Customer selectable auto order schedules
81 82 83 |
# File 'lib/ultracart_api/models/cart_item.rb', line 81 def schedules @schedules end |
#total_cost ⇒ Object
Returns the value of attribute total_cost.
83 84 85 |
# File 'lib/ultracart_api/models/cart_item.rb', line 83 def total_cost @total_cost end |
#total_cost_with_discount ⇒ Object
Returns the value of attribute total_cost_with_discount.
85 86 87 |
# File 'lib/ultracart_api/models/cart_item.rb', line 85 def total_cost_with_discount @total_cost_with_discount end |
#unit_cost ⇒ Object
Returns the value of attribute unit_cost.
87 88 89 |
# File 'lib/ultracart_api/models/cart_item.rb', line 87 def unit_cost @unit_cost end |
#unit_cost_with_discount ⇒ Object
Returns the value of attribute unit_cost_with_discount.
89 90 91 |
# File 'lib/ultracart_api/models/cart_item.rb', line 89 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
92 93 94 |
# File 'lib/ultracart_api/models/cart_item.rb', line 92 def upsell @upsell end |
#variations ⇒ Object
Variations
95 96 97 |
# File 'lib/ultracart_api/models/cart_item.rb', line 95 def variations @variations end |
#view_url ⇒ Object
URL to view the product on the site
98 99 100 |
# File 'lib/ultracart_api/models/cart_item.rb', line 98 def view_url @view_url end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
137 138 139 |
# File 'lib/ultracart_api/models/cart_item.rb', line 137 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
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 130 131 132 133 134 |
# File 'lib/ultracart_api/models/cart_item.rb', line 101 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', :'properties' => :'properties', :'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 |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
398 399 400 |
# File 'lib/ultracart_api/models/cart_item.rb', line 398 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
178 179 180 181 |
# File 'lib/ultracart_api/models/cart_item.rb', line 178 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/ultracart_api/models/cart_item.rb', line 142 def self.openapi_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', :'properties' => :'Array<CartItemProperty>', :'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.
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/ultracart_api/models/cart_item.rb', line 348 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 && properties == o.properties && 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
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
# File 'lib/ultracart_api/models/cart_item.rb', line 429 def _deserialize(type, value) case type.to_sym when :Time Time.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 # models (e.g. Pet) or oneOf klass = UltracartClient.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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
500 501 502 503 504 505 506 507 508 509 510 511 512 |
# File 'lib/ultracart_api/models/cart_item.rb', line 500 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
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/ultracart_api/models/cart_item.rb', line 405 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif 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 end self end |
#eql?(o) ⇒ Boolean
385 386 387 |
# File 'lib/ultracart_api/models/cart_item.rb', line 385 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
391 392 393 |
# File 'lib/ultracart_api/models/cart_item.rb', line 391 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, properties, 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?
335 336 337 338 |
# File 'lib/ultracart_api/models/cart_item.rb', line 335 def list_invalid_properties invalid_properties = Array.new invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
476 477 478 |
# File 'lib/ultracart_api/models/cart_item.rb', line 476 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
482 483 484 485 486 487 488 489 490 491 492 493 494 |
# File 'lib/ultracart_api/models/cart_item.rb', line 482 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
470 471 472 |
# File 'lib/ultracart_api/models/cart_item.rb', line 470 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
342 343 344 |
# File 'lib/ultracart_api/models/cart_item.rb', line 342 def valid? true end |