package org.knowm.xchange.bitstamp.service;
import java.io.IOException;
import java.math.BigDecimal;
import org.knowm.xchange.Exchange;
import org.knowm.xchange.bitstamp.BitstampAdapters;
import org.knowm.xchange.bitstamp.dto.account.BitstampDepositAddress;
import org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.service.account.AccountService;
/**
* @author Matija Mazi
*/
public class BitstampAccountService extends BitstampAccountServiceRaw implements AccountService {
/**
* Constructor
*
* @param exchange
*/
public BitstampAccountService(Exchange exchange) {
super(exchange);
}
@Override
public AccountInfo getAccountInfo() throws IOException {
return BitstampAdapters.adaptAccountInfo(getBitstampBalance(), exchange.getExchangeSpecification().getUserName());
}
@Override
public String withdrawFunds(Currency currency, BigDecimal amount, String address) throws IOException {
final BitstampWithdrawal response = withdrawBitstampFunds(currency, amount, address);
if (response.getId() == null) {
return null;
}
return Integer.toString(response.getId());
}
/**
* This returns the currently set deposit address. It will not generate a new address (ie. repeated calls will return the same address).
*/
@Override
public String requestDepositAddress(Currency currency, String... arguments) throws IOException {
final BitstampDepositAddress response = getBitstampBitcoinDepositAddress();
return response.getDepositAddress();
}
}