Class: NewStoreApi::SalesOrderTotals
- Defined in:
- lib/new_store_api/models/sales_order_totals.rb
Overview
SalesOrderTotals Model.
Instance Attribute Summary collapse
-
#discount ⇒ Float
The applied discount to the entire order.
-
#gift_wrapping ⇒ Float
The amount paid for gift wrapping.
-
#gross ⇒ Float
The gross price of the order, is the sum of all product item gross prices.
-
#net ⇒ Float
The net price of the order, is the sum of all product item net prices.
-
#shipping ⇒ Float
The shipping amount.
-
#tax ⇒ Float
The taxes of the order, is the sum of all product item taxes.
-
#total ⇒ Float
The total amount that the customer paid including shipping costs, taxes, gift_wrapping and any discounts.
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(discount = SKIP, gift_wrapping = SKIP, gross = SKIP, net = SKIP, shipping = SKIP, tax = SKIP, total = SKIP) ⇒ SalesOrderTotals
constructor
A new instance of SalesOrderTotals.
-
#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(discount = SKIP, gift_wrapping = SKIP, gross = SKIP, net = SKIP, shipping = SKIP, tax = SKIP, total = SKIP) ⇒ SalesOrderTotals
Returns a new instance of SalesOrderTotals.
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 72 def initialize(discount = SKIP, gift_wrapping = SKIP, gross = SKIP, net = SKIP, shipping = SKIP, tax = SKIP, total = SKIP) @discount = discount unless discount == SKIP @gift_wrapping = gift_wrapping unless gift_wrapping == SKIP @gross = gross unless gross == SKIP @net = net unless net == SKIP @shipping = shipping unless shipping == SKIP @tax = tax unless tax == SKIP @total = total unless total == SKIP end |
Instance Attribute Details
#discount ⇒ Float
The applied discount to the entire order.
14 15 16 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 14 def discount @discount end |
#gift_wrapping ⇒ Float
The amount paid for gift wrapping.
18 19 20 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 18 def gift_wrapping @gift_wrapping end |
#gross ⇒ Float
The gross price of the order, is the sum of all product item gross prices.
22 23 24 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 22 def gross @gross end |
#net ⇒ Float
The net price of the order, is the sum of all product item net prices.
26 27 28 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 26 def net @net end |
#shipping ⇒ Float
The shipping amount.
30 31 32 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 30 def shipping @shipping end |
#tax ⇒ Float
The taxes of the order, is the sum of all product item taxes.
34 35 36 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 34 def tax @tax end |
#total ⇒ Float
The total amount that the customer paid including shipping costs, taxes, gift_wrapping and any discounts.
39 40 41 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 39 def total @total 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 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 84 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. discount = hash.key?('discount') ? hash['discount'] : SKIP gift_wrapping = hash.key?('gift_wrapping') ? hash['gift_wrapping'] : SKIP gross = hash.key?('gross') ? hash['gross'] : SKIP net = hash.key?('net') ? hash['net'] : SKIP shipping = hash.key?('shipping') ? hash['shipping'] : SKIP tax = hash.key?('tax') ? hash['tax'] : SKIP total = hash.key?('total') ? hash['total'] : SKIP # Create object from extracted values. SalesOrderTotals.new(discount, gift_wrapping, gross, net, shipping, tax, total) end |
.names ⇒ Object
A mapping from model property names to API property names.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 42 def self.names @_hash = {} if @_hash.nil? @_hash['discount'] = 'discount' @_hash['gift_wrapping'] = 'gift_wrapping' @_hash['gross'] = 'gross' @_hash['net'] = 'net' @_hash['shipping'] = 'shipping' @_hash['tax'] = 'tax' @_hash['total'] = 'total' @_hash end |
.nullables ⇒ Object
An array for nullable fields
68 69 70 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 68 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 55 def self.optionals %w[ discount gift_wrapping gross net shipping tax total ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
114 115 116 117 118 119 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 114 def inspect class_name = self.class.name.split('::').last "<#{class_name} discount: #{@discount.inspect}, gift_wrapping: #{@gift_wrapping.inspect},"\ " gross: #{@gross.inspect}, net: #{@net.inspect}, shipping: #{@shipping.inspect}, tax:"\ " #{@tax.inspect}, total: #{@total.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
107 108 109 110 111 |
# File 'lib/new_store_api/models/sales_order_totals.rb', line 107 def to_s class_name = self.class.name.split('::').last "<#{class_name} discount: #{@discount}, gift_wrapping: #{@gift_wrapping}, gross: #{@gross},"\ " net: #{@net}, shipping: #{@shipping}, tax: #{@tax}, total: #{@total}>" end |