Skip to content

Commit 904e054

Browse files
authored
Merge pull request #17 from OpenSTFoundation/release-1.0
Release 1.0
2 parents bd42837 + f952ac6 commit 904e054

22 files changed

+969
-247
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[OST Ruby SDK v1.0.0](https://github.com/OpenSTFoundation/ost-sdk-ruby/tree/v1.0.0) May 17 2018
2+
---
3+
4+
* Added support for interacting with V1 API along with V0
5+
* [README.md](README.md) has API V1 usage instructions
6+
* [README_V0.md](README.md) has API V0 usage instructions
7+
8+
[OST Ruby SDK v0.9.2](https://github.com/OpenSTFoundation/ost-sdk-ruby/tree/v0.9.2) March 15 2018
9+
---
10+
Initial release of the official OST Ruby SDK<br />
11+
This release has the OST API V0 interaction layer implementation.

README.md

Lines changed: 93 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,105 +32,162 @@ require('ost-sdk-ruby')
3232
Set variables for initializing SDK objects:
3333

3434
```ruby
35-
environment = 'sandbox'
36-
credentials = OSTSdk::Util::APICredentials.new(<api_key>, <api_secret>)
35+
ost_sdk = OSTSdk::Saas::Services.new({api_key: <api_key>, api_secret: <api_secret>, api_base_url: <api_base_url>})
3736
```
3837

39-
### Transaction Kind Module
38+
### Users Module
4039

41-
Initialize a `TransactionKind` object to perform transaction-related actions:
40+
```ruby
41+
ost_users_object = ost_sdk.services.users
42+
```
43+
44+
Create a new user:
4245

4346
```ruby
44-
ostTransactionKindObject = OSTSdk::Saas::TransactionKind.new(environment, credentials)
47+
ost_users_object.create(name: 'Alice').to_json
4548
```
4649

47-
Create new transaction kinds:
50+
Edit an existing user:
4851

4952
```ruby
50-
ostTransactionKindObject.create(name: 'Like', kind: 'user_to_user', currency_type: 'usd', currency_value: '1.25', commission_percent: '12')
53+
ost_users_object.edit(id: 'e55feef0-26e6-438a-9f1a-f348ce2e3c44', name: 'Bob').to_json
5154
```
5255

56+
Get an existing user:
57+
58+
```ruby
59+
ost_users_object.get(id: 'e55feef0-26e6-438a-9f1a-f348ce2e3c44').to_json
60+
```
61+
62+
Get a list of users and other data:
63+
5364
```ruby
54-
ostTransactionKindObject.create(name: 'Grant', kind: 'company_to_user', currency_type: 'bt', currency_value: '12', commission_percent: '0')
65+
ost_users_object.list({page_no: 1, limit: 5}).to_json
5566
```
5667

68+
### Airdrops Module
69+
5770
```ruby
58-
ostTransactionKindObject.create(name: 'Buy', kind: 'user_to_company', currency_type: 'bt', currency_value: '100', commission_percent: '0')
71+
ost_airdrop_object = ost_sdk.services.airdrops
5972
```
6073

61-
Get a list of existing transaction kinds and other data:
74+
Execute Airdrop:
6275

6376
```ruby
64-
ostTransactionKindObject.list()
77+
ost_airdrop_object.execute({amount: 1, user_ids: 'e55feef0-26e6-438a-9f1a-f348ce2e3c44'}).to_json
6578
```
6679

67-
Edit an existing transaction kind:
80+
Get Airdrop Status:
81+
```ruby
82+
ost_airdrop_object.get({id: 'ecd9b0b2-a0f4-422c-95a4-f25f8fc88334'}).to_json
83+
```
6884

85+
List Airdrop
6986
```ruby
70-
ostTransactionKindObject.edit(client_transaction_id: '12', name: 'New Transaction Kind')
87+
ost_airdrop_object.list({page_no: 1, limit: 50, current_status: 'processing,complete'}).to_json
7188
```
7289

73-
Execute a branded token transfer by transaction kind:
90+
91+
### Token Module
7492

7593
```ruby
76-
ostTransactionKindObject.execute(from_uuid: '1234-1928-1081dsds-djhksjd', to_uuid: '1234-1928-1081-1223232', transaction_kind: 'Purchase')
94+
ost_token_object = ost_sdk.services.token
7795
```
7896

79-
Get the status of an executed transaction:
80-
97+
Get details:
98+
8199
```ruby
82-
ostTransactionKindObject.status(transaction_uuids: ['5f79063f-e22a-4d28-99d7-dd095f02c72e'])
100+
ost_token_object.get({}).to_json
83101
```
84102

85-
### Users Module
103+
### Actions Module
86104

87-
Initialize a `Users` object to perform user specific actions:
88105

89106
```ruby
90-
ostUsersObject = OSTSdk::Saas::Users.new(environment, credentials)
107+
ost_action_object = ost_sdk.services.actions
91108
```
92109

93-
Create a new user:
110+
Create a new action:
94111

95112
```ruby
96-
ostUsersObject.create(name: 'Alice')
113+
ost_action_object.create({name: 'Test', kind: 'user_to_user', currency: 'USD', arbitrary_amount: false, amount: 1.01,
114+
arbitrary_commission: true}).to_json
97115
```
98116

99-
Get a list of users and other data:
117+
Edit an action:
100118

101119
```ruby
102-
ostUsersObject.list()
120+
ost_action_object.edit({id: 1234, amount: 2}).to_json
103121
```
104122

105-
Edit an existing user:
123+
Get an action:
124+
125+
```ruby
126+
ost_action_object.get(id: 1234).to_json
127+
```
106128

129+
List actions:
130+
131+
```ruby
132+
ost_action_object.list(page_no: 1).to_json
133+
```
134+
135+
### Transaction Module
136+
137+
```ruby
138+
ost_transaction_object = ost_sdk.services.transactions
139+
```
140+
141+
Execute Transaction:
142+
143+
```ruby
144+
ost_transaction_object.execute({from_user_id:'f87346e4-61f6-4d55-8cb8-234c65437b01', to_user_id:'c07bd853-e893-4400-b7e8-c358cfa05d85', action_id:'20145'}).to_json
145+
```
146+
147+
Get Transaction Status:
148+
```ruby
149+
ost_transaction_object.get({id: '0ab712ec-dc41-4e31-ac31-c93bc148bbb9'}).to_json
150+
```
151+
152+
List Transactions
107153
```ruby
108-
ostUsersObject.edit(uuid: '1234-1928-1081dsds-djhksjd', name: 'Bob')
154+
ost_transaction_object.list({page_no: 1, limit: 50}).to_json
109155
```
110156

111-
Airdrop branded tokens to users:
157+
### Transfer Module
112158

113159
```ruby
114-
ostUsersObject.airdrop_tokens(amount: 100, list_type: 'all')
160+
ost_transfer_object = ost_sdk.services.transfers
115161
```
116162

117-
As airdropping tokens is an asynchronous task, you can check the airdrop's status:
163+
Execute Transfer:
118164

119165
```ruby
120-
ostUsersObject.get_airdrop_status(airdrop_uuid: '1234-1928-1081dsds-djhksjd')
166+
ost_transfer_object.execute({to_address:'0xd2b789293674faEE51bEb2d0338d15401dEbfdE3', amount:1}).to_json
167+
```
168+
169+
Get Transfer Status:
170+
```ruby
171+
ost_transfer_object.get({id: 'd0589dc5-d0a0-4996-b9f8-847295fd2c3b'}).to_json
172+
```
173+
174+
List Transfers
175+
```ruby
176+
ost_transfer_object.list().to_json
121177
```
122178

123179
### Request Specs
124180

125-
To obtain request/API specification, pass in `true` for the optional `api_spec` parameter when initializing a `TransactionKind` or `Users` module object:
181+
To obtain request/API specification, pass in `true` for the optional `api_spec` parameter when initializing SDK object:
126182

127183
```ruby
128-
ostTransactionKindObject = OSTSdk::Saas::TransactionKind.new(environment, credentials, true)
184+
ost_sdk = OSTSdk::Saas::Services.new({api_key: <api_key>, api_secret: <api_secret>, api_base_url: <api_base_url>, api_spec: true})
185+
ost_action_object = ost_sdk.services.actions
129186
```
130187

131188
And then call a method:
132189

133190
```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-
```
191+
ost_action_object.list().to_json
192+
{:success=>true, :data=>{:request_uri=>"https://playground2api.stagingost.com/v1/actions/", :request_type=>"GET", :request_params=>"request_timestamp=1526541627&signature=410f6fef1ab2ad34e74caef589a15b56490b63a316fc46509d31bb133bf11678&api_key=7cad25e082390a90114e"}}
193+
```

README_V0.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Ost::Sdk::Ruby
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/docs/0.9.1/simpletoken.html/)
15+
16+
## Installation
17+
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+
ost_sdk = OSTSdk::Saas::Services.new({api_key: <api_key>, api_secret: <api_secret>, api_base_url: <api_base_url>})
36+
```
37+
38+
### Transaction Kind Module
39+
40+
41+
```ruby
42+
ost_transaction_object = ost_sdk.services.transaction_kind
43+
```
44+
45+
Create new transaction kinds:
46+
47+
```ruby
48+
ost_transaction_object.create(name: 'Like', kind: 'user_to_user', currency_type: 'usd', currency_value: '1.25', commission_percent: '12').to_json
49+
```
50+
51+
```ruby
52+
ost_transaction_object.create(name: 'Grant', kind: 'user_to_user', currency_type: 'bt', currency_value: '12', commission_percent: '0').to_json
53+
```
54+
55+
```ruby
56+
ost_transaction_object.create(name: 'Buy', kind: 'user_to_company', currency_type: 'bt', currency_value: '100').to_json
57+
```
58+
59+
Get a list of existing transaction kinds and other data:
60+
61+
```ruby
62+
ost_transaction_object.list().to_json
63+
```
64+
65+
Edit an existing transaction kind:
66+
67+
```ruby
68+
ost_transaction_object.edit(client_transaction_id: '21728', name: 'New Transaction Kind').to_json
69+
```
70+
71+
Execute a branded token transfer by transaction kind:
72+
73+
```ruby
74+
ost_transaction_object.execute(from_uuid: 'aeb9e7e3-a054-4883-a005-0bd8c4f0df7a', to_uuid: '53d906b3-ce0c-4798-8aa7-b1352daab757', transaction_kind: 'Upvote').to_json
75+
```
76+
77+
Get the status of an executed transaction:
78+
79+
```ruby
80+
ost_transaction_object.status(transaction_uuids: ['b6f099a3-2a65-431e-b3ec-54056d7d81eb']).to_json
81+
```
82+
83+
### Users Module
84+
85+
```ruby
86+
ost_users_object = ost_sdk.services.users
87+
```
88+
89+
Create a new user:
90+
91+
```ruby
92+
ost_users_object.create(name: 'Alice').to_json
93+
```
94+
95+
Get a list of users and other data:
96+
97+
```ruby
98+
ost_users_object.list().to_json
99+
```
100+
101+
Edit an existing user:
102+
103+
```ruby
104+
ost_users_object.edit(uuid: 'ab1aa227-0545-4d7a-9921-abe9d9c34146', name: 'BobTheBuilder').to_json
105+
```
106+
107+
Airdrop branded tokens to users:
108+
109+
```ruby
110+
ost_users_object.airdrop_tokens(amount: 1, list_type: 'never_airdropped').to_json
111+
```
112+
113+
As airdropping tokens is an asynchronous task, you can check the airdrop's status:
114+
115+
```ruby
116+
ost_users_object.get_airdrop_status(airdrop_uuid: 'd2b8714d-cc2e-46ba-beca-313de32d0280').to_json
117+
```
118+
119+
### Request Specs
120+
121+
To obtain request/API specification, pass in `true` for the optional `api_spec` parameter when initializing SDK object:
122+
123+
```ruby
124+
ost_sdk = OSTSdk::Saas::Services.new({api_key: <api_key>, api_secret: <api_secret>, api_base_url: <api_base_url>, api_spec: true})
125+
ost_transaction_object = ost_sdk.services.transaction_kind
126+
```
127+
128+
And then call a method:
129+
130+
```ruby
131+
ost_transaction_object.list().to_json
132+
{:success=>true, :data=>{:request_uri=>"https://playground2api.stagingost.com/transaction-types/list", :request_type=>"GET", :request_params=>"request_timestamp=1526540175&signature=6c2819714cd184fbb3ff5f495724bea3737679074055a5c90698d6a317515323&api_key=7cad25e082390a90114e"}}
133+
```

lib/ost-sdk-ruby/saas.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1+
require_relative 'saas/services'
2+
13
require_relative 'saas/base'
2-
require_relative 'saas/transaction_kind'
3-
require_relative 'saas/users'
4+
5+
require_relative 'saas/v0/services'
6+
require_relative 'saas/v0/transaction_kind'
7+
require_relative 'saas/v0/users'
8+
9+
require_relative 'saas/v1/services'
10+
require_relative 'saas/v1/users'
11+
require_relative 'saas/v1/token'
12+
require_relative 'saas/v1/actions'
13+
require_relative 'saas/v1/airdrops'
14+
require_relative 'saas/v1/transfers'
15+
require_relative 'saas/v1/transactions'
416

517
module OSTSdk
618

0 commit comments

Comments
 (0)