All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.knowm.xchange.btcchina.service.rest.BTCChinaAccountService Maven / Gradle / Ivy

The newest version!
package org.knowm.xchange.btcchina.service.rest;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;

import org.knowm.xchange.Exchange;
import org.knowm.xchange.btcchina.BTCChinaAdapters;
import org.knowm.xchange.btcchina.dto.BTCChinaID;
import org.knowm.xchange.btcchina.dto.BTCChinaResponse;
import org.knowm.xchange.btcchina.dto.account.BTCChinaAccountInfo;
import org.knowm.xchange.btcchina.dto.account.response.BTCChinaGetDepositsResponse;
import org.knowm.xchange.btcchina.dto.account.response.BTCChinaGetWithdrawalsResponse;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.FundingRecord;
import org.knowm.xchange.exceptions.ExchangeException;
import org.knowm.xchange.exceptions.NotAvailableFromExchangeException;
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;
import org.knowm.xchange.service.account.AccountService;
import org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrency;
import org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams;
import org.knowm.xchange.service.trade.params.TradeHistoryParamCurrency;
import org.knowm.xchange.service.trade.params.TradeHistoryParams;
import org.knowm.xchange.service.trade.params.WithdrawFundsParams;

/**
 * Implementation of the account data service for BTCChina.
 * 
    *
  • Provides access to account data
  • *
* * @author ObsessiveOrange */ public class BTCChinaAccountService extends BTCChinaAccountServiceRaw implements AccountService { /** * Constructor * * @param exchange */ public BTCChinaAccountService(Exchange exchange) { super(exchange); } @Override public AccountInfo getAccountInfo() throws IOException { BTCChinaResponse response = getBTCChinaAccountInfo(); return BTCChinaAdapters.adaptAccountInfo(response); } @Override public String withdrawFunds(Currency currency, BigDecimal amount, String address) throws IOException { BTCChinaResponse response = withdrawBTCChinaFunds(currency.toString(), amount, address); return response.getResult().getId(); } @Override public String withdrawFunds(WithdrawFundsParams params) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException { if (params instanceof DefaultWithdrawFundsParams) { DefaultWithdrawFundsParams defaultParams = (DefaultWithdrawFundsParams) params; return withdrawFunds(defaultParams.currency, defaultParams.amount, defaultParams.address); } throw new IllegalStateException("Don't know how to withdraw: " + params); } @Override public String requestDepositAddress(Currency currency, String... arguments) throws IOException { return requestBTCChinaDepositAddress(currency.toString()); } @Override public TradeHistoryParams createFundingHistoryParams() { return new BTCChinaFundingHistoryParams(Currency.BTC); } @Override public List getFundingHistory( TradeHistoryParams params) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException { String currency = null; if (params instanceof TradeHistoryParamCurrency && ((TradeHistoryParamCurrency) params).getCurrency() != null) { currency = ((TradeHistoryParamCurrency) params).getCurrency().getCurrencyCode(); } else { throw new ExchangeException("Currency must be supplied"); } BTCChinaGetDepositsResponse depositsResponse = getDeposits(currency, false); BTCChinaGetWithdrawalsResponse withdrawalsResponse = getWithdrawals(currency, false); return BTCChinaAdapters.adaptFundingHistory(depositsResponse, withdrawalsResponse); } public static class BTCChinaFundingHistoryParams extends DefaultTradeHistoryParamCurrency { public BTCChinaFundingHistoryParams(Currency currency) { super(currency); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy