Class: NewStoreApi::GiftWrapping1
- Defined in:
- lib/new_store_api/models/gift_wrapping1.rb
Overview
Indicates if gift wrapping option was selected for the order. Only information from the first item (message and price) will be taken into account.
Instance Attribute Summary collapse
-
#item_price ⇒ Float
Price of the item, including taxes or not, depending on the value of the
price_methodproperty. -
#item_tax_lines ⇒ Array[InjectedOrderItemTaxLine]
Describes the taxes applied to the item.
-
#message ⇒ String
Message to be attached to the gift-wrapped order.
-
#tax_class ⇒ String
Tax classification identifier for the line item.
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(item_price = SKIP, item_tax_lines = SKIP, message = SKIP, tax_class = SKIP) ⇒ GiftWrapping1
constructor
A new instance of GiftWrapping1.
-
#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(item_price = SKIP, item_tax_lines = SKIP, message = SKIP, tax_class = SKIP) ⇒ GiftWrapping1
Returns a new instance of GiftWrapping1.
57 58 59 60 61 62 63 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 57 def initialize(item_price = SKIP, item_tax_lines = SKIP, = SKIP, tax_class = SKIP) @item_price = item_price unless item_price == SKIP @item_tax_lines = item_tax_lines unless item_tax_lines == SKIP @message = unless == SKIP @tax_class = tax_class unless tax_class == SKIP end |
Instance Attribute Details
#item_price ⇒ Float
Price of the item, including taxes or not, depending on the value of the
price_method property.
17 18 19 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 17 def item_price @item_price end |
#item_tax_lines ⇒ Array[InjectedOrderItemTaxLine]
Describes the taxes applied to the item.
21 22 23 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 21 def item_tax_lines @item_tax_lines end |
#message ⇒ String
Message to be attached to the gift-wrapped order. Its length is configurable per tenant.
26 27 28 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 26 def @message end |
#tax_class ⇒ String
Tax classification identifier for the line item
30 31 32 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 30 def tax_class @tax_class end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 66 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. item_price = hash.key?('item_price') ? hash['item_price'] : SKIP # Parameter is an array, so we need to iterate through it item_tax_lines = nil unless hash['item_tax_lines'].nil? item_tax_lines = [] hash['item_tax_lines'].each do |structure| item_tax_lines << (InjectedOrderItemTaxLine.from_hash(structure) if structure) end end item_tax_lines = SKIP unless hash.key?('item_tax_lines') = hash.key?('message') ? hash['message'] : SKIP tax_class = hash.key?('tax_class') ? hash['tax_class'] : SKIP # Create object from extracted values. GiftWrapping1.new(item_price, item_tax_lines, , tax_class) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['item_price'] = 'item_price' @_hash['item_tax_lines'] = 'item_tax_lines' @_hash['message'] = 'message' @_hash['tax_class'] = 'tax_class' @_hash end |
.nullables ⇒ Object
An array for nullable fields
53 54 55 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 53 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
43 44 45 46 47 48 49 50 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 43 def self.optionals %w[ item_price item_tax_lines message tax_class ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
93 94 95 96 97 98 99 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 93 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
109 110 111 112 113 114 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 109 def inspect class_name = self.class.name.split('::').last "<#{class_name} item_price: #{@item_price.inspect}, item_tax_lines:"\ " #{@item_tax_lines.inspect}, message: #{@message.inspect}, tax_class:"\ " #{@tax_class.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
102 103 104 105 106 |
# File 'lib/new_store_api/models/gift_wrapping1.rb', line 102 def to_s class_name = self.class.name.split('::').last "<#{class_name} item_price: #{@item_price}, item_tax_lines: #{@item_tax_lines}, message:"\ " #{@message}, tax_class: #{@tax_class}>" end |