Class: VisaAcceptanceMergedSpec::Order
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- VisaAcceptanceMergedSpec::Order
- Defined in:
- lib/visa_acceptance_merged_spec/models/order.rb
Overview
Order Model.
Instance Attribute Summary collapse
-
#currency ⇒ String
Currency used for the order.
-
#gift_wrap_amount ⇒ String
Amount being charged as gift wrap fee.
-
#handling_amount ⇒ String
Aggregate handling charges for the transaction.
-
#insurance_amount ⇒ String
Amount being charged for the insurance fee.
-
#shipping_amount ⇒ String
Aggregate shipping charges for the transaction If this amount has changed since the initial sessions request, you must include the new value in the order request.
-
#shipping_discount_amount ⇒ String
Shipping discount amount for the transaction.
-
#sub_total_amount ⇒ String
Shipping discount amount for the transaction.
-
#tax_amount ⇒ String
Total tax amount.
-
#total_amount ⇒ String
Grand total for the order.
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(total_amount: SKIP, currency: SKIP, sub_total_amount: SKIP, handling_amount: SKIP, shipping_amount: SKIP, shipping_discount_amount: SKIP, tax_amount: SKIP, insurance_amount: SKIP, gift_wrap_amount: SKIP, additional_properties: nil) ⇒ Order
constructor
A new instance of Order.
-
#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(total_amount: SKIP, currency: SKIP, sub_total_amount: SKIP, handling_amount: SKIP, shipping_amount: SKIP, shipping_discount_amount: SKIP, tax_amount: SKIP, insurance_amount: SKIP, gift_wrap_amount: SKIP, additional_properties: nil) ⇒ Order
Returns a new instance of Order.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 105 def initialize(total_amount: SKIP, currency: SKIP, sub_total_amount: SKIP, handling_amount: SKIP, shipping_amount: SKIP, shipping_discount_amount: SKIP, tax_amount: SKIP, insurance_amount: SKIP, gift_wrap_amount: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @total_amount = total_amount unless total_amount == SKIP @currency = currency unless currency == SKIP @sub_total_amount = sub_total_amount unless sub_total_amount == SKIP @handling_amount = handling_amount unless handling_amount == SKIP @shipping_amount = shipping_amount unless shipping_amount == SKIP @shipping_discount_amount = shipping_discount_amount unless shipping_discount_amount == SKIP @tax_amount = tax_amount unless tax_amount == SKIP @insurance_amount = insurance_amount unless insurance_amount == SKIP @gift_wrap_amount = gift_wrap_amount unless gift_wrap_amount == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#currency ⇒ String
Currency used for the order
21 22 23 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 21 def currency @currency end |
#gift_wrap_amount ⇒ String
Amount being charged as gift wrap fee.
68 69 70 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 68 def gift_wrap_amount @gift_wrap_amount end |
#handling_amount ⇒ String
Aggregate handling charges for the transaction. If this amount has changed since the initial sessions request, you must include the new value in the order request. You must also include all additional amount fields that apply to the order and ensure the total amount equals the purchaseTotals_grandTotalAmount value.
37 38 39 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 37 def handling_amount @handling_amount end |
#insurance_amount ⇒ String
Amount being charged for the insurance fee. Only supported when the payment_method is set to paypal.
64 65 66 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 64 def insurance_amount @insurance_amount end |
#shipping_amount ⇒ String
Aggregate shipping charges for the transaction If this amount has changed since the initial sessions request, you must include the new value in the order request. You must also include all additional amount fields that apply to the order and ensure the total amount equals the purchaseTotals_grandTotalAmount value.
45 46 47 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 45 def shipping_amount @shipping_amount end |
#shipping_discount_amount ⇒ String
Shipping discount amount for the transaction. If this amount has changed since the initial sessions request, you must include the new value in the order request. You must also include all additional amount fields that apply to the order and ensure the total amount equals the purchaseTotals_grandTotalAmount value.
53 54 55 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 53 def shipping_discount_amount @shipping_discount_amount end |
#sub_total_amount ⇒ String
Shipping discount amount for the transaction. If this amount has changed since the initial sessions request, you must include the new value in the order request. You must also include all additional amount fields that apply to the order and ensure the total amount equals the purchaseTotals_grandTotalAmount value.
29 30 31 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 29 def sub_total_amount @sub_total_amount end |
#tax_amount ⇒ String
Total tax amount. When the purchaseTotals_ taxAmount and ap_subtotalAmount fields are included in the request, do not include the tax amount as part of the subtotal amount calculation.
59 60 61 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 59 def tax_amount @tax_amount end |
#total_amount ⇒ String
Grand total for the order. This value cannot be negative. You can include a decimal point (.), but you cannot include any other special characters. Visa Acceptance truncates the amount to the correct number of decimal places
17 18 19 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 17 def total_amount @total_amount end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 126 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. total_amount = hash.key?('totalAmount') ? hash['totalAmount'] : SKIP currency = hash.key?('currency') ? hash['currency'] : SKIP sub_total_amount = hash.key?('subTotalAmount') ? hash['subTotalAmount'] : SKIP handling_amount = hash.key?('handlingAmount') ? hash['handlingAmount'] : SKIP shipping_amount = hash.key?('shippingAmount') ? hash['shippingAmount'] : SKIP shipping_discount_amount = hash.key?('shippingDiscountAmount') ? hash['shippingDiscountAmount'] : SKIP tax_amount = hash.key?('taxAmount') ? hash['taxAmount'] : SKIP insurance_amount = hash.key?('insuranceAmount') ? hash['insuranceAmount'] : SKIP gift_wrap_amount = hash.key?('giftWrapAmount') ? hash['giftWrapAmount'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. Order.new(total_amount: total_amount, currency: currency, sub_total_amount: sub_total_amount, handling_amount: handling_amount, shipping_amount: shipping_amount, shipping_discount_amount: shipping_discount_amount, tax_amount: tax_amount, insurance_amount: insurance_amount, gift_wrap_amount: gift_wrap_amount, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 71 def self.names @_hash = {} if @_hash.nil? @_hash['total_amount'] = 'totalAmount' @_hash['currency'] = 'currency' @_hash['sub_total_amount'] = 'subTotalAmount' @_hash['handling_amount'] = 'handlingAmount' @_hash['shipping_amount'] = 'shippingAmount' @_hash['shipping_discount_amount'] = 'shippingDiscountAmount' @_hash['tax_amount'] = 'taxAmount' @_hash['insurance_amount'] = 'insuranceAmount' @_hash['gift_wrap_amount'] = 'giftWrapAmount' @_hash end |
.nullables ⇒ Object
An array for nullable fields
101 102 103 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 101 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 86 def self.optionals %w[ total_amount currency sub_total_amount handling_amount shipping_amount shipping_discount_amount tax_amount insurance_amount gift_wrap_amount ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
177 178 179 180 181 182 183 184 185 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 177 def inspect class_name = self.class.name.split('::').last "<#{class_name} total_amount: #{@total_amount.inspect}, currency: #{@currency.inspect},"\ " sub_total_amount: #{@sub_total_amount.inspect}, handling_amount:"\ " #{@handling_amount.inspect}, shipping_amount: #{@shipping_amount.inspect},"\ " shipping_discount_amount: #{@shipping_discount_amount.inspect}, tax_amount:"\ " #{@tax_amount.inspect}, insurance_amount: #{@insurance_amount.inspect}, gift_wrap_amount:"\ " #{@gift_wrap_amount.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
167 168 169 170 171 172 173 174 |
# File 'lib/visa_acceptance_merged_spec/models/order.rb', line 167 def to_s class_name = self.class.name.split('::').last "<#{class_name} total_amount: #{@total_amount}, currency: #{@currency}, sub_total_amount:"\ " #{@sub_total_amount}, handling_amount: #{@handling_amount}, shipping_amount:"\ " #{@shipping_amount}, shipping_discount_amount: #{@shipping_discount_amount}, tax_amount:"\ " #{@tax_amount}, insurance_amount: #{@insurance_amount}, gift_wrap_amount:"\ " #{@gift_wrap_amount}, additional_properties: #{@additional_properties}>" end |