class Bitex::SpecieWithdrawal

A withdrawal of some specie from your bitex.la balance

Attributes

created_at[RW]

@!attribute created_at

@return [Time] Time when this withdrawal was requested by you.
id[RW]

@!attribute id

@return [Integer] This SpecieWithdrawal's unique ID.
kyc_profile_id[RW]

@!attribute kyc_profile_id

@return [Integer] Kyc profile id for which this request was made.
label[RW]

@!attribute label

@return [String] A custom label you gave to this address.
quantity[RW]

@!attribute quantity

@return [BigDecimal] Quantity deposited
reason[RW]

@!attribute reason

Returns the reason for cancellation of this withdrawal, if any.
* :not_cancelled
* :insufficient_funds The instruction was received, but you didn't have
  enough funds available
* :destination_invalid The destination address was invalid.
specie[RW]

@!attribute specie

@return [Symbol] :btc
status[RW]

@!attribute status

Returns the status of this withdrawal.
* :received Our engine is checking if you have enough funds.
* :pending your withdrawal was accepted and is being processed.
* :done your withdrawal was processed and published to the network.
* :cancelled your withdrawal could not be processed.
to_address[RW]

@!attribute to_address

@return [String] Address to wich you made this withdrawal.
transaction_id[RW]

@!attribute transaction_id

@return [String] Network transaction id, if available.

Public Class Methods

all(specie) click to toggle source
# File lib/bitex/specie_withdrawal.rb, line 85
def self.all(specie)
  Api.private(:get, "/private/#{specie}/withdrawals").map { |sw| from_json(sw) }
end
create!(specie, address, amount, label, kyc_profile_id = nil) click to toggle source

rubocop:enable Metrics/AbcSize

# File lib/bitex/specie_withdrawal.rb, line 68
def self.create!(specie, address, amount, label, kyc_profile_id = nil)
  from_json(
    Api.private(
      :post,
      "/private/#{specie}/withdrawals",
      address: address,
      amount: amount,
      label: label,
      kyc_profile_id: kyc_profile_id
    )
  )
end
find(specie, id) click to toggle source
# File lib/bitex/specie_withdrawal.rb, line 81
def self.find(specie, id)
  from_json(Api.private(:get, "/private/#{specie}/withdrawals/#{id}"))
end
from_json(json) click to toggle source

@visibility private rubocop:disable Metrics/AbcSize

# File lib/bitex/specie_withdrawal.rb, line 54
def self.from_json(json)
  Api.from_json(new, json) do |thing|
    thing.specie = { 1 => :btc }[json[3]]
    thing.quantity = (json[4].presence || 0).to_d
    thing.status = statuses[json[5]]
    thing.reason = reasons[json[6]]
    thing.to_address = json[7]
    thing.label = json[8]
    thing.kyc_profile_id = json[9]
    thing.transaction_id = json[10]
  end
end
reasons() click to toggle source
# File lib/bitex/specie_withdrawal.rb, line 93
def self.reasons
  { 0 => :not_cancelled, 1 => :insufficient_funds, 2 => :destination_invalid }
end
statuses() click to toggle source
# File lib/bitex/specie_withdrawal.rb, line 89
def self.statuses
  { 1 => :received, 2 => :pending, 3 => :done, 4 => :cancelled }
end