You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
6 years ago
|
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 = Helpers.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;
|
||
|
}
|
||
|
|
||
|
|
||
|
public void close() throws IOException {
|
||
|
closeableHttpClient.close();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void finalize() throws IOException {
|
||
|
close();
|
||
|
}
|
||
|
}
|