Class: Cryptopay::CoinNetwork

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CoinNetwork

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

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

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::CoinNetwork

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



37
38
39
40
# File 'lib/cryptopay/models/coin_network.rb', line 37

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

Instance Method Details

#channelsObject



68
69
70
# File 'lib/cryptopay/models/coin_network.rb', line 68

def channels
  @attributes[:channels]
end

#coin_withdrawalsObject



72
73
74
# File 'lib/cryptopay/models/coin_network.rb', line 72

def coin_withdrawals
  @attributes[:coin_withdrawals]
end

#destination_tagObject



60
61
62
# File 'lib/cryptopay/models/coin_network.rb', line 60

def destination_tag
  @attributes[:destination_tag]
end

#inspectObject



124
125
126
# File 'lib/cryptopay/models/coin_network.rb', line 124

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



78
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/cryptopay/models/coin_network.rb', line 78

def invalid_properties
  properties = []

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

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

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

  destination_tag&.invalid_properties&.each do |prop|
    properties.push("invalid value for \"destination_tag\": #{prop}")
  end

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

  invoices&.invalid_properties&.each do |prop|
    properties.push("invalid value for \"invoices\": #{prop}")
  end

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

  channels&.invalid_properties&.each do |prop|
    properties.push("invalid value for \"channels\": #{prop}")
  end

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

  coin_withdrawals&.invalid_properties&.each do |prop|
    properties.push("invalid value for \"coin_withdrawals\": #{prop}")
  end

  properties
end

#invoicesObject



64
65
66
# File 'lib/cryptopay/models/coin_network.rb', line 64

def invoices
  @attributes[:invoices]
end

#nameObject



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

def name
  @attributes[:name]
end

#networkObject



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

def network
  @attributes[:network]
end

#precisionObject



56
57
58
# File 'lib/cryptopay/models/coin_network.rb', line 56

def precision
  @attributes[:precision]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



120
121
122
# File 'lib/cryptopay/models/coin_network.rb', line 120

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



114
115
116
# File 'lib/cryptopay/models/coin_network.rb', line 114

def valid?
  invalid_properties.empty?
end