forked from irufus/gdax-java
-
Notifications
You must be signed in to change notification settings - Fork 1
/
WithdrawalsService.java
51 lines (42 loc) · 2.19 KB
/
WithdrawalsService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.coinbase.exchange.api.withdrawals;
import com.coinbase.exchange.api.entity.CoinbasePaymentRequest;
import com.coinbase.exchange.api.entity.CryptoPaymentRequest;
import com.coinbase.exchange.api.exchange.GdaxExchange;
import com.coinbase.exchange.api.entity.PaymentRequest;
import com.coinbase.exchange.api.entity.PaymentResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
/**
* Created by robevansuk on 16/02/2017.
*/
@Component
public class WithdrawalsService {
static final String WITHDRAWALS_ENDPOINT = "/withdrawals";
static final String PAYMENT_METHOD = "/payment-method";
static final String COINBASE = "/coinbase-account";
static final String CRYPTO = "/crypto";
@Autowired
GdaxExchange gdaxExchange;
// TODO untested - needs a payment method id.
public PaymentResponse makeWithdrawalToPaymentMethod(BigDecimal amount, String currency, String paymentMethodId) {
PaymentRequest withdrawalRequest = new PaymentRequest(amount, currency, paymentMethodId);
return gdaxExchange.post(WITHDRAWALS_ENDPOINT+ PAYMENT_METHOD,
new ParameterizedTypeReference<PaymentResponse>() {},
withdrawalRequest);
}
public PaymentResponse makeWithdrawalToCoinbase(BigDecimal amount, String currency, String coinbaseAccountId) {
CoinbasePaymentRequest withdrawalRequest = new CoinbasePaymentRequest(amount, currency, coinbaseAccountId);
return gdaxExchange.post(WITHDRAWALS_ENDPOINT+ COINBASE,
new ParameterizedTypeReference<PaymentResponse>() {},
withdrawalRequest);
}
// TODO untested - needs a crypto currency account address
public PaymentResponse makeWithdrawalToCryptoAccount(BigDecimal amount, String currency, String cryptoAddress) {
CryptoPaymentRequest withdrawalRequest = new CryptoPaymentRequest(amount, currency, cryptoAddress);
return gdaxExchange.post(WITHDRAWALS_ENDPOINT+ CRYPTO,
new ParameterizedTypeReference<PaymentResponse>() {},
withdrawalRequest);
}
}