Class: NewStoreApi::SalesOrderPrice1

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

Overview

The response for retrieving price information.

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(base = nil, discount = nil, gross = nil, net = nil, tax = nil) ⇒ SalesOrderPrice1

Returns a new instance of SalesOrderPrice1.



53
54
55
56
57
58
59
60
# File 'lib/new_store_api/models/sales_order_price1.rb', line 53

def initialize(base = nil, discount = nil, gross = nil, net = nil,
               tax = nil)
  @base = base
  @discount = discount
  @gross = gross
  @net = net
  @tax = tax
end

Instance Attribute Details

#baseFloat

Price of the item that contains the catalog price or the overridden price.

Returns:

  • (Float)


14
15
16
# File 'lib/new_store_api/models/sales_order_price1.rb', line 14

def base
  @base
end

#discountFloat

The applied discount to the item.

Returns:

  • (Float)


18
19
20
# File 'lib/new_store_api/models/sales_order_price1.rb', line 18

def discount
  @discount
end

#grossFloat

The gross price of the item.

Returns:

  • (Float)


22
23
24
# File 'lib/new_store_api/models/sales_order_price1.rb', line 22

def gross
  @gross
end

#netFloat

The net price of the item.

Returns:

  • (Float)


26
27
28
# File 'lib/new_store_api/models/sales_order_price1.rb', line 26

def net
  @net
end

#taxFloat

The taxes of the item.

Returns:

  • (Float)


30
31
32
# File 'lib/new_store_api/models/sales_order_price1.rb', line 30

def tax
  @tax
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/new_store_api/models/sales_order_price1.rb', line 63

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  base = hash.key?('base') ? hash['base'] : nil
  discount = hash.key?('discount') ? hash['discount'] : nil
  gross = hash.key?('gross') ? hash['gross'] : nil
  net = hash.key?('net') ? hash['net'] : nil
  tax = hash.key?('tax') ? hash['tax'] : nil

  # Create object from extracted values.
  SalesOrderPrice1.new(base,
                       discount,
                       gross,
                       net,
                       tax)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/new_store_api/models/sales_order_price1.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['base'] = 'base'
  @_hash['discount'] = 'discount'
  @_hash['gross'] = 'gross'
  @_hash['net'] = 'net'
  @_hash['tax'] = 'tax'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/new_store_api/models/sales_order_price1.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
# File 'lib/new_store_api/models/sales_order_price1.rb', line 44

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



83
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
112
113
# File 'lib/new_store_api/models/sales_order_price1.rb', line 83

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.base,
                            ->(val) { val.instance_of? Float }) and
        APIHelper.valid_type?(value.discount,
                              ->(val) { val.instance_of? Float }) and
        APIHelper.valid_type?(value.gross,
                              ->(val) { val.instance_of? Float }) and
        APIHelper.valid_type?(value.net,
                              ->(val) { val.instance_of? Float }) and
        APIHelper.valid_type?(value.tax,
                              ->(val) { val.instance_of? Float })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['base'],
                          ->(val) { val.instance_of? Float }) and
      APIHelper.valid_type?(value['discount'],
                            ->(val) { val.instance_of? Float }) and
      APIHelper.valid_type?(value['gross'],
                            ->(val) { val.instance_of? Float }) and
      APIHelper.valid_type?(value['net'],
                            ->(val) { val.instance_of? Float }) and
      APIHelper.valid_type?(value['tax'],
                            ->(val) { val.instance_of? Float })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



123
124
125
126
127
# File 'lib/new_store_api/models/sales_order_price1.rb', line 123

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} base: #{@base.inspect}, discount: #{@discount.inspect}, gross:"\
  " #{@gross.inspect}, net: #{@net.inspect}, tax: #{@tax.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



116
117
118
119
120
# File 'lib/new_store_api/models/sales_order_price1.rb', line 116

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} base: #{@base}, discount: #{@discount}, gross: #{@gross}, net: #{@net},"\
  " tax: #{@tax}>"
end