Class: Cryptopay::Transactions

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

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Transactions

Returns a new instance of Transactions.



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

def initialize(connection)
  @connection = connection
end

Instance Method Details

#list(opts = {}) ⇒ TransactionListResult

List transactions

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :created_at_from (Time)

    Date and time in iso8601 format

  • :created_at_to (Time)

    Date and time in iso8601 format

  • :reference_type (TransactionReferenceType)

    Transaction reference type

  • :currency (String)

    Transaction currency

  • :status (String)

    Transaction status

  • :risk_level (RiskLevel)

    Transaction risk level

  • :starting_after (String)

    Pagination parameter. ID to start after

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cryptopay/api/transactions.rb', line 22

def list(opts = {})
  path = '/api/transactions'

  query_params = {}
  query_params[:created_at_from] = opts[:created_at_from] unless opts[:created_at_from].nil?
  query_params[:created_at_to] = opts[:created_at_to] unless opts[:created_at_to].nil?
  query_params[:reference_type] = opts[:reference_type] unless opts[:reference_type].nil?
  query_params[:currency] = opts[:currency] unless opts[:currency].nil?
  query_params[:status] = opts[:status] unless opts[:status].nil?
  query_params[:risk_level] = opts[:risk_level] unless opts[:risk_level].nil?
  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