Module: MixinBot::API::Withdraw
- Included in:
- MixinBot::API
- Defined in:
- lib/mixin_bot/api/withdraw.rb
Instance Method Summary collapse
- #create_withdraw_address(**kwargs) ⇒ Object
- #delete_withdraw_address(address, **kwargs) ⇒ Object
- #get_withdraw_address(address, access_token: nil) ⇒ Object
- #withdrawals(**kwargs) ⇒ Object
Instance Method Details
#create_withdraw_address(**kwargs) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mixin_bot/api/withdraw.rb', line 6 def create_withdraw_address(**kwargs) path = '/addresses' pin = kwargs[:pin] payload = { asset_id: kwargs[:asset_id], destination: kwargs[:destination], tag: kwargs[:tag], label: kwargs[:label] } if pin.length > 6 payload[:pin_base64] = encrypt_tip_pin pin, 'TIP:ADDRESS:ADD:', payload[:asset_id], payload[:destination], payload[:tag], payload[:label] else payload[:pin] = encrypt_pin pin end client.post path, **payload end |
#delete_withdraw_address(address, **kwargs) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mixin_bot/api/withdraw.rb', line 32 def delete_withdraw_address(address, **kwargs) pin = kwargs[:pin] path = format('/addresses/%<address>s/delete', address:) payload = if pin.length > 6 { pin_base64: encrypt_tip_pin(pin, 'TIP:ADDRESS:REMOVE:', address) } else { pin: encrypt_pin(pin) } end client.post path, **payload end |
#get_withdraw_address(address, access_token: nil) ⇒ Object
26 27 28 29 30 |
# File 'lib/mixin_bot/api/withdraw.rb', line 26 def get_withdraw_address(address, access_token: nil) path = format('/addresses/%<address>s', address:) client.get path, access_token: end |
#withdrawals(**kwargs) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mixin_bot/api/withdraw.rb', line 50 def withdrawals(**kwargs) address_id = kwargs[:address_id] pin = kwargs[:pin] amount = format('%.8f', kwargs[:amount].to_d.to_r) trace_id = kwargs[:trace_id] memo = kwargs[:memo] kwargs[:access_token] path = '/withdrawals' payload = { address_id:, amount:, trace_id:, memo: } if pin.length > 6 fee = '0' payload[:pin_base64] = encrypt_tip_pin pin, 'TIP:WITHDRAW:', address_id, amount, fee, trace_id, memo else payload[:pin] = encrypt_pin pin end client.post path, **payload end |