Skip to content

Commit

Permalink
add callback parser
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangeguo committed Mar 11, 2019
1 parent 14a99c4 commit 2733bfe
Show file tree
Hide file tree
Showing 16 changed files with 1,411 additions and 539 deletions.
74 changes: 61 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# jadepool-sdk-java

## Example
## API Example

```
import com.jadepool.sdk.*;
Expand All @@ -9,35 +9,83 @@ public class Main {
public static void main(String[] args) throws Exception {
// If you are using Jadepool v0.12+, make sure to use unique sequence.
// If you are using versions below v0.12, any number will be accepted.
long sequence = 100;
//initialization
Configuration config = new Configuration("testa", "http://127.0.0.1:7001", "p8BMNxtcp8Xy+ofvxhyHbBbYDC/x0JtYBb0HJWBG2OI=", "base64", "en", true, "a7c04c371b5ca7c5f2fa87efc61c876c16d80c2ff1d09b5805bd07256046d8e2", "hex");
// Initialization
// You can set appid and public key of your server on Jadepool Admin.
// Jadepool public key can be found on Admin.
Configuration config = new Configuration("testa", "http://127.0.0.1:7001","BKzjJTLJBlLhuukWJI5CenqxCu7qEGeUlmmj9NoQll75DXKX9TjyMAajH5T9z67Z6N04yFun4oX3J0MDMpJa7+U=", "cn", "Gv/sLcN/Blq64QJ2BI5AZQo8VrAoTOHG/BuyGPQdjNk=", "base64", "Gv/sLcN/Blq64QJ2BI5AZQo8VrAoTOHG/BuyGPQdjNk=", "base64");
HttpApi api = new HttpApi(config);
// request a withdrawal
Order withdrawal = api.requestWithdrawal(sequence, "BTC", "0.01", "mg2bfYdfii2GG13HK94jXBYPPCSWRmSiAS", null, null);
// get a new address
// Request new address
Address newAddr = api.newAddress("BTC");
// verify if an address is valid
boolean valid = api.verifyAddress("BTC", newAddr.getAddress());
// Verify if an address is valid
boolean valid = api.verifyAddress("BTC", "mg2bfYdfii2GG13HK94jXBYPPCSWRmSiAS");
// request an audit
// Request an audit
String auditId = api.requestAudit("BTC", 1546070108000L);
// query a order
Order order = api.queryOrder(withdrawal.getId());
// Query a order
Order order = api.queryOrder("123");
// query an audit order
Audit audit = api.queryAudit(auditId);
// Query an audit order
Audit audit = api.queryAudit("5c6298f436d03c1751d47ffa");
// query wallet balance
// Query wallet balance
WalletBalance balance = api.getBalance("BTC");
// authorize coin
// Authorize coin
// This API is only available on v0.12+
api.authCoin("BTC", "BTC", "BTC", "BTC", 8, null);
// Pass any Jadepool callbacks to the callback parser.
CallbackParser callbackParser = new CallbackParser(config);
// Pseudo code: Your callback server received Jadepool's notification
String orderCallback = request.body
// Order callback will be parsed as a Order class object.
Order orderParsed = callbackParser.orderCallbackParser(orderCallback);
// or
String auditCallback = request.body
// Audit callback will be parsed as a Audit class object.
Audit auditParsed = callbackParser.auditCallbackParser(auditCallback);
}
}
```

## Callback Parser Example

```
import com.jadepool.sdk.*;
public class Main {
public static void main(String[] args) throws Exception {
CallbackParser callbackParser = new CallbackParser(config);
// Pass any Jadepool callbacks to the callback parser.
// Pseudo code: Your callback server received Jadepool's notification
String orderCallback = request.body
// Order callback will be parsed as a Order class object.
Order orderParsed = callbackParser.orderCallbackParser(orderCallback);
// or
String auditCallback = request.body
// Audit callback will be parsed as a Audit class object.
Audit auditParsed = callbackParser.auditCallbackParser(auditCallback);
}
}
Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,12 @@
<version>4.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>

</dependencies>
</project>
253 changes: 0 additions & 253 deletions src/main/java/com/jadepool/sdk/Audit.java

This file was deleted.

Loading

0 comments on commit 2733bfe

Please sign in to comment.