Skip to content

Commit a1fe022

Browse files
author
Rachin Kapoor
authored
Merge pull request #8 from OpenSTFoundation/rachin/api-v1.1
Changes to support API v1.1
2 parents 396530b + 13e7de3 commit a1fe022

35 files changed

Lines changed: 870 additions & 125 deletions

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To use this node module, developers will need to:
2424
<dependency>
2525
<groupId>com.ost</groupId>
2626
<artifactId>ost-sdk-java</artifactId>
27-
<version>1.0.1.beta.1</version>
27+
<version>1.1.0.beta.4</version>
2828
</dependency>
2929
```
3030

@@ -55,19 +55,19 @@ The jar file can be found in the target folder.
5555
Initialize the SDK object:
5656

5757
```java
58-
// the latest valid API endpoint is "https://sandboxapi.ost.com/v1/", this may change in the future
58+
// the latest valid API endpoint is "https://sandboxapi.ost.com/v1.1/", this may change in the future
5959
HashMap <String,Object> sdkConfig = new HashMap<String,Object>();
6060
sdkConfig.put("apiEndpoint","[V1_API_ENDPOINT]");
6161
sdkConfig.put("apiKey","[YOUR_API_KEY]");
6262
sdkConfig.put("apiSecret","[YOUR_API_SECRET]");
6363
OSTSDK ostObj = new OSTSDK(sdkConfig);
64-
com.ost.services.v1.Manifest services = (com.ost.services.v1.Manifest) ostObj.services;
64+
com.ost.services.v1_1.Manifest services = (com.ost.services.v1_1.Manifest) ostObj.services;
6565
```
6666

6767
### Users Module
6868

6969
```java
70-
com.ost.services.v1.Users userService = services.users;
70+
com.ost.services.v1_1.Users userService = services.users;
7171
```
7272

7373
Create a new user:
@@ -109,7 +109,7 @@ System.out.println("response: " + response.toString() );
109109
### Airdrops Module
110110

111111
```java
112-
com.ost.services.v1.Airdrops airdropService = services.airdrops;
112+
com.ost.services.v1_1.Airdrops airdropService = services.airdrops;
113113
```
114114

115115
Execute Airdrop:
@@ -146,7 +146,7 @@ System.out.println("response: " + response.toString() );
146146
### Token Module
147147

148148
```java
149-
com.ost.services.v1.Token tokenService = services.token;
149+
com.ost.services.v1_1.Token tokenService = services.token;
150150
```
151151

152152
Get details:
@@ -161,7 +161,7 @@ System.out.println("response: " + response.toString() );
161161

162162

163163
```java
164-
com.ost.services.v1.Actions actionService = services.actions;
164+
com.ost.services.v1_1.Actions actionService = services.actions;
165165
```
166166

167167
Create a new action:
@@ -208,7 +208,7 @@ System.out.println("response: " + response.toString() );
208208
### Transaction Module
209209

210210
```java
211-
com.ost.services.v1.Transactions transactionService = services.transactions;
211+
com.ost.services.v1_1.Transactions transactionService = services.transactions;
212212
```
213213

214214
Execute Transaction:
@@ -243,7 +243,7 @@ System.out.println("response: " + response.toString() );
243243
### Transfer Module
244244

245245
```java
246-
com.ost.services.v1.Transfer transferService = ostObj.services.transfers;
246+
com.ost.services.v1_1.Transfer transferService = ostObj.services.transfers;
247247
```
248248

249249
Execute ST Prime Transfer:
@@ -275,7 +275,7 @@ JsonObject response = transferService.list( params );
275275
### Balance Module
276276

277277
```java
278-
com.ost.services.v1.Balances balanceService = ostObj.services.balances;
278+
com.ost.services.v1_1.Balances balanceService = ostObj.services.balances;
279279
```
280280

281281
Get user balance:
@@ -290,7 +290,7 @@ System.out.println("response: " + response.toString() );
290290
### Ledger Module
291291

292292
```java
293-
com.ost.services.v1.Ledger ledgerService = ostObj.services.ledger;
293+
com.ost.services.v1_1.Ledger ledgerService = ostObj.services.ledger;
294294
```
295295

296296
Get transaction ledger for user:

README_V1.md

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
# OST Java SDK
2+
The official [OST Java SDK](https://dev.ost.com/).
3+
4+
5+
[![Travis](https://travis-ci.org/OpenSTFoundation/ost-sdk-java.svg?branch=master)](https://travis-ci.org/OpenSTFoundation/ost-sdk-java)
6+
[![Gitter: JOIN CHAT](https://img.shields.io/badge/gitter-JOIN%20CHAT-brightgreen.svg)](https://gitter.im/OpenSTFoundation/SimpleToken)
7+
8+
## Requirements
9+
10+
To use this node module, developers will need to:
11+
1. Sign-up on [https://kit.ost.com](https://kit.ost.com).
12+
2. Launch a branded token economy with the OST KIT Economy Planner.
13+
3. Obtain an API Key and API Secret from [https://kit.ost.com/developer-api-console](https://kit.ost.com/developer-api-console).
14+
15+
## Documentation
16+
17+
[https://dev.ost.com/](https://dev.ost.com/)
18+
19+
## Installation
20+
21+
### Maven users
22+
#### Add this dependency to your project's POM:
23+
```xml
24+
<dependency>
25+
<groupId>com.ost</groupId>
26+
<artifactId>ost-sdk-java</artifactId>
27+
<version>1.1.0.beta.4</version>
28+
</dependency>
29+
```
30+
31+
### Building from source using Maven
32+
33+
Clone the repository
34+
```bash
35+
git clone https://github.com/OpenSTFoundation/ost-sdk-java.git
36+
cd ost-sdk-java
37+
```
38+
39+
40+
Package using MVN (without dependencies)
41+
```bash
42+
mvn clean pacakge -DskipTests
43+
```
44+
45+
With dependencies
46+
```bash
47+
mvn clean compile assembly:single -DskipTests
48+
```
49+
50+
The jar file can be found in the target folder.
51+
52+
## Example Usage
53+
54+
55+
Initialize the SDK object:
56+
57+
```java
58+
// the latest valid API endpoint is "https://sandboxapi.ost.com/v1/", this may change in the future
59+
HashMap <String,Object> sdkConfig = new HashMap<String,Object>();
60+
sdkConfig.put("apiEndpoint","[V1_API_ENDPOINT]");
61+
sdkConfig.put("apiKey","[YOUR_API_KEY]");
62+
sdkConfig.put("apiSecret","[YOUR_API_SECRET]");
63+
OSTSDK ostObj = new OSTSDK(sdkConfig);
64+
com.ost.services.v1.Manifest services = (com.ost.services.v1.Manifest) ostObj.services;
65+
```
66+
67+
### Users Module
68+
69+
```java
70+
com.ost.services.v1.Users userService = services.users;
71+
```
72+
73+
Create a new user:
74+
75+
```java
76+
HashMap <String,Object> params = new HashMap<String,Object>();
77+
params.put("name", "Alice");
78+
JsonObject response = userService.create( params );
79+
System.out.println("response: " + response.toString() );
80+
```
81+
82+
Edit an existing user:
83+
84+
```java
85+
HashMap <String,Object> params = new HashMap<String,Object>();
86+
params.put("id", "1234-1928-1081dsds-djhksjd");
87+
params.put("name", "Bob");
88+
JsonObject response = userService.edit( params );
89+
System.out.println("response: " + response.toString() );
90+
```
91+
92+
Get an existing user:
93+
94+
```java
95+
HashMap <String,Object> params = new HashMap<String,Object>();
96+
params.put("id", "1234-1928-1081dsds-djhksjd");
97+
JsonObject response = userService.get( params );
98+
System.out.println("response: " + response.toString() );
99+
```
100+
101+
Get a list of users and other data:
102+
103+
```java
104+
HashMap <String,Object> params = new HashMap<String,Object>();
105+
JsonObject response = userService.list( params );
106+
System.out.println("response: " + response.toString() );
107+
```
108+
109+
### Airdrops Module
110+
111+
```java
112+
com.ost.services.v1.Airdrops airdropService = services.airdrops;
113+
```
114+
115+
Execute Airdrop:
116+
117+
```java
118+
HashMap <String,Object> params = new HashMap<String,Object>();
119+
params.put("amount", 1);
120+
params.put("user_ids", "f87346e4-61f6-4d55-8cb8-234c65437b01");
121+
JsonObject response = airdropService.execute( params );
122+
System.out.println("response: " + response.toString() );
123+
```
124+
125+
Get Airdrop Status:
126+
127+
```java
128+
HashMap <String,Object> params = new HashMap<String,Object>();
129+
params.put("id", 'ecd9b0b2-a0f4-422c-95a4-f25f8fc88334');
130+
JsonObject response = airdropService.get( params );
131+
System.out.println("response: " + response.toString() );
132+
```
133+
134+
List Airdrop
135+
136+
```java
137+
HashMap <String,Object> params = new HashMap<String,Object>();
138+
params.put("page_no", 1);
139+
params.put("limit", 50);
140+
params.put("current_status", "processing,complete");
141+
JsonObject response = airdropService.list( params );
142+
System.out.println("response: " + response.toString() );
143+
```
144+
145+
146+
### Token Module
147+
148+
```java
149+
com.ost.services.v1.Token tokenService = services.token;
150+
```
151+
152+
Get details:
153+
154+
```java
155+
HashMap <String,Object> params = new HashMap<String,Object>();
156+
JsonObject response = tokenService.get( params );
157+
System.out.println("response: " + response.toString() );
158+
```
159+
160+
### Actions Module
161+
162+
163+
```java
164+
com.ost.services.v1.Actions actionService = services.actions;
165+
```
166+
167+
Create a new action:
168+
169+
```java
170+
HashMap <String,Object> params = new HashMap<String,Object>();
171+
params.put("name", "Voteup");
172+
params.put("kind", "user_to_user");
173+
params.put("currency", "USD");
174+
params.put("arbitrary_amount", false);
175+
params.put("amount", 1.01);
176+
params.put("arbitrary_commission", false);
177+
params.put("commission_percent", 1);
178+
JsonObject response = actionService.create( params );
179+
System.out.println("response: " + response.toString() );
180+
```
181+
182+
Edit an action:
183+
184+
```java
185+
HashMap <String,Object> params = new HashMap<String,Object>();
186+
params.put("id", 22599);
187+
params.put("name", "Like");
188+
JsonObject response = actionService.edit( params );
189+
```
190+
191+
Get an action:
192+
193+
```java
194+
HashMap <String,Object> params = new HashMap<String,Object>();
195+
params.put("id", 22599);
196+
JsonObject response = actionService.get( params );
197+
System.out.println("response: " + response.toString() );
198+
```
199+
200+
List actions:
201+
202+
```java
203+
HashMap <String,Object> params = new HashMap<String,Object>();
204+
JsonObject response = actionService.list( params );
205+
System.out.println("response: " + response.toString() );
206+
```
207+
208+
### Transaction Module
209+
210+
```java
211+
com.ost.services.v1.Transactions transactionService = services.transactions;
212+
```
213+
214+
Execute Transaction:
215+
216+
```java
217+
HashMap <String,Object> params = new HashMap<String,Object>();
218+
params.put("from_user_id", "0a201640-77a7-49c8-b289-b6b5d7325323");
219+
params.put("to_user_id", "24580db2-bf29-4d73-bf5a-e1d0cf8c8928");
220+
params.put("action_id", "22599");
221+
JsonObject response = transactionService.execute( params );
222+
System.out.println("response: " + response.toString() );
223+
```
224+
225+
Get Transaction Status:
226+
227+
```java
228+
HashMap <String,Object> params = new HashMap<String,Object>();
229+
params.put("id", "84d97848-074f-4a9a-a214-19076cfe9dd1");
230+
JsonObject response = transactionService.get( params );
231+
```
232+
233+
List Transactions:
234+
235+
```java
236+
HashMap <String,Object> params = new HashMap<String,Object>();
237+
params.put("page_no", 1);
238+
params.put("limit", 10);
239+
JsonObject response = transactionService.list( params );
240+
System.out.println("response: " + response.toString() );
241+
```
242+
243+
### Transfer Module
244+
245+
```java
246+
com.ost.services.v1.Transfer transferService = ostObj.services.transfers;
247+
```
248+
249+
Execute ST Prime Transfer:
250+
251+
```java
252+
HashMap <String,Object> params = new HashMap<String,Object>();
253+
params.put("to_address", "0xd2b789293674faEE51bEb2d0338d15401dEbfdE3");
254+
params.put("amount", 1);
255+
JsonObject response = transferService.execute( params );
256+
System.out.println("response: " + response.toString() );
257+
```
258+
259+
Get Transfer Status:
260+
261+
```java
262+
HashMap <String,Object> params = new HashMap<String,Object>();
263+
params.put("id", "38895b82-737e-4b23-b111-fec96e52f3b2");
264+
JsonObject response = transferService.get( params );
265+
System.out.println("response: " + response.toString() );
266+
```
267+
268+
List Transfers:
269+
270+
```java
271+
HashMap <String,Object> params = new HashMap<String,Object>();
272+
JsonObject response = transferService.list( params );
273+
```
274+

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.1.beta.1
1+
1.1.0.beta.2

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.ost</groupId>
55
<artifactId>ost-sdk-java</artifactId>
6-
<version>1.0.1.beta.1-SNAPSHOT</version>
6+
<version>1.1.0.beta.4-SNAPSHOT</version>
77
<name>OST SDK for Java</name>
88
<description>The official OST SDK for Java(https://dev.ost.com).</description>
99
<packaging>jar</packaging>

0 commit comments

Comments
 (0)