Skip to content

Commit

Permalink
Merge 2f1222b into 01605dc
Browse files Browse the repository at this point in the history
  • Loading branch information
GinMu committed Dec 29, 2018
2 parents 01605dc + 2f1222b commit 4f1c439
Show file tree
Hide file tree
Showing 9 changed files with 699 additions and 109 deletions.
211 changes: 211 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,214 @@ jcc rpc java version

[![Build Status](https://travis-ci.com/JCCDex/jcc_rpc_java.svg?branch=master)](https://travis-ci.com/JCCDex/jcc_rpc_java)
[![Coverage Status](https://coveralls.io/repos/github/JCCDex/jcc_rpc_java/badge.svg?branch=master)](https://coveralls.io/github/JCCDex/jcc_rpc_java?branch=master)

## Usage of jcc_rpc_java API

## JCallback interface
```javascript
/**
*
* @param code code from jingchang api response, if the code is equal to 0
* that means response result is correct, otherwise means wrong.
* @param response response result from jingchang api
*/
void onResponse(String code, String response);

void onFail(Exception e);
```

### Create JccdexUrl.
```javascript
JccdexUrl jccUrl = new JccdexUrl("xxx", true);// https://xxx:443
JccdexUrl jccUrl = new JccdexUrl("xxx", false);// http://xxx:80
or
JccdexUrl jccUrl = new JccdexUrl("xxx", true, 8081);// https://xxx:8081
```

## JccdexExchange API

### Create JccdexExchange.
```javascript
JccdexExchange exchange = JccdexExchange.getInstance();
exchange.setmBaseUrl(jccUrl);
```

### requestBalance
```javascript
/** get balance with jingtum address. */
exchange.requestBalance(address, callback);
```
Parameters

`address`- `string`

`callback`- `implements JCallback`

### requestHistoricTransactions
```javascript
/** get historic transactions with jingtum address. */
exchange.requestHistoricTransactions(address, page, ledger, seq, callback);
```

Parameters

`address`- `string`

`page`- `int`

`ledger`- `int`

`seq`- `int`

`callback`- `implements JCallback`

### requestOrders
```javascript
/** get current orders with jingtum address. */
exchange.requestOrders(address, page, callback);
```

Parameters

`address`- `string`

`page`- `int`

`callback`- `implements JCallback`

### createOrder
```javascript
exchange.createOrder(signature, callback);
```

Parameters

`signature`- `string`

`callback`- `implements JCallback`

### cancelOrder
```javascript
exchange.cancelOrder(signature, callback);
```

Parameters

`signature`- `string`

`callback`- `implements JCallback`

### requestSequence
```javascript
/** get sequence with jingtum address. */
exchange.requestSequence(address);
```

Parameters

`address`- `string`

### transferToken
```javascript
exchange.transferToken(signature, callback);
```

Parameters

`signature`- `string`

`callback`- `implements JCallback`

## JccdexInfo API
```javascript
JccdexInfo info = JccdexInfo.getInstance();
info.setmBaseUrl(jccUrl);
```

### requestTicker
```javascript
info.requestTicker(base, counter, callBack);
// info.requestTicker("swt", "cnt", mockCallBack);
```

Parameters

`signature`- `string`

`counter`- `string`

`callback`- `implements JCallback`

### requestAllTickers
```javascript
info.requestAllTickers(callBack);
```

Parameters

`callback`- `implements JCallback`

### requestDepth
```javascript
info.requestDepth(base, counter, type, callBack);
// info.requestDepth("swt", "cnt", "normal", mockCallBack);
```

Parameters

`signature`- `string`

`counter`- `string`

`type`- `string {more | normal}`

`callback`- `implements JCallback`

### requestKline
```javascript
info.requestKline(base, counter, type, callBack);
// info.requestDepth("swt", "cnt", "normal", mockCallBack);
```

Parameters

`signature`- `string`

`counter`- `string`

`type`- `string {hour | day | week | month}`

`callback`- `implements JCallback`

### requestHistory
```javascript
info.requestHistory(base, counter, type, time, callBack);
// String unixtime = String.valueOf(System.currentTimeMillis() / 1000);
// info.requestHistory("swt", "cnt", "newest", unixtime, mockCallBack);
```

Parameters

`signature`- `string`

`counter`- `string`

`type`- `string {all | more | newest}`

`time`- `string {Unix time}`

`callback`- `implements JCallback`

### requestTickerFromCMC
```javascript
/**the token value includes eth and btc, the currency value includes cny and rub so far.*/
info.requestTickerFromCMC(token, currency, callBack)
```

Parameters

`token`- `string`

`currency`- `string`

`callback`- `implements JCallback`
19 changes: 18 additions & 1 deletion rpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.6.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
Expand Down Expand Up @@ -88,7 +106,6 @@
<docencoding>${project.build.sourceEncoding}</docencoding>
<charset>${project.build.sourceEncoding}</charset>
<additionalparam>-XDignore.symbol.file</additionalparam>
<additionalparam>-Xdoclint:-html</additionalparam>
<linksource>true</linksource>
</configuration>
<executions>
Expand Down
2 changes: 2 additions & 0 deletions rpc/src/main/java/com/jccdex/rpc/api/JccdexInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public void requestDepth(@NotNull String base, @NotNull String counter, @NotNull
* @param base
* @param counter
* @param type {hour | day | week | month}
* @param callBack
*/
@Override
public void requestKline(@NotNull String base, @NotNull String counter, @NotNull String type,
Expand Down Expand Up @@ -180,6 +181,7 @@ public void requestKline(@NotNull String base, @NotNull String counter, @NotNull
* @param counter
* @param type {all | more | newest}
* @param time {Unix time}
* @param callBack
*/
@Override
public void requestHistory(@NotNull String base, @NotNull String counter, @NotNull String type,
Expand Down
69 changes: 65 additions & 4 deletions rpc/src/main/java/com/jccdex/rpc/config/JConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,95 @@

public class JConstant {

// jingchang api success code
/**
* jingchang api success code.
* <P>
* {@value}
*/
public static final String REQUEST_JC_SUCCESS_CODE = "0";

// jingchang api route
/* for Exchange API */
/**
* Exchange API route.
* <P>
* {@value}
*/
public static final String JC_REQUEST_BALANCE_ROUTE = "/exchange/balances/";

/**
* Exchange API route.
* <P>
* {@value}
*/
public static final String JC_REQUEST_HISTORY_ROUTE = "/exchange/tx/";

/**
* Exchange API route.
* <P>
* {@value}
*/
public static final String JC_REQUEST_ORDER_ROUTE = "/exchange/orders/";

/**
* Exchange API route.
* <P>
* {@value}
*/
public static final String JC_CREATE_ORDER_ROUTE = "/exchange/sign_order/";

/**
* Exchange API route.
* <P>
* {@value}
*/
public static final String JC_CANCEL_ORDER_ROUTE = "/exchange/sign_cancel_order/";

/**
* Exchange API route.
* <P>
* {@value}
*/
public static final String JC_REQUEST_SEQUENCE_ROUTE = "/exchange/sequence/";

/**
* Exchange API route.
* <P>
* {@value}
*/
public static final String JC_TRNSFER_TOKEN_ROUTE = "/exchange/sign_payment/";

/* for Info API */
/**
* Info API route.
* <P>
* {@value}
*/
public static final String JC_REQUEST_TICKER_ROUTE = "/info/ticker/";

/**
* Info API route.
* <P>
* {@value}
*/
public static final String JC_REQUEST_ALLTICKERS_ROUTE = "/info/alltickers";

/**
* Info API route.
* <P>
* {@value}
*/
public static final String JC_REQUEST_DEPTH_ROUTE = "/info/depth/";

/**
* Info API route.
* <P>
* {@value}
*/
public static final String JC_REQUEST_KLINE_ROUTE = "/info/kline/";

/**
* Info API route.
* <P>
* {@value}
*/
public static final String JC_REQUEST_INFO_HISTORY_ROUTE = "/info/history/";

/**
Expand Down
Loading

0 comments on commit 4f1c439

Please sign in to comment.