View Javadoc
1   package org.oxerr.okcoin.rest.service;
2   
3   import java.io.IOException;
4   import java.math.BigDecimal;
5   
6   import org.knowm.xchange.Exchange;
7   import org.oxerr.okcoin.rest.OKCoinException;
8   import org.oxerr.okcoin.rest.dto.AccountRecords;
9   import org.oxerr.okcoin.rest.dto.UserInfo;
10  import org.oxerr.okcoin.rest.dto.Withdrawal;
11  
12  /**
13   * Raw account service.
14   */
15  public class OKCoinAccountServiceRaw extends OKCoinBaseTradeService {
16  
17  	private static final String METHOD_GET_USER_INFO = "userinfo";
18  
19  	protected OKCoinAccountServiceRaw(Exchange exchange) {
20  		super(exchange);
21  	}
22  
23  	public UserInfo getUserInfo() throws OKCoinException, IOException {
24  		sleep(METHOD_GET_USER_INFO);
25  		UserInfo userInfo = okCoin.getUserInfo(apiKey, sign);
26  		updateLast(METHOD_GET_USER_INFO);
27  		return userInfo;
28  	}
29  
30  	public Withdrawal withdraw(String symbol, BigDecimal chargeFee,
31  			String tradePassword, String withdrawAddress,
32  			BigDecimal withdrawAmount) throws OKCoinException, IOException {
33  		return okCoin.withdraw(apiKey, symbol, chargeFee, tradePassword,
34  				withdrawAddress, withdrawAmount, sign);
35  	}
36  
37  	public Withdrawal cancelWithdraw(String symbol, long withdrawId)
38  			throws OKCoinException, IOException {
39  		return okCoin.cancelWithdraw(apiKey, symbol, withdrawId, sign);
40  	}
41  
42  	/**
43  	 * Returns the user deposits or withdraw records.
44  	 *
45  	 * @param symbol the symbol: btc_cny, ltc_cny, cny.
46  	 * @param type 0: deposits, 1: withdraw.
47  	 * @param currentPage the current page number, 1 based.
48  	 * @param pageLength the data entries number per page, maximum 50.
49  	 * @return the user deposits or withdraw records.
50  	 * @throws OKCoinException indicates request failed.
51  	 * @throws IOException indicates I/O exception.
52  	 */
53  	public AccountRecords getAccountRecords(String symbol, int type,
54  			int currentPage, int pageLength) throws OKCoinException,
55  			IOException {
56  		return okCoin.getAccountRecords(apiKey, symbol, type, currentPage,
57  				pageLength, sign);
58  	}
59  
60  }