|
1 | 1 | package io.goodforgod.api.etherscan; |
2 | 2 |
|
3 | | -import io.goodforgod.api.etherscan.error.EtherScanException; |
4 | 3 | import io.goodforgod.api.etherscan.error.EtherScanParseException; |
5 | 4 | import io.goodforgod.api.etherscan.error.EtherScanRateLimitException; |
6 | 5 | import io.goodforgod.api.etherscan.error.EtherScanResponseException; |
|
9 | 8 | import io.goodforgod.api.etherscan.model.response.StringResponseTO; |
10 | 9 | import java.net.URI; |
11 | 10 | import java.nio.charset.StandardCharsets; |
12 | | -import java.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 | final String jsonAsString = new String(json, StandardCharsets.UTF_8); |
67 | | - try { |
68 | | - final Map<String, Object> map = converter.fromJson(json, Map.class); |
69 | | - final Object result = map.get("result"); |
70 | | - if (result instanceof String && ((String) result).startsWith(MAX_RATE_LIMIT_REACHED)) |
71 | | - throw new EtherScanRateLimitException(((String) result)); |
72 | | - |
73 | | - throw new EtherScanParseException(e.getMessage() + ", for response: " + jsonAsString, e.getCause(), jsonAsString); |
74 | | - } catch (EtherScanException ex) { |
75 | | - throw ex; |
76 | | - } catch (Exception ex) { |
77 | | - throw new EtherScanParseException(e.getMessage() + ", for response: " + jsonAsString, e.getCause(), jsonAsString); |
78 | | - } |
| 65 | + throw new EtherScanParseException(e.getMessage() + ", for response: " + jsonAsString, e.getCause(), jsonAsString); |
79 | 66 | } |
80 | 67 | } |
81 | 68 |
|
82 | 69 | byte[] getRequest(String urlParameters) { |
83 | 70 | queue.takeTurn(); |
84 | 71 | final URI uri = URI.create(baseUrl + module + urlParameters); |
85 | | - final byte[] result = executor.get(uri); |
86 | | - if (result.length == 0) { |
87 | | - final StringResponseTO emptyResponse = StringResponseTO.builder() |
88 | | - .withStatus("0") |
89 | | - .withMessage("Server returned null value for GET request at URL - " + uri) |
90 | | - .withResult("") |
91 | | - .build(); |
92 | | - |
93 | | - throw new EtherScanResponseException(emptyResponse, "Server returned null value for GET request at URL - " + uri); |
94 | | - } |
95 | | - |
96 | | - return result; |
| 72 | + return executor.get(uri); |
97 | 73 | } |
98 | 74 |
|
99 | 75 | byte[] postRequest(String urlParameters, String dataToPost) { |
|
0 commit comments