Module: Cryptomus::Client

Defined in:
lib/cryptomus/client.rb

Class Method Summary collapse

Class Method Details

.balanceHash

Examples:

Cryptomus::Client.balance

Returns:

  • (Hash)

Raises:



77
78
79
# File 'lib/cryptomus/client.rb', line 77

def balance
  connection.post('/v1/balance')
end

.connectionObject



81
82
83
# File 'lib/cryptomus/client.rb', line 81

def connection
  @connection ||= Connection.new
end

.create_payment(attributes) ⇒ Hash

Examples:

Cryptomus::Client.create_invoice(
  order_id: '123',
  currency: 'USD',
  amount: '100'
)

Parameters:

  • attributes (Hash)

Options Hash (attributes):

  • :order_id (String)

    required

  • :currency (String)

    required

  • :amount (String)

    required

Returns:

  • (Hash)

Raises:



20
21
22
# File 'lib/cryptomus/client.rb', line 20

def create_payment(attributes)
  connection.post('/v1/payment', body: attributes)
end

.create_wallet(attributes) ⇒ Hash

Examples:

Cryptomus::Client.create_wallet(
  order_id: '123',
  currency: 'USDT',
  network: 'tron'
)

Parameters:

  • attributes (Hash)

Options Hash (attributes):

  • :order_id (String)

    required

  • :currency (String)

    required

  • :network (String)

    required

Returns:

  • (Hash)

Raises:



68
69
70
# File 'lib/cryptomus/client.rb', line 68

def create_wallet(attributes)
  connection.post('/v1/wallet', body: attributes)
end

.list_payments(cursor: nil, date_from: nil, date_to: nil) ⇒ Hash

Parameters:

  • cursor (String, nil) (defaults to: nil)

    from previous response paginate.nextCursor or paginate.previousCursor

  • date_from (String, nil) (defaults to: nil)

    format: ‘YYYY-MM-DD H:mm:ss’

  • date_to (String, nil) (defaults to: nil)

    format: ‘YYYY-MM-DD H:mm:ss’

Returns:

  • (Hash)

Raises:



30
31
32
33
34
35
36
# File 'lib/cryptomus/client.rb', line 30

def list_payments(cursor: nil, date_from: nil, date_to: nil)
  attributes = { date_from:, date_to: }.compact
  attributes = nil if attributes.empty?
  query = { cursor: }.compact
  query = nil if query.empty?
  connection.post('/v1/payment/list', body: attributes, query:)
end

.list_servicesHash

Returns:

  • (Hash)

Raises:



51
52
53
# File 'lib/cryptomus/client.rb', line 51

def list_services
  connection.post('/v1/payment/services', body: {})
end

.payment(uuid: nil, order_id: nil) ⇒ Hash

Parameters:

  • uuid (String, nil) (defaults to: nil)

    uuid or order_id must be passed.

  • order_id (String, nil) (defaults to: nil)

    uuid or order_id must be passed.

Returns:

  • (Hash)

Raises:



43
44
45
46
# File 'lib/cryptomus/client.rb', line 43

def payment(uuid: nil, order_id: nil)
  attributes = { uuid:, order_id: }.compact
  connection.post('/v1/payment/info', body: attributes)
end