Class: CyberSourceMergedSpec::RiskInformation5

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

Overview

RiskInformation5 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(profile: SKIP, event_type: SKIP, buyer_history: SKIP, auxiliary_data: SKIP, additional_properties: nil) ⇒ RiskInformation5

Returns a new instance of RiskInformation5.



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/cyber_source_merged_spec/models/risk_information5.rb', line 65

def initialize(profile: SKIP, event_type: SKIP, buyer_history: SKIP,
               auxiliary_data: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @profile = profile unless profile == SKIP
  @event_type = event_type unless event_type == SKIP
  @buyer_history = buyer_history unless buyer_history == SKIP
  @auxiliary_data = auxiliary_data unless auxiliary_data == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#auxiliary_dataArray[AuxiliaryDatum]

Specifies one of the following types of events:

  • login
  • account_creation
  • account_update For regular payment transactions, do not send this field.

Returns:



38
39
40
# File 'lib/cyber_source_merged_spec/models/risk_information5.rb', line 38

def auxiliary_data
  @auxiliary_data
end

#buyer_historyBuyerHistory

Specifies one of the following types of events:

  • login
  • account_creation
  • account_update For regular payment transactions, do not send this field.

Returns:



30
31
32
# File 'lib/cyber_source_merged_spec/models/risk_information5.rb', line 30

def buyer_history
  @buyer_history
end

#event_typeString

Specifies one of the following types of events:

  • login
  • account_creation
  • account_update For regular payment transactions, do not send this field.

Returns:

  • (String)


22
23
24
# File 'lib/cyber_source_merged_spec/models/risk_information5.rb', line 22

def event_type
  @event_type
end

#profileProfile

Identifies a risk profile.

Returns:



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

def profile
  @profile
end

Class Method Details

.from_element(root) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/cyber_source_merged_spec/models/risk_information5.rb', line 111

def self.from_element(root)
  profile = XmlUtilities.from_element(root, 'Profile', Profile)
  event_type = XmlUtilities.from_element(root, 'eventType', String)
  buyer_history = XmlUtilities.from_element(root, 'BuyerHistory',
                                            BuyerHistory)
  auxiliary_data = XmlUtilities.from_element_to_array(root,
                                                      'AuxiliaryDatum',
                                                      AuxiliaryDatum)

  new(profile: profile,
      event_type: event_type,
      buyer_history: buyer_history,
      auxiliary_data: auxiliary_data,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/cyber_source_merged_spec/models/risk_information5.rb', line 78

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  profile = Profile.from_hash(hash['profile']) if hash['profile']
  event_type = hash.key?('eventType') ? hash['eventType'] : SKIP
  buyer_history = BuyerHistory.from_hash(hash['buyerHistory']) if hash['buyerHistory']
  # Parameter is an array, so we need to iterate through it
  auxiliary_data = nil
  unless hash['auxiliaryData'].nil?
    auxiliary_data = []
    hash['auxiliaryData'].each do |structure|
      auxiliary_data << (AuxiliaryDatum.from_hash(structure) if structure)
    end
  end

  auxiliary_data = SKIP unless hash.key?('auxiliaryData')

  # 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.
  RiskInformation5.new(profile: profile,
                       event_type: event_type,
                       buyer_history: buyer_history,
                       auxiliary_data: auxiliary_data,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
# File 'lib/cyber_source_merged_spec/models/risk_information5.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['profile'] = 'profile'
  @_hash['event_type'] = 'eventType'
  @_hash['buyer_history'] = 'buyerHistory'
  @_hash['auxiliary_data'] = 'auxiliaryData'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/cyber_source_merged_spec/models/risk_information5.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    profile
    event_type
    buyer_history
    auxiliary_data
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



150
151
152
153
154
155
# File 'lib/cyber_source_merged_spec/models/risk_information5.rb', line 150

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

#to_sObject

Provides a human-readable string representation of the object.



142
143
144
145
146
147
# File 'lib/cyber_source_merged_spec/models/risk_information5.rb', line 142

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

#to_xml_element(doc, root_name) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/cyber_source_merged_spec/models/risk_information5.rb', line 127

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

  XmlUtilities.add_as_subelement(doc, root, 'Profile', profile)
  XmlUtilities.add_as_subelement(doc, root, 'eventType', event_type)
  XmlUtilities.add_as_subelement(doc, root, 'BuyerHistory', buyer_history)
  XmlUtilities.add_array_as_subelement(doc, root, 'AuxiliaryDatum',
                                       auxiliary_data)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end