Class: CyberSourceMergedSpec::AmountDetails32
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- CyberSourceMergedSpec::AmountDetails32
- Defined in:
- lib/cyber_source_merged_spec/models/amount_details32.rb
Overview
AmountDetails32 Model.
Instance Attribute Summary collapse
-
#currency ⇒ String
Currency used for the order.
-
#discount_amount ⇒ String
Discount amount for the transaction.
-
#duty_amount ⇒ String
Amount being charged as duty amount.
-
#insurance_amount ⇒ String
Amount being charged for the insurance fee.
-
#shipping_amount ⇒ String
Aggregate shipping charges for the transactions.
-
#shipping_discount_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_element(root) ⇒ Object
-
.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, discount_amount: SKIP, shipping_amount: SKIP, shipping_discount_amount: SKIP, tax_amount: SKIP, insurance_amount: SKIP, duty_amount: SKIP, additional_properties: nil) ⇒ AmountDetails32
constructor
A new instance of AmountDetails32.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
- #to_xml_element(doc, root_name) ⇒ 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, discount_amount: SKIP, shipping_amount: SKIP, shipping_discount_amount: SKIP, tax_amount: SKIP, insurance_amount: SKIP, duty_amount: SKIP, additional_properties: nil) ⇒ AmountDetails32
Returns a new instance of AmountDetails32.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 79 def initialize(total_amount: SKIP, currency: SKIP, discount_amount: SKIP, shipping_amount: SKIP, shipping_discount_amount: SKIP, tax_amount: SKIP, insurance_amount: SKIP, duty_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 @discount_amount = discount_amount unless discount_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 @duty_amount = duty_amount unless duty_amount == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#currency ⇒ String
Currency used for the order
20 21 22 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 20 def currency @currency end |
#discount_amount ⇒ String
Discount amount for the transaction.
24 25 26 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 24 def discount_amount @discount_amount end |
#duty_amount ⇒ String
Amount being charged as duty amount.
44 45 46 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 44 def duty_amount @duty_amount end |
#insurance_amount ⇒ String
Amount being charged for the insurance fee.
40 41 42 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 40 def insurance_amount @insurance_amount end |
#shipping_amount ⇒ String
Aggregate shipping charges for the transactions.
28 29 30 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 28 def shipping_amount @shipping_amount end |
#shipping_discount_amount ⇒ String
Shipping discount amount for the transaction.
32 33 34 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 32 def shipping_discount_amount @shipping_discount_amount end |
#tax_amount ⇒ String
Total tax amount.
36 37 38 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 36 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. CyberSource truncates the amount to the correct number of decimal places
16 17 18 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 16 def total_amount @total_amount end |
Class Method Details
.from_element(root) ⇒ Object
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 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 134 def self.from_element(root) total_amount = XmlUtilities.from_element(root, 'totalAmount', String) currency = XmlUtilities.from_element(root, 'currency', String) discount_amount = XmlUtilities.from_element(root, 'discountAmount', String) shipping_amount = XmlUtilities.from_element(root, 'shippingAmount', String) shipping_discount_amount = XmlUtilities.from_element( root, 'shippingDiscountAmount', String ) tax_amount = XmlUtilities.from_element(root, 'taxAmount', String) insurance_amount = XmlUtilities.from_element(root, 'insuranceAmount', String) duty_amount = XmlUtilities.from_element(root, 'dutyAmount', String) new(total_amount: total_amount, currency: currency, discount_amount: discount_amount, shipping_amount: shipping_amount, shipping_discount_amount: shipping_discount_amount, tax_amount: tax_amount, insurance_amount: insurance_amount, duty_amount: duty_amount, additional_properties: additional_properties) end |
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 98 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 discount_amount = hash.key?('discountAmount') ? hash['discountAmount'] : 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 duty_amount = hash.key?('dutyAmount') ? hash['dutyAmount'] : 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. AmountDetails32.new(total_amount: total_amount, currency: currency, discount_amount: discount_amount, shipping_amount: shipping_amount, shipping_discount_amount: shipping_discount_amount, tax_amount: tax_amount, insurance_amount: insurance_amount, duty_amount: duty_amount, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 47 def self.names @_hash = {} if @_hash.nil? @_hash['total_amount'] = 'totalAmount' @_hash['currency'] = 'currency' @_hash['discount_amount'] = 'discountAmount' @_hash['shipping_amount'] = 'shippingAmount' @_hash['shipping_discount_amount'] = 'shippingDiscountAmount' @_hash['tax_amount'] = 'taxAmount' @_hash['insurance_amount'] = 'insuranceAmount' @_hash['duty_amount'] = 'dutyAmount' @_hash end |
.nullables ⇒ Object
An array for nullable fields
75 76 77 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 75 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 61 def self.optionals %w[ total_amount currency discount_amount shipping_amount shipping_discount_amount tax_amount insurance_amount duty_amount ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
192 193 194 195 196 197 198 199 200 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 192 def inspect class_name = self.class.name.split('::').last "<#{class_name} total_amount: #{@total_amount.inspect}, currency: #{@currency.inspect},"\ " discount_amount: #{@discount_amount.inspect}, shipping_amount:"\ " #{@shipping_amount.inspect}, shipping_discount_amount:"\ " #{@shipping_discount_amount.inspect}, tax_amount: #{@tax_amount.inspect},"\ " insurance_amount: #{@insurance_amount.inspect}, duty_amount: #{@duty_amount.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
182 183 184 185 186 187 188 189 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 182 def to_s class_name = self.class.name.split('::').last "<#{class_name} total_amount: #{@total_amount}, currency: #{@currency}, discount_amount:"\ " #{@discount_amount}, shipping_amount: #{@shipping_amount}, shipping_discount_amount:"\ " #{@shipping_discount_amount}, tax_amount: #{@tax_amount}, insurance_amount:"\ " #{@insurance_amount}, duty_amount: #{@duty_amount}, additional_properties:"\ " #{@additional_properties}>" end |
#to_xml_element(doc, root_name) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/cyber_source_merged_spec/models/amount_details32.rb', line 160 def to_xml_element(doc, root_name) root = doc.create_element(root_name) XmlUtilities.add_as_subelement(doc, root, 'totalAmount', total_amount) XmlUtilities.add_as_subelement(doc, root, 'currency', currency) XmlUtilities.add_as_subelement(doc, root, 'discountAmount', discount_amount) XmlUtilities.add_as_subelement(doc, root, 'shippingAmount', shipping_amount) XmlUtilities.add_as_subelement(doc, root, 'shippingDiscountAmount', shipping_discount_amount) XmlUtilities.add_as_subelement(doc, root, 'taxAmount', tax_amount) XmlUtilities.add_as_subelement(doc, root, 'insuranceAmount', insurance_amount) XmlUtilities.add_as_subelement(doc, root, 'dutyAmount', duty_amount) XmlUtilities.add_as_subelement(doc, root, 'additional_properties', additional_properties) root end |