Class: Cryptopay::NetworkFee

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ NetworkFee

Initializes the object

Parameters:

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

    Model attributes in the form of hash



36
37
38
# File 'lib/cryptopay/models/network_fee.rb', line 36

def initialize(attributes = {})
  @attributes = ENCODER.sanitize(attributes)
end

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::NetworkFee

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



29
30
31
32
# File 'lib/cryptopay/models/network_fee.rb', line 29

def self.build_from_hash(data)
  attributes = ENCODER.build_from_hash(data)
  new(attributes)
end

Instance Method Details

#currencyObject



48
49
50
# File 'lib/cryptopay/models/network_fee.rb', line 48

def currency
  @attributes[:currency]
end

#feeObject



44
45
46
# File 'lib/cryptopay/models/network_fee.rb', line 44

def fee
  @attributes[:fee]
end

#inspectObject



88
89
90
# File 'lib/cryptopay/models/network_fee.rb', line 88

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



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/cryptopay/models/network_fee.rb', line 58

def invalid_properties
  properties = []

  properties.push('invalid value for "level", level cannot be nil.') if level.nil?

  if !level.nil? && !%w[fast average slow].include?(level)
    properties.push('invalid value for level, must be one of "fast", "average", "slow"')
  end

  properties.push('invalid value for "fee", fee cannot be nil.') if fee.nil?

  properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?

  properties.push('invalid value for "network", network cannot be nil.') if network.nil?

  properties
end

#levelObject



40
41
42
# File 'lib/cryptopay/models/network_fee.rb', line 40

def level
  @attributes[:level]
end

#networkObject



52
53
54
# File 'lib/cryptopay/models/network_fee.rb', line 52

def network
  @attributes[:network]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



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

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



78
79
80
# File 'lib/cryptopay/models/network_fee.rb', line 78

def valid?
  invalid_properties.empty?
end