Class: NewStoreApi::SalesOrderGiftWrapping

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/sales_order_gift_wrapping.rb

Overview

Gift wrapping information. This field is not required and will not be present if gift wrapping is not applicable for the order

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(price = nil, message = SKIP, tax_lines = SKIP) ⇒ SalesOrderGiftWrapping

Returns a new instance of SalesOrderGiftWrapping.



47
48
49
50
51
# File 'lib/new_store_api/models/sales_order_gift_wrapping.rb', line 47

def initialize(price = nil, message = SKIP, tax_lines = SKIP)
  @message = message unless message == SKIP
  @price = price
  @tax_lines = tax_lines unless tax_lines == SKIP
end

Instance Attribute Details

#messageString

Personalised message to be printing on the gift wrapper.

Returns:

  • (String)


15
16
17
# File 'lib/new_store_api/models/sales_order_gift_wrapping.rb', line 15

def message
  @message
end

#pricePrice1

Personalised message to be printing on the gift wrapper.

Returns:



19
20
21
# File 'lib/new_store_api/models/sales_order_gift_wrapping.rb', line 19

def price
  @price
end

#tax_linesArray[SalesOrderTaxLine]

Detailed tax information.

Returns:



23
24
25
# File 'lib/new_store_api/models/sales_order_gift_wrapping.rb', line 23

def tax_lines
  @tax_lines
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/new_store_api/models/sales_order_gift_wrapping.rb', line 54

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  price = Price1.from_hash(hash['price']) if hash['price']
  message = hash.key?('message') ? hash['message'] : 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 << (SalesOrderTaxLine.from_hash(structure) if structure)
    end
  end

  tax_lines = SKIP unless hash.key?('tax_lines')

  # Create object from extracted values.
  SalesOrderGiftWrapping.new(price,
                             message,
                             tax_lines)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
# File 'lib/new_store_api/models/sales_order_gift_wrapping.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['message'] = 'message'
  @_hash['price'] = 'price'
  @_hash['tax_lines'] = 'tax_lines'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/new_store_api/models/sales_order_gift_wrapping.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
38
39
40
# File 'lib/new_store_api/models/sales_order_gift_wrapping.rb', line 35

def self.optionals
  %w[
    message
    tax_lines
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



84
85
86
87
88
# File 'lib/new_store_api/models/sales_order_gift_wrapping.rb', line 84

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} message: #{@message.inspect}, price: #{@price.inspect}, tax_lines:"\
  " #{@tax_lines.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



78
79
80
81
# File 'lib/new_store_api/models/sales_order_gift_wrapping.rb', line 78

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} message: #{@message}, price: #{@price}, tax_lines: #{@tax_lines}>"
end