Class: Coinbase::Withdrawals

Inherits:
Transfers show all
Defined in:
lib/coinbase/withdrawals.rb

Overview

Withdrawl coinbase APIs

Constant Summary collapse

WITHDRAWAL_API =
'/transfers'
DEFAULT_TYPE =
'withdraw'

Instance Method Summary collapse

Methods inherited from Transfers

#fetch, #payment_methods

Methods inherited from Client

configuration, configure, #delete, #get, #headers, #http_request, #initialize, #post, #put, #signature

Methods included from Util

#base_uri, #build_query_params, #format_response, #pagination_params, #send_request

Constructor Details

This class inherits a constructor from Coinbase::Client

Instance Method Details

#by_account(withdraw_details = {}) ⇒ Hash

Withdraw funds to a coinbase account.

amount [Float] The amount to withdraw. currency [String] The type of currency. coinbase_account_id [String] ID of coinbase account.

Parameters:

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

    with following fields

Returns:

  • (Hash)

    a hash with status code and withdraw details.



52
53
54
55
56
57
58
59
# File 'lib/coinbase/withdrawals.rb', line 52

def (withdraw_details = {})
  format_response(
    post(
      '/withdrawals/coinbase-account',
      body: withdraw_details
    )
  )
end

#by_crypto(withdraw_details = {}) ⇒ Hash

Withdraw funds to a crypto address.

amount [Float] The amount to withdraw. currency [String] The type of currency. crypto_address [String] A crypto address of the recipient. destination_tag [String] A destination tag for currencies

that support one.

no_destination_tag [Boolean] A boolean flag to opt out of

using a destination tag for currencies that support one.
This is required when not providing a destination tag.

add_network_fee_to_total [Boolean] A boolean flag to add the network fee

on top of the amount.

Parameters:

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

    with following fields

Returns:

  • (Hash)

    a hash with status code and withdraw details.



36
37
38
39
40
41
42
43
# File 'lib/coinbase/withdrawals.rb', line 36

def by_crypto(withdraw_details = {})
  format_response(
    post(
      '/withdrawals/crypto',
      body: withdraw_details
    )
  )
end

#by_method(withdraw_details) ⇒ Hash

Withdraw funds to a payment method.

amount [Float] The amount to withdraw. currency [String] The type of currency. payment_method_id [String] ID of the payment method.

Parameters:

  • withdraw_details (Hash)

    with following fields

Returns:

  • (Hash)

    a hash with status code and withdraw details.



68
69
70
71
72
73
74
75
# File 'lib/coinbase/withdrawals.rb', line 68

def by_method(withdraw_details)
  format_response(
    post(
      '/withdrawals/payment-method',
      body: withdraw_details
    )
  )
end

#fee_estimate(params = {}) ⇒ Hash

Fetch the network fee estimate when sending to the given address.

Parameters:

  • currency (String)

    The type of currency.

  • crypto_address (String)

    A crypto address of the recipient.

Returns:

  • (Hash)

    a hash with status code and fee estimate.



14
15
16
17
18
19
20
# File 'lib/coinbase/withdrawals.rb', line 14

def fee_estimate(params = {})
  operational_url = '/withdrawals/fee-estimate'
  query_params = build_query_params(params)
  operational_url += '/?' + query_params unless query_params.empty?
  response = get(operational_url)
  format_response(response)
end

#list(options = {}) ⇒ Hash

Fetch the list of Withdrawals from the profile of the API key, in descending order by created time.

before [String] If before is set,then it returns withdrawals created after

the before timestamp, sorted by oldest creation date(optional).

after [String] If after is set, then it returns withdrawals created before

the after timestamp, sorted by newest (optional).

limit [Integer] Truncate list to this many withdrawals, capped at 100.

Default is 100. (optional).

Parameters:

  • profile_id (String)

    Limit list of withdrawals to this profile_id. By default, it retrieves withdrawals using default profile(optional).

  • type (String)

    Set to withdraw or internal_withdraw (optional).

  • paginate_options (Hash)

    an hash with the following parameters

Returns:

  • (Hash)

    a hash with status code and withdrawal list.



91
92
93
94
# File 'lib/coinbase/withdrawals.rb', line 91

def list(options = {})
  options[:type] = options[:type].blank? ? DEFAULT_TYPE : options[:type]
  super(options)
end