Class: CyberSourceMergedSpec::PurchaseOptions3

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

Overview

PurchaseOptions3 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(benefit_amount: SKIP, benefit_type: SKIP, additional_properties: nil) ⇒ PurchaseOptions3

Returns a new instance of PurchaseOptions3.



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

def initialize(benefit_amount: SKIP, benefit_type: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @benefit_amount = benefit_amount unless benefit_amount == SKIP
  @benefit_type = benefit_type unless benefit_type == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#benefit_amountString

Workplace benefit amount.

Returns:

  • (String)


14
15
16
# File 'lib/cyber_source_merged_spec/models/purchase_options3.rb', line 14

def benefit_amount
  @benefit_amount
end

#benefit_typeString

Workplace benefit type. Possible values:

  • 70 = employee benefit
  • 4T = transportation / transit
  • 52 = general benefit
  • 53 = meal voucher
  • 54 = fuel
  • 55 = ecological / sustainability
  • 58 = philanthropy / patronage / consumption
  • 59 = gift
  • 5S = sport / culture
  • 5T = book / education

Returns:

  • (String)


29
30
31
# File 'lib/cyber_source_merged_spec/models/purchase_options3.rb', line 29

def benefit_type
  @benefit_type
end

Class Method Details

.from_element(root) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/cyber_source_merged_spec/models/purchase_options3.rb', line 83

def self.from_element(root)
  benefit_amount = XmlUtilities.from_element(root, 'benefitAmount', String)
  benefit_type = XmlUtilities.from_element(root, 'benefitType', String)

  new(benefit_amount: benefit_amount,
      benefit_type: benefit_type,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/cyber_source_merged_spec/models/purchase_options3.rb', line 63

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  benefit_amount = hash.key?('benefitAmount') ? hash['benefitAmount'] : SKIP
  benefit_type = hash.key?('benefitType') ? hash['benefitType'] : 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.
  PurchaseOptions3.new(benefit_amount: benefit_amount,
                       benefit_type: benefit_type,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



32
33
34
35
36
37
# File 'lib/cyber_source_merged_spec/models/purchase_options3.rb', line 32

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['benefit_amount'] = 'benefitAmount'
  @_hash['benefit_type'] = 'benefitType'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
# File 'lib/cyber_source_merged_spec/models/purchase_options3.rb', line 40

def self.optionals
  %w[
    benefit_amount
    benefit_type
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



111
112
113
114
115
# File 'lib/cyber_source_merged_spec/models/purchase_options3.rb', line 111

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} benefit_amount: #{@benefit_amount.inspect}, benefit_type:"\
  " #{@benefit_type.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



104
105
106
107
108
# File 'lib/cyber_source_merged_spec/models/purchase_options3.rb', line 104

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} benefit_amount: #{@benefit_amount}, benefit_type: #{@benefit_type},"\
  " additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



92
93
94
95
96
97
98
99
100
101
# File 'lib/cyber_source_merged_spec/models/purchase_options3.rb', line 92

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'benefitAmount', benefit_amount)
  XmlUtilities.add_as_subelement(doc, root, 'benefitType', benefit_type)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end