|
|
|
package com.sigmaflare.binancej;
|
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
import org.apache.http.impl.client.HttpClientBuilder;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
|
|
public abstract class BaseBinanceApi {
|
|
|
|
protected final String apiKey;
|
|
|
|
protected final String secretKey;
|
|
|
|
protected final CloseableHttpClient closeableHttpClient;
|
|
|
|
|
|
|
|
protected static final ObjectMapper mapper = HttpRequests.objectMapperBuilder();
|
|
|
|
|
|
|
|
public BaseBinanceApi(String apiKey, String secretKey) {
|
|
|
|
this.apiKey = apiKey;
|
|
|
|
this.secretKey = secretKey;
|
|
|
|
this.closeableHttpClient = HttpClientBuilder.create().build();
|
|
|
|
}
|
|
|
|
|
|
|
|
public BaseBinanceApi(String apiKey, String secretKey, CloseableHttpClient closeableHttpClient) {
|
|
|
|
this.apiKey = apiKey;
|
|
|
|
this.secretKey = secretKey;
|
|
|
|
this.closeableHttpClient = closeableHttpClient;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Closes the CloseableHttpClient instance.
|
|
|
|
* @throws IOException If closing fails
|
|
|
|
*/
|
|
|
|
public void close() throws IOException {
|
|
|
|
closeableHttpClient.close();
|
|
|
|
}
|
|
|
|
}
|