Class: NewStoreApi::GiftWrapping
- Defined in:
- lib/new_store_api/models/gift_wrapping.rb
Overview
A gift wrapping applied to one or more of the order's line items.
Instance Attribute Summary collapse
-
#line_item_ids ⇒ Array[String]
The line items covered by this gift wrapping.
-
#message ⇒ String
Message to attach to the gift wrapping.
-
#price ⇒ Integer
The gift wrapping price, in the currency's minor unit.
-
#price_tax ⇒ Integer
Total tax amount on the gift wrapping price, in the currency's minor unit.
-
#tax_class ⇒ String
Tax classification identifier for the gift wrapping.
-
#tax_lines ⇒ Array[TaxLine]
Optional breakdown of the taxes that make up
price_tax.
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(line_item_ids = nil, message = SKIP, price = 0, price_tax = 0, tax_class = SKIP, tax_lines = SKIP) ⇒ GiftWrapping
constructor
A new instance of GiftWrapping.
-
#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(line_item_ids = nil, message = SKIP, price = 0, price_tax = 0, tax_class = SKIP, tax_lines = SKIP) ⇒ GiftWrapping
Returns a new instance of GiftWrapping.
73 74 75 76 77 78 79 80 81 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 73 def initialize(line_item_ids = nil, = SKIP, price = 0, price_tax = 0, tax_class = SKIP, tax_lines = SKIP) @line_item_ids = line_item_ids @message = unless == SKIP @price = price unless price == SKIP @price_tax = price_tax unless price_tax == SKIP @tax_class = tax_class unless tax_class == SKIP @tax_lines = tax_lines unless tax_lines == SKIP end |
Instance Attribute Details
#line_item_ids ⇒ Array[String]
The line items covered by this gift wrapping. Each value must match a
line_items[].line_item_id in the same order. Partial gift wrapping is
not yet supported: the gift wrapping must cover every line item in the
order.
17 18 19 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 17 def line_item_ids @line_item_ids end |
#message ⇒ String
Message to attach to the gift wrapping. Its maximum length is configurable per tenant.
22 23 24 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 22 def @message end |
#price ⇒ Integer
The gift wrapping price, in the currency's minor unit. With tax_included
pricing this already contains the tax; with tax_excluded pricing the
customer pays price plus price_tax.
28 29 30 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 28 def price @price end |
#price_tax ⇒ Integer
Total tax amount on the gift wrapping price, in the currency's minor unit.
32 33 34 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 32 def price_tax @price_tax end |
#tax_class ⇒ String
Tax classification identifier for the gift wrapping.
36 37 38 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 36 def tax_class @tax_class end |
#tax_lines ⇒ Array[TaxLine]
Optional breakdown of the taxes that make up price_tax.
40 41 42 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 40 def tax_lines @tax_lines end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 84 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. line_item_ids = hash.key?('line_item_ids') ? hash['line_item_ids'] : nil = hash.key?('message') ? hash['message'] : SKIP price = hash['price'] ||= 0 price_tax = hash['price_tax'] ||= 0 tax_class = hash.key?('tax_class') ? hash['tax_class'] : SKIP # Parameter is an array, so we need to iterate through it tax_lines = nil unless hash['tax_lines'].nil? tax_lines = [] hash['tax_lines'].each do |structure| tax_lines << (TaxLine.from_hash(structure) if structure) end end tax_lines = SKIP unless hash.key?('tax_lines') # Create object from extracted values. GiftWrapping.new(line_item_ids, , price, price_tax, tax_class, tax_lines) end |
.names ⇒ Object
A mapping from model property names to API property names.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 43 def self.names @_hash = {} if @_hash.nil? @_hash['line_item_ids'] = 'line_item_ids' @_hash['message'] = 'message' @_hash['price'] = 'price' @_hash['price_tax'] = 'price_tax' @_hash['tax_class'] = 'tax_class' @_hash['tax_lines'] = 'tax_lines' @_hash end |
.nullables ⇒ Object
An array for nullable fields
66 67 68 69 70 71 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 66 def self.nullables %w[ message tax_class ] end |
.optionals ⇒ Object
An array for optional fields
55 56 57 58 59 60 61 62 63 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 55 def self.optionals %w[ message price price_tax tax_class tax_lines ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
121 122 123 124 125 126 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 121 def inspect class_name = self.class.name.split('::').last "<#{class_name} line_item_ids: #{@line_item_ids.inspect}, message: #{@message.inspect},"\ " price: #{@price.inspect}, price_tax: #{@price_tax.inspect}, tax_class:"\ " #{@tax_class.inspect}, tax_lines: #{@tax_lines.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
114 115 116 117 118 |
# File 'lib/new_store_api/models/gift_wrapping.rb', line 114 def to_s class_name = self.class.name.split('::').last "<#{class_name} line_item_ids: #{@line_item_ids}, message: #{@message}, price: #{@price},"\ " price_tax: #{@price_tax}, tax_class: #{@tax_class}, tax_lines: #{@tax_lines}>" end |