Class: Cryptopay::CoinWithdrawal

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CoinWithdrawal

Initializes the object

Parameters:

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

    Model attributes in the form of hash



69
70
71
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 69

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

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::CoinWithdrawal

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



62
63
64
65
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 62

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

Instance Method Details

#addressObject

Recipient’s cryptocurrency wallet address



89
90
91
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 89

def address
  @attributes[:address]
end

#charged_amountObject

Payment amount. Amount charged from your account



108
109
110
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 108

def charged_amount
  @attributes[:charged_amount]
end

#charged_currencyObject

Account currency the payment has been sent from



113
114
115
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 113

def charged_currency
  @attributes[:charged_currency]
end

#created_atObject

Coin withdrawal creation date and time



153
154
155
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 153

def created_at
  @attributes[:created_at]
end

#custom_idObject

Payment reference ID in your system



79
80
81
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 79

def custom_id
  @attributes[:custom_id]
end

#customer_idObject

The reference ID of your customer



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

def customer_id
  @attributes[:customer_id]
end

#exchangeObject



144
145
146
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 144

def exchange
  @attributes[:exchange]
end

#feeObject



136
137
138
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 136

def fee
  @attributes[:fee]
end

#fee_currencyObject



140
141
142
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 140

def fee_currency
  @attributes[:fee_currency]
end

#idObject

Coin withdrawal ID



74
75
76
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 74

def id
  @attributes[:id]
end

#inspectObject



221
222
223
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 221

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



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 159

def invalid_properties
  properties = []

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

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

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

  if !status.nil? && !%w[new pending on_hold processing sent completed failed cancelled].include?(status)
    properties.push('invalid value for status, must be one of "new", "pending", "on_hold", "processing", "sent", "completed", "failed", "cancelled"')
  end

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

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

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

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

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

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

  if !network_fee_level.nil? && !%w[fast average slow].include?(network_fee_level)
    properties.push('invalid value for network_fee_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 "fee_currency", fee_currency cannot be nil.') if fee_currency.nil?

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

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

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

  properties
end

#networkObject

Cryptocurrency network



94
95
96
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 94

def network
  @attributes[:network]
end

#network_feeObject

Network fee amount



128
129
130
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 128

def network_fee
  @attributes[:network_fee]
end

#network_fee_levelObject



132
133
134
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 132

def network_fee_level
  @attributes[:network_fee_level]
end

#received_amountObject

Cryptocurrency transaction amount. Exact amount received by a recipient



118
119
120
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 118

def received_amount
  @attributes[:received_amount]
end

#received_currencyObject

Cryptocurrency type



123
124
125
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 123

def received_currency
  @attributes[:received_currency]
end

#riskObject



148
149
150
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 148

def risk
  @attributes[:risk]
end

#statusObject



103
104
105
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 103

def status
  @attributes[:status]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



217
218
219
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 217

def to_hash
  ENCODER.to_hash(@attributes)
end

#txidObject

Cryptocurrency transaction ID on the blockchain



99
100
101
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 99

def txid
  @attributes[:txid]
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



211
212
213
# File 'lib/cryptopay/models/coin_withdrawal.rb', line 211

def valid?
  invalid_properties.empty?
end