Search in sources :

Example 1 with DefaultWithdrawFundsParams

use of org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams in project XChange by knowm.

the class CoingiAccountService method withdrawFunds.

@Override
public String withdrawFunds(WithdrawFundsParams p) throws IOException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException {
    try {
        if (p instanceof DefaultWithdrawFundsParams) {
            DefaultWithdrawFundsParams params = (DefaultWithdrawFundsParams) p;
            CoingiWithdrawalRequest request = new CoingiWithdrawalRequest().setAddress(params.address).setAmount(params.amount).setCurrency(params.currency.getCurrencyCode().toUpperCase());
            return withdraw(request).toString();
        }
        throw new NotYetImplementedForExchangeException();
    } catch (CoingiException e) {
        throw CoingiErrorAdapter.adapt(e);
    }
}
Also used : DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) CoingiException(org.knowm.xchange.coingi.dto.CoingiException) CoingiWithdrawalRequest(org.knowm.xchange.coingi.dto.account.CoingiWithdrawalRequest) NotYetImplementedForExchangeException(org.knowm.xchange.exceptions.NotYetImplementedForExchangeException)

Example 2 with DefaultWithdrawFundsParams

use of org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams in project XChange by knowm.

the class BitbayAccountService method withdrawFunds.

@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
    if (params instanceof DefaultWithdrawFundsParams) {
        DefaultWithdrawFundsParams defaultParams = (DefaultWithdrawFundsParams) params;
        transfer(defaultParams.getCurrency(), defaultParams.getAmount(), defaultParams.getAddress());
        return "Success";
    } else if (params instanceof BitbayWithdrawFundsSwiftParams) {
        BitbayWithdrawFundsSwiftParams bicParams = (BitbayWithdrawFundsSwiftParams) params;
        withdraw(bicParams.getCurrency(), bicParams.getAmount(), bicParams.getAccount(), bicParams.isExpress(), bicParams.getBic());
        return "Success";
    }
    throw new NotAvailableFromExchangeException();
}
Also used : NotAvailableFromExchangeException(org.knowm.xchange.exceptions.NotAvailableFromExchangeException) DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) BitbayWithdrawFundsSwiftParams(org.knowm.xchange.bitbay.service.account.params.BitbayWithdrawFundsSwiftParams)

Example 3 with DefaultWithdrawFundsParams

use of org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams in project XChange by knowm.

the class BinanceAccountService method withdrawFunds.

@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
    try {
        if (!(params instanceof DefaultWithdrawFundsParams)) {
            throw new IllegalArgumentException("DefaultWithdrawFundsParams must be provided.");
        }
        WithdrawResponse withdraw;
        if (params instanceof RippleWithdrawFundsParams) {
            RippleWithdrawFundsParams rippleParams = null;
            rippleParams = (RippleWithdrawFundsParams) params;
            withdraw = super.withdraw(rippleParams.getCurrency().getCurrencyCode(), rippleParams.getAddress(), rippleParams.getTag(), rippleParams.getAmount());
        } else {
            DefaultWithdrawFundsParams p = (DefaultWithdrawFundsParams) params;
            withdraw = super.withdraw(p.getCurrency().getCurrencyCode(), p.getAddress(), p.getAddressTag(), p.getAmount());
        }
        return withdraw.getId();
    } catch (BinanceException e) {
        throw BinanceErrorAdapter.adapt(e);
    }
}
Also used : DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) BinanceException(org.knowm.xchange.binance.dto.BinanceException) RippleWithdrawFundsParams(org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams) WithdrawResponse(org.knowm.xchange.binance.dto.account.WithdrawResponse)

Example 4 with DefaultWithdrawFundsParams

use of org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams in project XChange by knowm.

the class BTCMarketsAccountService method withdrawFunds.

@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
    if (params instanceof DefaultWithdrawFundsParams) {
        DefaultWithdrawFundsParams defaultWithdrawFundsParams = (DefaultWithdrawFundsParams) params;
        String address = defaultWithdrawFundsParams.address;
        if (params instanceof RippleWithdrawFundsParams) {
            address = address + "?dt=" + ((RippleWithdrawFundsParams) params).tag;
        }
        return withdrawCrypto(address, defaultWithdrawFundsParams.getAmount(), defaultWithdrawFundsParams.getCurrency());
    }
    throw new IllegalStateException("Cannot process " + params);
}
Also used : DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) RippleWithdrawFundsParams(org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams)

Example 5 with DefaultWithdrawFundsParams

use of org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams in project XChange by knowm.

the class ExmoAccountService method withdrawFunds.

@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
    Map<String, Object> result;
    if (params instanceof RippleWithdrawFundsParams) {
        RippleWithdrawFundsParams rippleWithdrawFundsParams = (RippleWithdrawFundsParams) params;
        result = exmo.withdrawCrypt(signatureCreator, apiKey, exchange.getNonceFactory(), rippleWithdrawFundsParams.getAmount(), rippleWithdrawFundsParams.getCurrency().getCurrencyCode(), rippleWithdrawFundsParams.getAddress(), rippleWithdrawFundsParams.getTag());
    } else if (params instanceof DefaultWithdrawFundsParams) {
        DefaultWithdrawFundsParams defaultWithdrawFundsParams = (DefaultWithdrawFundsParams) params;
        result = exmo.withdrawCrypt(signatureCreator, apiKey, exchange.getNonceFactory(), defaultWithdrawFundsParams.getAmount(), defaultWithdrawFundsParams.getCurrency().getCurrencyCode(), defaultWithdrawFundsParams.getAddress(), null);
    } else {
        throw new IllegalStateException("Don't understand " + params);
    }
    Boolean success = (Boolean) result.get("result");
    if (success) {
        return result.get("task_id").toString();
    } else {
        throw new ExchangeException("Withdrawal failed: " + result.get("error").toString());
    }
}
Also used : DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) RippleWithdrawFundsParams(org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams) ExchangeException(org.knowm.xchange.exceptions.ExchangeException)

Aggregations

DefaultWithdrawFundsParams (org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams)8 RippleWithdrawFundsParams (org.knowm.xchange.service.trade.params.RippleWithdrawFundsParams)4 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)3 NotAvailableFromExchangeException (org.knowm.xchange.exceptions.NotAvailableFromExchangeException)2 NotYetImplementedForExchangeException (org.knowm.xchange.exceptions.NotYetImplementedForExchangeException)2 BinanceException (org.knowm.xchange.binance.dto.BinanceException)1 WithdrawResponse (org.knowm.xchange.binance.dto.account.WithdrawResponse)1 BitbayWithdrawFundsSwiftParams (org.knowm.xchange.bitbay.service.account.params.BitbayWithdrawFundsSwiftParams)1 BitstampWithdrawal (org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal)1 CoingiException (org.knowm.xchange.coingi.dto.CoingiException)1 CoingiWithdrawalRequest (org.knowm.xchange.coingi.dto.account.CoingiWithdrawalRequest)1 MoneroWithdrawFundsParams (org.knowm.xchange.service.trade.params.MoneroWithdrawFundsParams)1 BaseYoBitResponse (org.knowm.xchange.yobit.dto.BaseYoBitResponse)1