Class: SilaRuby::Transactions

Inherits:
Object
  • Object
show all
Includes:
ApiHelpers
Defined in:
lib/sila-ruby/transactions.rb

Overview

==============================================

TRANSACTIONS =================================

Class Method Summary collapse

Methods included from ApiHelpers

included

Class Method Details

.get_transactions(handle, params = {}, user_key) ⇒ Object


GET-TRANSACTIONS ---------------------------

Gets array of user handle's transactions with detailed status information



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/sila-ruby/transactions.rb', line 74

def self.get_transactions(handle, params={}, user_key)
  header = { user_handle: handle }
  message = 'get_transactions_msg'

  # Example of params passed
  #
  # params = {
  #   search_filters: {
  #     transaction_id: "some UUID string assigned by Sila",
  #     reference_id: "the reference string sent in the header object when transaction request was made",
  #     show_timelines: true,
  #     sort_ascending: false,
  #     max_sila_amount: 1300,
  #     min_sila_amount: 1000,
  #     statuses: ["pending", "successful", "failed", "complete"],
  #     start_epoch: 1234567860,
  #     end_epoch: 1234567891,
  #     page: 1,
  #     per_page: 20,
  #     transaction_types: ["issue", "redeem", "transfer"]
  #   }
  # }

  post_signed('get_transactions', header, message, params, user_key)
end

.issue_sila(handle, params = {}, user_key) ⇒ Object


ISSUE-SILA ---------------------------------

Debits a specified account and issues tokens to the address belonging to the requested handle



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sila-ruby/transactions.rb', line 20

def self.issue_sila(handle, params={}, user_key)
  header = { user_handle: handle }
  message = 'issue_msg'

  # Example of params passed
  #
  # params = {
  #   amount: 1000,
  #   account_name: "default"
  # }

  post_signed('issue_sila', header, message, params, user_key)
end

.redeem_sila(handle, params = {}, user_key) ⇒ Object


REDEEM-SILA --------------------------------

Burns given amount of SILA at the handle's blockchain address and credits their named bank account in the equivalent monetary amount



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/sila-ruby/transactions.rb', line 56

def self.redeem_sila(handle, params={}, user_key)
  header = { user_handle: handle }
  message = 'redeem_msg'

  # Example of params passed
  #
  # params = {
  #   amount: 1000,
  #   account_name: "default"
  # }

  post_signed('redeem_sila', header, message, params, user_key)
end

.transfer_sila(handle, params = {}, user_key) ⇒ Object


TRANSFER-SILA ------------------------------

Starts a transfer of the requested amount of SILA to the requested destination handle



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/sila-ruby/transactions.rb', line 38

def self.transfer_sila(handle, params={}, user_key)
  header = { user_handle: handle }
  message = 'transfer_msg'

  # Example of params passed
  #
  # params = {
  #   amount: 1000,
  #   destination: "user2.silamoney.eth"
  # }

  post_signed('transfer_sila', header, message, params, user_key)
end