Class: Cryptopay::Risk

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptopay/models/risk.rb

Overview

Transaction risk level details

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Risk

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



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

#inspectObject



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_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



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

#levelObject



46
47
48
# File 'lib/cryptopay/models/risk.rb', line 46

def level
  @attributes[:level]
end

#resource_categoryObject

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_nameObject

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

#scoreObject

Transaction risk score



42
43
44
# File 'lib/cryptopay/models/risk.rb', line 42

def score
  @attributes[:score]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (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

Returns:

  • (Boolean)

    true if the model is valid



84
85
86
# File 'lib/cryptopay/models/risk.rb', line 84

def valid?
  invalid_properties.empty?
end