Class: Coinbase::Accounts

Inherits:
Client
  • Object
show all
Defined in:
lib/coinbase/accounts.rb

Overview

Coinbase Accounts APIs

Constant Summary collapse

ACCOUNT_BASE =
'accounts'

Instance Method Summary collapse

Methods inherited from Client

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

Methods included from Util

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

Constructor Details

#initializeAccounts

Returns a new instance of Accounts.



8
9
10
# File 'lib/coinbase/accounts.rb', line 8

def initialize
  super
end

Instance Method Details

#fetch(account_id) ⇒ Hash

Show current user account by account_id.

Parameters:

  • account_id (String)

Returns:

  • (Hash)

    a account.



67
68
69
70
71
72
73
# File 'lib/coinbase/accounts.rb', line 67

def fetch()
  format_response(
    get(
      "/#{ACCOUNT_BASE}/#{}"
    )
  )
end

#history(account_id, options = {}) ⇒ Array of Hashes

History List account activity of the API key’s profile.

from this account id. If set, returns ledger entries before the specified integer. If set, returns ledger entries after the specified integer. the start_date timestamp, sorted by newest creation date. When combined with end_date, returns ledger entries in the specified time range. the end_date timestamp, sorted by newest creation date.

Parameters:

  • account_id (String)

    Returns list of ledger entries

  • before (String)

    . Parameter requires a positive integer.

  • after (String)

    . Parameter requires a positive integer.

  • start_date (String)

    . If set, returns ledger entries created after

  • end_date (String)

    . If set, returns ledger entries created before

  • limit (Integer)

    . Number of results per request. Maximum 1000.

Returns:

  • (Array of Hashes)

    List account activity of the API key’s profile.



40
41
42
43
44
45
46
47
48
49
# File 'lib/coinbase/accounts.rb', line 40

def history(, options = {})
  operational_url = "/#{ACCOUNT_BASE}/#{}/ledger"
  query_params = build_query_params(options)
  operational_url += '?' + query_params unless query_params.empty?
  format_response(
    get(
      operational_url
    )
  )
end

#holds(account_id) ⇒ Array of Hashes

Holds of an account that belong to the same profile as the API key.

Parameters:

  • account_id (String)

Returns:

  • (Array of Hashes)


55
56
57
58
59
60
61
# File 'lib/coinbase/accounts.rb', line 55

def holds()
  format_response(
    get(
      "/#{ACCOUNT_BASE}/#{}/holds"
    )
  )
end

#listArray of Hashes

Lists current user accounts.

Returns:

  • (Array of Hashes)

    a list of accounts.



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

def list
  format_response(
    get(
      "/#{ACCOUNT_BASE}"
    )
  )
end