Class: Bitodeme::Resource::Withdrawal

Inherits:
Base
  • Object
show all
Defined in:
lib/bitodeme/resources/withdrawal.rb

Overview

Withdrawal resource

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

#to_h

Instance Attribute Details

#addressObject (readonly)

Address



8
9
10
# File 'lib/bitodeme/resources/withdrawal.rb', line 8

def address
  @address
end

#amountObject (readonly)

Amount



11
12
13
# File 'lib/bitodeme/resources/withdrawal.rb', line 11

def amount
  @amount
end

#fund_idObject (readonly)

Fund identifier



14
15
16
# File 'lib/bitodeme/resources/withdrawal.rb', line 14

def fund_id
  @fund_id
end

#idObject (readonly)

Unique identifier



17
18
19
# File 'lib/bitodeme/resources/withdrawal.rb', line 17

def id
  @id
end

#otp_valueObject (readonly)

One time password value gathered from Google Authenticator



20
21
22
# File 'lib/bitodeme/resources/withdrawal.rb', line 20

def otp_value
  @otp_value
end

Class Method Details

.build(params) ⇒ Object

Build a withdrawal object

Example:

>> fund_id    = '12b241a7-941e-43a8-878e-a467809e988e'
>> withdrawal =
>>   Bitodeme::Resource::Withdrawal.build(
>>     amount:    0.0013,
>>     address:   'morg4YKzAESEktS7H74dtaavFjuhNUi8zq',
>>     fund_id:   fund_id,
>>     otp_value: "123456" # otp value from Google Authenticator
>>   )

Arguments:

params: (Hash)


37
38
39
# File 'lib/bitodeme/resources/withdrawal.rb', line 37

def build(params)
  new(params).send(:validate)
end

.create(withdrawal) ⇒ Object

Craete a new withdrawal(send money)

Example:

>> fund_id    = '12b241a7-941e-43a8-878e-a467809e988e'
>> withdrawal =
>>   Bitodeme::Resource::Withdrawal.build(
>>     amount:    0.0013,
>>     address:   'morg4YKzAESEktS7H74dtaavFjuhNUi8zq',
>>     fund_id:   fund_id,
>>     otp_value: "123456" # otp value from Google Authenticator
>>   )

>> Bitodeme::Resource::Withdrawal.create(withdrawal)

Arguments:

withdrawal: (Bitodeme::Resource::Withdrawal)


57
58
59
60
61
# File 'lib/bitodeme/resources/withdrawal.rb', line 57

def create(withdrawal)
  raise_for('withdrawal', withdrawal) unless withdrawal.is_a?(Withdrawal)
  data = { withdrawal: withdrawal.to_h }
  post('/api/v1/withdrawals', data).body
end