Class: CyberSourceMergedSpec::TaxDetails

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/tax_details.rb

Overview

TaxDetails Model.

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(amount: SKIP, rate: SKIP, applied: SKIP, exemption_code: SKIP, tax_type: SKIP, tax_summary: SKIP, additional_properties: nil) ⇒ TaxDetails

Returns a new instance of TaxDetails.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 79

def initialize(amount: SKIP, rate: SKIP, applied: SKIP,
               exemption_code: SKIP, tax_type: SKIP, tax_summary: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @amount = amount unless amount == SKIP
  @rate = rate unless rate == SKIP
  @applied = applied unless applied == SKIP
  @exemption_code = exemption_code unless exemption_code == SKIP
  @tax_type = tax_type unless tax_type == SKIP
  @tax_summary = tax_summary unless tax_summary == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountString

Indicates the amount of tax based on the type field as described in the table below:

Returns:

  • (String)


15
16
17
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 15

def amount
  @amount
end

#appliedTrueClass | FalseClass

Flag that indicates whether the tax amount (travelInformation.autoRental.taxDetails.amount) is included in the request. Possible values:

  • false: tax amount is not included in the request.
  • true: tax amount is included in the request.

Returns:

  • (TrueClass | FalseClass)


32
33
34
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 32

def applied
  @applied
end

#exemption_codeString

Status code for exemption from sales and use tax. This field is a pass-through, which means that CyberSource does not verify the value or modify it in any way before sending it to the processor.

Returns:

  • (String)


39
40
41
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 39

def exemption_code
  @exemption_code
end

#rateString

Rate of VAT or other tax for the order. Example 0.040 (=4%) Valid range: 0.01 to 0.99 (1% to 99%, with only whole percentage values accepted; values with additional decimal places will be truncated)

Returns:

  • (String)


23
24
25
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 23

def rate
  @rate
end

#tax_summaryString

Summary of all tax types

Returns:

  • (String)


48
49
50
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 48

def tax_summary
  @tax_summary
end

#tax_typeString

Different taxes the rental agency applies to the rental agreement such as tourist tax, airport tax, or rental tax.

Returns:

  • (String)


44
45
46
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 44

def tax_type
  @tax_type
end

Class Method Details

.from_element(root) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 123

def self.from_element(root)
  amount = XmlUtilities.from_element(root, 'amount', String)
  rate = XmlUtilities.from_element(root, 'rate', String)
  applied = XmlUtilities.from_element(root, 'applied', TrueClass)
  exemption_code = XmlUtilities.from_element(root, 'exemptionCode', String)
  tax_type = XmlUtilities.from_element(root, 'taxType', String)
  tax_summary = XmlUtilities.from_element(root, 'taxSummary', String)

  new(amount: amount,
      rate: rate,
      applied: applied,
      exemption_code: exemption_code,
      tax_type: tax_type,
      tax_summary: tax_summary,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 95

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('amount') ? hash['amount'] : SKIP
  rate = hash.key?('rate') ? hash['rate'] : SKIP
  applied = hash.key?('applied') ? hash['applied'] : SKIP
  exemption_code = hash.key?('exemptionCode') ? hash['exemptionCode'] : SKIP
  tax_type = hash.key?('taxType') ? hash['taxType'] : SKIP
  tax_summary = hash.key?('taxSummary') ? hash['taxSummary'] : 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.
  TaxDetails.new(amount: amount,
                 rate: rate,
                 applied: applied,
                 exemption_code: exemption_code,
                 tax_type: tax_type,
                 tax_summary: tax_summary,
                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



51
52
53
54
55
56
57
58
59
60
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 51

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['rate'] = 'rate'
  @_hash['applied'] = 'applied'
  @_hash['exemption_code'] = 'exemptionCode'
  @_hash['tax_type'] = 'taxType'
  @_hash['tax_summary'] = 'taxSummary'
  @_hash
end

.nullablesObject

An array for nullable fields



75
76
77
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 75

def self.nullables
  []
end

.optionalsObject

An array for optional fields



63
64
65
66
67
68
69
70
71
72
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 63

def self.optionals
  %w[
    amount
    rate
    applied
    exemption_code
    tax_type
    tax_summary
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



164
165
166
167
168
169
170
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 164

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount.inspect}, rate: #{@rate.inspect}, applied:"\
  " #{@applied.inspect}, exemption_code: #{@exemption_code.inspect}, tax_type:"\
  " #{@tax_type.inspect}, tax_summary: #{@tax_summary.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



156
157
158
159
160
161
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 156

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount}, rate: #{@rate}, applied: #{@applied}, exemption_code:"\
  " #{@exemption_code}, tax_type: #{@tax_type}, tax_summary: #{@tax_summary},"\
  " additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/cyber_source_merged_spec/models/tax_details.rb', line 140

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, 'rate', rate)
  XmlUtilities.add_as_subelement(doc, root, 'applied', applied)
  XmlUtilities.add_as_subelement(doc, root, 'exemptionCode', exemption_code)
  XmlUtilities.add_as_subelement(doc, root, 'taxType', tax_type)
  XmlUtilities.add_as_subelement(doc, root, 'taxSummary', tax_summary)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end