Skip to content

Commit abe781a

Browse files
authored
Merge pull request #6 from OpenSTFoundation/santhosh/balances_model_and_cache
Added balance and ledger module to V1 Apis
2 parents d3c7f1d + 6823744 commit abe781a

6 files changed

Lines changed: 91 additions & 3 deletions

File tree

README.md

Lines changed: 31 additions & 1 deletion
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.0</version>
27+
<version>1.0.0.beta.1</version>
2828
</dependency>
2929
```
3030

@@ -271,3 +271,33 @@ List Transfers:
271271
HashMap <String,Object> params = new HashMap<String,Object>();
272272
JsonObject response = transferService.list( params );
273273
```
274+
275+
### Balance Module
276+
277+
```java
278+
com.ost.services.v1.Balances balanceService = ostObj.services.balances;
279+
```
280+
281+
Get user balance:
282+
283+
```java
284+
HashMap <String,Object> params = new HashMap<String,Object>();
285+
params.put("id", "38895b82-737e-4b23-b111-fec96e52f3b2");
286+
JsonObject response = balanceService.get( params );
287+
System.out.println("response: " + response.toString() );
288+
```
289+
290+
### Ledger Module
291+
292+
```java
293+
com.ost.services.v1.Ledger ledgerService = ostObj.services.ledger;
294+
```
295+
296+
Get transaction ledger for user:
297+
298+
```java
299+
HashMap <String,Object> params = new HashMap<String,Object>();
300+
params.put("id", "38895b82-737e-4b23-b111-fec96e52f3b2");
301+
JsonObject response = ledgerService.get( params );
302+
System.out.println("response: " + response.toString() );
303+
```

VERSION

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

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.0-SNAPSHOT</version>
6+
<version>1.0.0.beta.1-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>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.ost.services.v1;
2+
3+
import com.google.gson.JsonObject;
4+
import com.ost.lib.OSTRequestClient;
5+
import com.ost.services.OSTAPIService;
6+
7+
import java.io.IOException;
8+
import java.util.Map;
9+
10+
11+
public class Balances extends OSTAPIService {
12+
private static String servicePrefix = "/balances";
13+
14+
public Balances(OSTRequestClient ostRequestClient) {
15+
super(ostRequestClient, servicePrefix);
16+
}
17+
18+
/**
19+
* Get balance of user
20+
* @param params Request Params
21+
* @return API Response
22+
*/
23+
public JsonObject get( Map<String,Object> params ) throws MissingParameter, IOException {
24+
String resource = this.urlPrefix + "/" + this.getId( params ) + "/";
25+
return this.request.get(resource, params);
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.ost.services.v1;
2+
3+
import com.google.gson.JsonObject;
4+
import com.ost.lib.OSTRequestClient;
5+
import com.ost.services.OSTAPIService;
6+
7+
import java.io.IOException;
8+
import java.util.Map;
9+
10+
11+
public class Ledger extends OSTAPIService {
12+
private static String servicePrefix = "/ledger";
13+
14+
public Ledger(OSTRequestClient ostRequestClient) {
15+
super(ostRequestClient, servicePrefix);
16+
}
17+
18+
/**
19+
* Get ledger for user
20+
* @param params Request Params
21+
* @return API Response
22+
*/
23+
public JsonObject get( Map<String,Object> params ) throws MissingParameter, IOException {
24+
String resource = this.urlPrefix + "/" + this.getId( params ) + "/";
25+
return this.request.get(resource, params);
26+
}
27+
}

src/main/java/com/ost/services/v1/Manifest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public class Manifest extends OSTServiceManifest {
1212
public Transactions transactions;
1313
public Transfers transfers;
1414
public Users users;
15+
public Balances balances;
16+
public Ledger ledger;
1517

1618
public Manifest( Map<String, Object> params) {
1719
super(params);
@@ -25,6 +27,8 @@ private void init() {
2527
this.transactions = new Transactions( this.request );
2628
this.transfers = new Transfers( this.request );
2729
this.users = new Users( this.request );
30+
this.balances = new Balances( this.request );
31+
this.ledger = new Ledger( this.request );
2832
}
2933

3034
public String getApiVersion() {

0 commit comments

Comments
 (0)