Module: Bitstamper::Rest::Private::Withdrawals

Included in:
Client
Defined in:
lib/bitstamper/rest/private/withdrawals.rb

Instance Method Summary collapse

Instance Method Details

#bank_withdrawal_status(id) ⇒ Object



38
39
40
41
42
# File 'lib/bitstamper/rest/private/withdrawals.rb', line 38

def bank_withdrawal_status(id)
  check_credentials!
  
  response    =   post("/v2/withdrawal/status", data: {id: id})
end

#cancel_bank_withdrawal(id) ⇒ Object



44
45
46
47
48
# File 'lib/bitstamper/rest/private/withdrawals.rb', line 44

def cancel_bank_withdrawal(id)
  check_credentials!
  
  response    =   post("/v2/withdrawal/cancel", data: {id: id})
end

#withdraw(currency, address:, amount:, instant: nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bitstamper/rest/private/withdrawals.rb', line 6

def withdraw(currency, address:, amount:, instant: nil)
  check_credentials!
  
  currency    =   currency.to_s.downcase
  
  if !::Bitstamper::Constants::AVAILABLE_CRYPTOS.include?(currency)
    raise ::Bitstamper::Errors::InvalidCurrencyError.new("#{currency} is not a tradeable crypto currency on Bitstamp.")
  end
  
  path        =   currency.eql?("btc") ? "/bitcoin_withdrawal" : "/v2/#{currency}_withdrawal"
  
  data        =   {
    address:  address,
    amount:   amount,
  }
  
  data[:instant] = 1 if (currency.eql?("btc") && (instant.eql?(true) || instant.eql?(1)))
  
  response    =   parse(post(path, data: data))
  response    =   response.is_a?(String) ? {"id" => response} : response
  
  return response
end

#withdrawal_requests(interval: ) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/bitstamper/rest/private/withdrawals.rb', line 30

def withdrawal_requests(interval: ::Bitstamper::Constants::TIME_IN_SECONDS[:day])
  check_credentials!
  
  response    =   post("/v2/withdrawal-requests", data: {timedelta: interval})
  
  Bitstamper::Models::Withdrawal.parse(response) if response
end