Class: CyberSourceMergedSpec::Freight
- Defined in:
- lib/cyber_source_merged_spec/models/freight.rb
Overview
Contains all of the shipping-related fields for the order.
Instance Attribute Summary collapse
-
#amount ⇒ String
Total freight or shipping and handling charges for the order.
-
#tax_rate ⇒ String
Shipping Tax rate applied to the freight amount.
-
#taxable ⇒ TrueClass | FalseClass
Flag that indicates whether an order is taxable.
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(amount: SKIP, taxable: SKIP, tax_rate: SKIP, additional_properties: nil) ⇒ Freight
constructor
A new instance of Freight.
-
#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(amount: SKIP, taxable: SKIP, tax_rate: SKIP, additional_properties: nil) ⇒ Freight
Returns a new instance of Freight.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 60 def initialize(amount: SKIP, taxable: SKIP, tax_rate: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @amount = amount unless amount == SKIP @taxable = taxable unless taxable == SKIP @tax_rate = tax_rate unless tax_rate == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ String
Total freight or shipping and handling charges for the order. When you include this field in your request, you must also include the totalAmount field.
16 17 18 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 16 def amount @amount end |
#tax_rate ⇒ String
Shipping Tax rate applied to the freight amount. Visa: Valid range is 0.01 to 0.99 (1% to 99%, with only whole percentage values accepted; values with additional decimal places will be truncated). Mastercard: Valid range is 0.00001 to 0.99999 (0.001% to 99.999%).
35 36 37 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 35 def tax_rate @tax_rate end |
#taxable ⇒ TrueClass | FalseClass
Flag that indicates whether an order is taxable. This value must be true
if the sum of all lineItems.taxAmount values > 0.
If you do not include any lineItems[].taxAmount values in your request,
CyberSource does not include
invoiceDetails.taxable in the data it sends to the processor.
Possible values:
- true
- false
27 28 29 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 27 def taxable @taxable end |
Class Method Details
.from_element(root) ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 94 def self.from_element(root) amount = XmlUtilities.from_element(root, 'amount', String) taxable = XmlUtilities.from_element(root, 'taxable', TrueClass) tax_rate = XmlUtilities.from_element(root, 'taxRate', String) new(amount: amount, taxable: taxable, tax_rate: tax_rate, additional_properties: additional_properties) end |
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 72 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = hash.key?('amount') ? hash['amount'] : SKIP taxable = hash.key?('taxable') ? hash['taxable'] : SKIP tax_rate = hash.key?('taxRate') ? hash['taxRate'] : 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. Freight.new(amount: amount, taxable: taxable, tax_rate: tax_rate, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
38 39 40 41 42 43 44 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 38 def self.names @_hash = {} if @_hash.nil? @_hash['amount'] = 'amount' @_hash['taxable'] = 'taxable' @_hash['tax_rate'] = 'taxRate' @_hash end |
.nullables ⇒ Object
An array for nullable fields
56 57 58 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 56 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
47 48 49 50 51 52 53 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 47 def self.optionals %w[ amount taxable tax_rate ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
125 126 127 128 129 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 125 def inspect class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount.inspect}, taxable: #{@taxable.inspect}, tax_rate:"\ " #{@tax_rate.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
118 119 120 121 122 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 118 def to_s class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount}, taxable: #{@taxable}, tax_rate: #{@tax_rate},"\ " additional_properties: #{@additional_properties}>" end |
#to_xml_element(doc, root_name) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/cyber_source_merged_spec/models/freight.rb', line 105 def to_xml_element(doc, root_name) root = doc.create_element(root_name) XmlUtilities.add_as_subelement(doc, root, 'amount', amount) XmlUtilities.add_as_subelement(doc, root, 'taxable', taxable) XmlUtilities.add_as_subelement(doc, root, 'taxRate', tax_rate) XmlUtilities.add_as_subelement(doc, root, 'additional_properties', additional_properties) root end |