-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathGasTrackerAPIProvider.java
37 lines (31 loc) · 1.26 KB
/
GasTrackerAPIProvider.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
package io.goodforgod.api.etherscan;
import io.goodforgod.api.etherscan.error.EtherScanException;
import io.goodforgod.api.etherscan.error.EtherScanResponseException;
import io.goodforgod.api.etherscan.executor.EthHttpClient;
import io.goodforgod.api.etherscan.manager.RequestQueueManager;
import io.goodforgod.api.etherscan.model.GasOracle;
import io.goodforgod.api.etherscan.model.response.GasOracleResponseTO;
import org.jetbrains.annotations.NotNull;
/**
* GasTracker API Implementation
*
* @see GasTrackerAPI
* @author Abhay Gupta
* @since 14.11.2022
*/
final class GasTrackerAPIProvider extends BasicProvider implements GasTrackerAPI {
private static final String ACT_GAS_ORACLE_PARAM = ACT_PREFIX + "gasoracle";
GasTrackerAPIProvider(RequestQueueManager queue,
String baseUrl,
EthHttpClient ethHttpClient) {
super(queue, "gastracker", baseUrl, ethHttpClient);
}
@NotNull
@Override
public GasOracle oracle() throws EtherScanException {
final GasOracleResponseTO response = getRequest(ACT_GAS_ORACLE_PARAM, GasOracleResponseTO.class);
if (response.getStatus() != 1)
throw new EtherScanResponseException(response);
return response.getResult();
}
}