Class: Cryptopay::Risk
- Inherits:
-
Object
- Object
- Cryptopay::Risk
- Defined in:
- lib/cryptopay/models/risk.rb
Overview
Transaction risk level details
Class Method Summary collapse
-
.build_from_hash(data) ⇒ Cryptopay::Risk
Builds the object from hash.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Risk
constructor
Initializes the object.
- #inspect ⇒ Object
-
#invalid_properties ⇒ Object
Show invalid properties with the reasons.
- #level ⇒ Object
-
#resource_category ⇒ Object
A resource category the transaction has been received from.
-
#resource_name ⇒ Object
A resource name the transaction has been received from.
-
#score ⇒ Object
Transaction risk score.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Risk
Initializes the object
37 38 39 |
# File 'lib/cryptopay/models/risk.rb', line 37 def initialize(attributes = {}) @attributes = ENCODER.sanitize(attributes) end |
Class Method Details
.build_from_hash(data) ⇒ Cryptopay::Risk
Builds the object from hash
30 31 32 33 |
# File 'lib/cryptopay/models/risk.rb', line 30 def self.build_from_hash(data) attributes = ENCODER.build_from_hash(data) new(attributes) end |
Instance Method Details
#inspect ⇒ Object
94 95 96 |
# File 'lib/cryptopay/models/risk.rb', line 94 def inspect "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash) end |
#invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cryptopay/models/risk.rb', line 62 def invalid_properties properties = [] properties.push('invalid value for "score", score cannot be nil.') if score.nil? properties.push('invalid value for "level", level cannot be nil.') if level.nil? if !level.nil? && !%w[low medium high].include?(level) properties.push('invalid value for level, must be one of "low", "medium", "high"') end properties.push('invalid value for "resource_name", resource_name cannot be nil.') if resource_name.nil? if resource_category.nil? properties.push('invalid value for "resource_category", resource_category cannot be nil.') end properties end |
#level ⇒ Object
46 47 48 |
# File 'lib/cryptopay/models/risk.rb', line 46 def level @attributes[:level] end |
#resource_category ⇒ Object
A resource category the transaction has been received from
56 57 58 |
# File 'lib/cryptopay/models/risk.rb', line 56 def resource_category @attributes[:resource_category] end |
#resource_name ⇒ Object
A resource name the transaction has been received from
51 52 53 |
# File 'lib/cryptopay/models/risk.rb', line 51 def resource_name @attributes[:resource_name] end |
#score ⇒ Object
Transaction risk score
42 43 44 |
# File 'lib/cryptopay/models/risk.rb', line 42 def score @attributes[:score] end |
#to_hash ⇒ Hash
Returns the object in the form of hash
90 91 92 |
# File 'lib/cryptopay/models/risk.rb', line 90 def to_hash ENCODER.to_hash(@attributes) end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
84 85 86 |
# File 'lib/cryptopay/models/risk.rb', line 84 def valid? invalid_properties.empty? end |