|
1 | 1 | packageio.goodforgod.api.etherscan; |
2 | 2 |
|
3 | | -importio.goodforgod.api.etherscan.error.EtherScanException; |
4 | 3 | importio.goodforgod.api.etherscan.error.EtherScanParseException; |
5 | 4 | importio.goodforgod.api.etherscan.error.EtherScanRateLimitException; |
6 | 5 | importio.goodforgod.api.etherscan.error.EtherScanResponseException; |
|
9 | 8 | importio.goodforgod.api.etherscan.model.response.StringResponseTO; |
10 | 9 | importjava.net.URI; |
11 | 10 | importjava.nio.charset.StandardCharsets; |
12 | | -importjava.util.Map; |
13 | 11 |
|
14 | 12 | /** |
15 | 13 | * Base provider for API Implementations |
@@ -64,36 +62,14 @@ <T> T convert(byte[] json, Class<T> tClass) { |
64 | 62 | } |
65 | 63 |
|
66 | 64 | finalStringjsonAsString =newString(json,StandardCharsets.UTF_8); |
67 | | -try { |
68 | | -finalMap<String,Object>map =converter.fromJson(json,Map.class); |
69 | | -finalObjectresult =map.get("result"); |
70 | | -if (resultinstanceofString && ((String)result).startsWith(MAX_RATE_LIMIT_REACHED)) |
71 | | -thrownewEtherScanRateLimitException(((String)result)); |
72 | | - |
73 | | -thrownewEtherScanParseException(e.getMessage() +", for response: " +jsonAsString,e.getCause(),jsonAsString); |
74 | | - }catch (EtherScanExceptionex) { |
75 | | -throwex; |
76 | | - }catch (Exceptionex) { |
77 | | -thrownewEtherScanParseException(e.getMessage() +", for response: " +jsonAsString,e.getCause(),jsonAsString); |
78 | | - } |
| 65 | +thrownewEtherScanParseException(e.getMessage() +", for response: " +jsonAsString,e.getCause(),jsonAsString); |
79 | 66 | } |
80 | 67 | } |
81 | 68 |
|
82 | 69 | byte[]getRequest(StringurlParameters) { |
83 | 70 | queue.takeTurn(); |
84 | 71 | finalURIuri =URI.create(baseUrl +module +urlParameters); |
85 | | -finalbyte[]result =executor.get(uri); |
86 | | -if (result.length ==0) { |
87 | | -finalStringResponseTOemptyResponse =StringResponseTO.builder() |
88 | | - .withStatus("0") |
89 | | - .withMessage("Server returned null value for GET request at URL - " +uri) |
90 | | - .withResult("") |
91 | | - .build(); |
92 | | - |
93 | | -thrownewEtherScanResponseException(emptyResponse,"Server returned null value for GET request at URL - " +uri); |
94 | | - } |
95 | | - |
96 | | -returnresult; |
| 72 | +returnexecutor.get(uri); |
97 | 73 | } |
98 | 74 |
|
99 | 75 | byte[]postRequest(StringurlParameters,StringdataToPost) { |
|