Class: CyberSourceMergedSpec::RiskInformation

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

Overview

This object is only needed when you are requesting both payment and DM services at same time.

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) ⇒ RiskInformation

Returns a new instance of RiskInformation.



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

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:



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

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:



31
32
33
# File 'lib/cyber_source_merged_spec/models/risk_information.rb', line 31

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)


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

def event_type
  @event_type
end

#profileProfile

Identifies a risk profile.

Returns:



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

def profile
  @profile
end

Class Method Details

.from_element(root) ⇒ Object



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

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.



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
110
# File 'lib/cyber_source_merged_spec/models/risk_information.rb', line 79

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.
  RiskInformation.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.



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

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



62
63
64
# File 'lib/cyber_source_merged_spec/models/risk_information.rb', line 62

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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.



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

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.



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

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



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

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