Class: Cryptopay::CoinWithdrawalParams

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CoinWithdrawalParams

Initializes the object

Parameters:

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

    Model attributes in the form of hash



58
59
60
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 58

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

Class Method Details

.build_from_hash(data) ⇒ Cryptopay::CoinWithdrawalParams

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:



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

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

Instance Method Details

#addressObject

A recipient’s cryptocurrency wallet address



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

def address
  @attributes[:address]
end

#beneficiaryObject



121
122
123
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 121

def beneficiary
  @attributes[:beneficiary]
end

#charged_amountObject

The exact amount to debit from your account in ‘charged_currency`. All applicable fees will be deducted from this amount before processing a transaction instead of adding them on top it.



83
84
85
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 83

def charged_amount
  @attributes[:charged_amount]
end

#charged_amount_to_sendObject

The exact transaction amount to send in ‘charged_currency`. All applicable fees will be added on top of this amount and debited from your account.



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

def charged_amount_to_send
  @attributes[:charged_amount_to_send]
end

#charged_currencyObject

An account currency to send a transaction from



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

def charged_currency
  @attributes[:charged_currency]
end

#custom_idObject

The payment reference ID in your system



98
99
100
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 98

def custom_id
  @attributes[:custom_id]
end

#customer_idObject

The internal ID of your customer that the wihdrawal relates to



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

def customer_id
  @attributes[:customer_id]
end

#force_commitObject

Is ‘false` if omitted. Set `true` to turn off two-step withdrawal. Set `false` for two-step withdrawal and commit it within 30 seconds



112
113
114
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 112

def force_commit
  @attributes[:force_commit]
end

#inspectObject



161
162
163
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 161

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



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 127

def invalid_properties
  properties = []

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

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

  if received_currency.nil?
    properties.push('invalid value for "received_currency", received_currency 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

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

  properties
end

#networkObject

Cryptocurrency network



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

def network
  @attributes[:network]
end

#network_fee_levelObject



107
108
109
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 107

def network_fee_level
  @attributes[:network_fee_level]
end

#received_amountObject

The exact transaction amount to send in ‘received_currency`. All applicable fees will be added on top of this amount and debited from your account.



93
94
95
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 93

def received_amount
  @attributes[:received_amount]
end

#received_currencyObject

Cryptocurrency type



73
74
75
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 73

def received_currency
  @attributes[:received_currency]
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



157
158
159
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 157

def to_hash
  ENCODER.to_hash(@attributes)
end

#travel_rule_compliantObject

Is ‘false` if omitted. Set `true` to turn on beneficiary data validations



117
118
119
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 117

def travel_rule_compliant
  @attributes[:travel_rule_compliant]
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



151
152
153
# File 'lib/cryptopay/models/coin_withdrawal_params.rb', line 151

def valid?
  invalid_properties.empty?
end