|
1 | 1 | # Ost::Sdk::Ruby
|
2 | 2 |
|
| 3 | +A Ruby wrapper for the [OST Developers API](https://dev.ost.com/). |
| 4 | + |
| 5 | +## Requirements |
| 6 | + |
| 7 | +To use this gem, developers will need to: |
| 8 | +1. Sign-up on [https://kit.ost.com](https://kit.ost.com). |
| 9 | +2. Launch a branded token economy with the OST KIT Economy Planner. |
| 10 | +3. Obtain an API Key and API Secret from [https://kit.ost.com/developer-api-console](https://kit.ost.com/developer-api-console). |
| 11 | + |
| 12 | +## Documentation |
| 13 | + |
| 14 | +[https://dev.ost.com/](https://dev.ost.com/) |
| 15 | + |
3 | 16 | ## Installation
|
4 | 17 |
|
5 |
| -Add this line to your application's Gemfile: |
6 |
| - |
7 |
| - gem 'ost-sdk-ruby' |
8 |
| - |
9 |
| -And then execute: |
10 |
| - |
11 |
| - $ bundle |
12 |
| - |
13 |
| -Or install it yourself as: |
14 |
| - |
15 |
| - $ gem install ost-sdk-ruby |
16 |
| - |
17 |
| -## Usage |
18 |
| - |
19 |
| -1. TransactionKind Module |
20 |
| - |
21 |
| - environment = 'sandbox' # possible values sandbox / production |
22 |
| - |
23 |
| - credentials = OSTSdk::Util::APICredentials.new('2fb1cd4ff54f8d842805', '018215e8eeda1084ebcf1fefb5b702799a2d52d0cda955209d98e65bd55a69e0') |
24 |
| - |
25 |
| - obj = OSTSdk::Saas::TransactionKind.new(environment, credentials) |
26 |
| - |
27 |
| - obj.list() |
28 |
| - |
29 |
| - obj.create(name: 'ABC', kind: 'user_to_user', value_currency_type: 'usd', value_in_usd: '1.1', value_in_bt: '1.1', commission_percent: '0.0') |
30 |
| - |
31 |
| - obj.edit(client_transaction_id: '12', name: 'test_1_1_1') |
32 |
| - |
33 |
| -2. Address Module |
34 |
| - |
35 |
| - environment = 'sandbox' # possible values sandbox / production |
36 |
| - |
37 |
| - credentials = OSTSdk::Util::APICredentials.new('2fb1cd4ff54f8d842805', '018215e8eeda1084ebcf1fefb5b702799a2d52d0cda955209d98e65bd55a69e0') |
38 |
| - |
39 |
| - obj = OSTSdk::Saas::Addresses.new(environment, credentials) |
40 |
| - |
41 |
| - obj.fetch_balances(balance_types: ['ost', 'ostPrime', 'eth', 'FRC'], address_uuid: '0xddA2cB099235F657b77b8ABf055725c88cbc6112') |
42 |
| - |
43 |
| -3. User Module |
44 |
| - |
45 |
| - obj = OSTSdk::Saas::Users.new(environment, credentials) |
46 |
| - |
47 |
| - obj.create(name: 'test test') |
48 |
| - |
49 |
| - obj.edit(name: 'test test', address_uuid: '0xddA2cB099235F657b77b8ABf055725c88cbc6112') |
50 |
| - |
51 |
| - obj.list() |
52 |
| - |
53 |
| -## Contributing |
54 |
| - |
55 |
| -1. Fork it ( https://github.com/[my-github-username]/ost-sdk-ruby/fork ) |
56 |
| -2. Create your feature branch (`git checkout -b my-new-feature`) |
57 |
| -3. Commit your changes (`git commit -am 'Add some feature'`) |
58 |
| -4. Push to the branch (`git push origin my-new-feature`) |
59 |
| -5. Create a new Pull Request |
| 18 | +Install OST Ruby SDK |
| 19 | + |
| 20 | +```bash |
| 21 | +> gem install ost-sdk-ruby |
| 22 | +``` |
| 23 | + |
| 24 | +## Example Usage |
| 25 | + |
| 26 | +Require the OST Ruby SDK: |
| 27 | + |
| 28 | +```ruby |
| 29 | +require('ost-sdk-ruby') |
| 30 | +``` |
| 31 | + |
| 32 | +Set variables for initializing SDK objects: |
| 33 | + |
| 34 | +```ruby |
| 35 | +environment = 'sandbox' |
| 36 | +credentials = OSTSdk::Util::APICredentials.new(<api_key>, <api_secret>) |
| 37 | +``` |
| 38 | + |
| 39 | +### Transaction Kind Module |
| 40 | + |
| 41 | +Initialize a `TransactionKind` object to perform transaction-related actions: |
| 42 | + |
| 43 | +```ruby |
| 44 | +ostTransactionKindObject = OSTSdk::Saas::TransactionKind.new(environment, credentials) |
| 45 | +``` |
| 46 | + |
| 47 | +Create new transaction kinds: |
| 48 | + |
| 49 | +```ruby |
| 50 | +ostTransactionKindObject.create(name: 'Like', kind: 'user_to_user', currency_type: 'usd', currency_value: '1.25', commission_percent: '12') |
| 51 | +``` |
| 52 | + |
| 53 | +```ruby |
| 54 | +ostTransactionKindObject.create(name: 'Grant', kind: 'company_to_user', currency_type: 'bt', currency_value: '12', commission_percent: '0') |
| 55 | +``` |
| 56 | + |
| 57 | +```ruby |
| 58 | +ostTransactionKindObject.create(name: 'Buy', kind: 'user_to_company', currency_type: 'bt', currency_value: '100', commission_percent: '0') |
| 59 | +``` |
| 60 | + |
| 61 | +Get a list of existing transaction kinds and other data: |
| 62 | + |
| 63 | +```ruby |
| 64 | +ostTransactionKindObject.list() |
| 65 | +``` |
| 66 | + |
| 67 | +Edit an existing transaction kind: |
| 68 | + |
| 69 | +```ruby |
| 70 | +ostTransactionKindObject.edit(client_transaction_id: '12', name: 'New Transaction Kind') |
| 71 | +``` |
| 72 | + |
| 73 | +Execute a branded token transfer by transaction kind: |
| 74 | + |
| 75 | +```ruby |
| 76 | +ostTransactionKindObject.execute(from_uuid: '1234-1928-1081dsds-djhksjd', to_uuid: '1234-1928-1081-1223232', transaction_kind: 'Purchase') |
| 77 | +``` |
| 78 | + |
| 79 | +Get the status of an executed transaction: |
| 80 | + |
| 81 | +```ruby |
| 82 | +ostTransactionKindObject.status(transaction_uuids: ['5f79063f-e22a-4d28-99d7-dd095f02c72e']) |
| 83 | +``` |
| 84 | + |
| 85 | +### Users Module |
| 86 | + |
| 87 | +Initialize a `Users` object to perform user specific actions: |
| 88 | + |
| 89 | +```ruby |
| 90 | +ostUsersObject = OSTSdk::Saas::Users.new(environment, credentials) |
| 91 | +``` |
| 92 | + |
| 93 | +Create a new user: |
| 94 | + |
| 95 | +```ruby |
| 96 | +ostUsersObject.create(name: 'Alice') |
| 97 | +``` |
| 98 | + |
| 99 | +Get a list of users and other data: |
| 100 | + |
| 101 | +```ruby |
| 102 | +ostUsersObject.list() |
| 103 | +``` |
| 104 | + |
| 105 | +Edit an existing user: |
| 106 | + |
| 107 | +```ruby |
| 108 | +ostUsersObject.edit(uuid: '1234-1928-1081dsds-djhksjd', name: 'Bob') |
| 109 | +``` |
| 110 | + |
| 111 | +Airdrop branded tokens to users: |
| 112 | + |
| 113 | +```ruby |
| 114 | +ostUsersObject.airdrop_tokens(amount: 100, list_type: 'all') |
| 115 | +``` |
| 116 | + |
| 117 | +As airdropping tokens is an asynchronous task, you can check the airdrop's status: |
| 118 | + |
| 119 | +```ruby |
| 120 | +ostUsersObject.get_airdrop_status(airdrop_uuid: '1234-1928-1081dsds-djhksjd') |
| 121 | +``` |
| 122 | + |
| 123 | +### Request Specs |
| 124 | + |
| 125 | +To obtain request/API specification, pass in `true` for the optional `api_spec` parameter when initializing a `TransactionKind` or `Users` module object: |
| 126 | + |
| 127 | +```ruby |
| 128 | +ostTransactionKindObject = OSTSdk::Saas::TransactionKind.new(environment, credentials, true) |
| 129 | +``` |
| 130 | + |
| 131 | +And then call a method: |
| 132 | + |
| 133 | +```ruby |
| 134 | +> ostTransactionKindObject.list() |
| 135 | +=> #<OSTSdk::Util::Result:0x007ffccab36c98 @error=nil, @error_message=nil, @error_data=nil, @error_display_text=nil, @error_display_heading=nil, @message=nil, @http_code=200, @data={:request_uri=>"https://sandboxapi.ost.com/transaction-types/list", :request_type=>"GET", :request_params=>"request_timestamp=<request_epoch_timestamp>&signature=<signature>&api_key=<api_key>"}> |
| 136 | +``` |
0 commit comments