Class: CyberSourceMergedSpec::Score
- Defined in:
- lib/cyber_source_merged_spec/models/score.rb
Overview
Score Model.
Instance Attribute Summary collapse
-
#factor_codes ⇒ Array[String]
TODO: Write general description for this method.
-
#model_used ⇒ String
Name of the score model used for the transaction.
-
#result ⇒ String
Total score calculated for this order.
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(factor_codes: SKIP, model_used: SKIP, result: SKIP, additional_properties: nil) ⇒ Score
constructor
A new instance of Score.
-
#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(factor_codes: SKIP, model_used: SKIP, result: SKIP, additional_properties: nil) ⇒ Score
Returns a new instance of Score.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 59 def initialize(factor_codes: SKIP, model_used: SKIP, result: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @factor_codes = factor_codes unless factor_codes == SKIP @model_used = model_used unless model_used == SKIP @result = result unless result == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#factor_codes ⇒ Array[String]
TODO: Write general description for this method
14 15 16 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 14 def factor_codes @factor_codes end |
#model_used ⇒ String
Name of the score model used for the transaction. If you did not include a
custom model in your request,
this field contains the name of CyberSource’s default model.
For all possible values, see the score_model_used field description in
the Decision Manager Using the SCMP API Developer Guide on the
CyberSource Business Center. Click
Decision Manager > Documentation > Guides > Decision Manager
Using the SCMP API Developer Guide (PDF link).
25 26 27 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 25 def model_used @model_used end |
#result ⇒ String
Total score calculated for this order. The value cannot be negative.
For all possible values, see the score_score_result field description in
the Decision Manager Using the SCMP API Developer Guide on the
CyberSource Business Center. Click
Decision Manager > Documentation > Guides > Decision Manager
Using the SCMP API Developer Guide (PDF link).
34 35 36 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 34 def result @result end |
Class Method Details
.from_element(root) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 93 def self.from_element(root) factor_codes = XmlUtilities.from_element_to_array(root, 'factorCodes', String) model_used = XmlUtilities.from_element(root, 'modelUsed', String) result = XmlUtilities.from_element(root, 'result', String) new(factor_codes: factor_codes, model_used: model_used, result: result, additional_properties: additional_properties) end |
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 71 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. factor_codes = hash.key?('factorCodes') ? hash['factorCodes'] : SKIP model_used = hash.key?('modelUsed') ? hash['modelUsed'] : SKIP result = hash.key?('result') ? hash['result'] : 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. Score.new(factor_codes: factor_codes, model_used: model_used, result: result, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['factor_codes'] = 'factorCodes' @_hash['model_used'] = 'modelUsed' @_hash['result'] = 'result' @_hash end |
.nullables ⇒ Object
An array for nullable fields
55 56 57 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 55 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
46 47 48 49 50 51 52 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 46 def self.optionals %w[ factor_codes model_used result ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
126 127 128 129 130 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 126 def inspect class_name = self.class.name.split('::').last "<#{class_name} factor_codes: #{@factor_codes.inspect}, model_used: #{@model_used.inspect},"\ " result: #{@result.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
119 120 121 122 123 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 119 def to_s class_name = self.class.name.split('::').last "<#{class_name} factor_codes: #{@factor_codes}, model_used: #{@model_used}, result:"\ " #{@result}, additional_properties: #{@additional_properties}>" end |
#to_xml_element(doc, root_name) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/cyber_source_merged_spec/models/score.rb', line 105 def to_xml_element(doc, root_name) root = doc.create_element(root_name) XmlUtilities.add_array_as_subelement(doc, root, 'factorCodes', factor_codes) XmlUtilities.add_as_subelement(doc, root, 'modelUsed', model_used) XmlUtilities.add_as_subelement(doc, root, 'result', result) XmlUtilities.add_as_subelement(doc, root, 'additional_properties', additional_properties) root end |