Class: Cryptopay::Accounts

Inherits:
Object
  • Object
show all
Defined in:
lib/cryptopay/api/accounts.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Accounts

Returns a new instance of Accounts.



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

def initialize(connection)
  @connection = connection
end

Instance Method Details

#list(_opts = {}) ⇒ AccountListResult

List accounts

Parameters:

  • opts (Hash)

    the optional parameters

Returns:



15
16
17
18
19
20
21
22
23
24
# File 'lib/cryptopay/api/accounts.rb', line 15

def list(_opts = {})
  path = '/api/accounts'

  req = Request.new(
    method: :get,
    path: path
  )

  connection.call(req, return_type: AccountListResult)
end

#list_transactions(account_id, opts = {}) ⇒ TransactionListResult

List account transactions

Parameters:

  • account_id (String)

    Account ID

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

    the optional parameters

Options Hash (opts):

  • :starting_after (String)

    Pagination parameter. ID to start after

Returns:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cryptopay/api/accounts.rb', line 31

def list_transactions(, opts = {})
  path = '/api/accounts/{account_id}/transactions'
  path = path.sub('{account_id}', CGI.escape(.to_s))

  query_params = {}
  query_params[:starting_after] = opts[:starting_after] unless opts[:starting_after].nil?

  req = Request.new(
    method: :get,
    path: path,
    query_params: query_params
  )

  connection.call(req, return_type: TransactionListResult)
end