Class: NewStoreApi::Item7
- Defined in:
- lib/new_store_api/models/item7.rb
Overview
An individual item in the cart.
Instance Attribute Summary collapse
-
#adjustment ⇒ Adjustment
TODO: Write general description for this method.
-
#id ⇒ String
The ID of the item in the cart.
-
#price ⇒ String
The price of the item, accurate to 5 decimal places.
-
#product_categories ⇒ Array[String]
The product categories for which this promotion was applied.
-
#product_id ⇒ String
The Newstore ID of the product.
-
#type ⇒ String
The type of item that the promotion is applied to.
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(id = nil, price = nil, product_categories = nil, product_id = nil, type = nil, adjustment = SKIP) ⇒ Item7
constructor
A new instance of Item7.
-
#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(id = nil, price = nil, product_categories = nil, product_id = nil, type = nil, adjustment = SKIP) ⇒ Item7
Returns a new instance of Item7.
68 69 70 71 72 73 74 75 76 |
# File 'lib/new_store_api/models/item7.rb', line 68 def initialize(id = nil, price = nil, product_categories = nil, product_id = nil, type = nil, adjustment = SKIP) @adjustment = adjustment unless adjustment == SKIP @id = id @price = price @product_categories = product_categories @product_id = product_id @type = type end |
Instance Attribute Details
#adjustment ⇒ Adjustment
TODO: Write general description for this method
14 15 16 |
# File 'lib/new_store_api/models/item7.rb', line 14 def adjustment @adjustment end |
#id ⇒ String
The ID of the item in the cart.
18 19 20 |
# File 'lib/new_store_api/models/item7.rb', line 18 def id @id end |
#price ⇒ String
The price of the item, accurate to 5 decimal places. Should be >= 0
22 23 24 |
# File 'lib/new_store_api/models/item7.rb', line 22 def price @price end |
#product_categories ⇒ Array[String]
The product categories for which this promotion was applied.
26 27 28 |
# File 'lib/new_store_api/models/item7.rb', line 26 def product_categories @product_categories end |
#product_id ⇒ String
The Newstore ID of the product.
30 31 32 |
# File 'lib/new_store_api/models/item7.rb', line 30 def product_id @product_id end |
#type ⇒ String
The type of item that the promotion is applied to. Currently, you can apply automatic promotions to specified products or shipping costs. Automatic promotions can also be applied to merchandise that is chargeable to the customer, but not part of a product catalog to sell for your business, such as coffee to go in the retail store or gift wrap services.
42 43 44 |
# File 'lib/new_store_api/models/item7.rb', line 42 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/new_store_api/models/item7.rb', line 79 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil price = hash.key?('price') ? hash['price'] : nil product_categories = hash.key?('product_categories') ? hash['product_categories'] : nil product_id = hash.key?('product_id') ? hash['product_id'] : nil type = hash.key?('type') ? hash['type'] : nil adjustment = Adjustment.from_hash(hash['adjustment']) if hash['adjustment'] # Create object from extracted values. Item7.new(id, price, product_categories, product_id, type, adjustment) end |
.names ⇒ Object
A mapping from model property names to API property names.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/new_store_api/models/item7.rb', line 45 def self.names @_hash = {} if @_hash.nil? @_hash['adjustment'] = 'adjustment' @_hash['id'] = 'id' @_hash['price'] = 'price' @_hash['product_categories'] = 'product_categories' @_hash['product_id'] = 'product_id' @_hash['type'] = 'type' @_hash end |
.nullables ⇒ Object
An array for nullable fields
64 65 66 |
# File 'lib/new_store_api/models/item7.rb', line 64 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
57 58 59 60 61 |
# File 'lib/new_store_api/models/item7.rb', line 57 def self.optionals %w[ adjustment ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
108 109 110 111 112 113 |
# File 'lib/new_store_api/models/item7.rb', line 108 def inspect class_name = self.class.name.split('::').last "<#{class_name} adjustment: #{@adjustment.inspect}, id: #{@id.inspect}, price:"\ " #{@price.inspect}, product_categories: #{@product_categories.inspect}, product_id:"\ " #{@product_id.inspect}, type: #{@type.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
101 102 103 104 105 |
# File 'lib/new_store_api/models/item7.rb', line 101 def to_s class_name = self.class.name.split('::').last "<#{class_name} adjustment: #{@adjustment}, id: #{@id}, price: #{@price},"\ " product_categories: #{@product_categories}, product_id: #{@product_id}, type: #{@type}>" end |