added fetchBillByBillId

This commit is contained in:
himanshu
2025-10-29 13:55:49 +05:30
parent c8191b54cd
commit 5325f26a64
10 changed files with 262 additions and 10 deletions
@@ -42,7 +42,7 @@ public class HttpService {
}
headers.setContentType(MediaType.APPLICATION_JSON);
// ✅ MAKE THE REQUEST
ResponseEntity<String> restResponse = restClient.post()
.uri(url)
@@ -71,24 +71,78 @@ public class HttpService {
return response;
}
public HashMap<String, String> getRequest(String url) {
public HashMap<String, String> getRequest(String url, HttpHeaders customHeaders) {
HashMap<String, String> response = new HashMap<>();
try {
log.info("🌐 Bank GET Request to URL: {}", url);
HttpHeaders headers = new HttpHeaders();
if (customHeaders != null) {
headers.addAll(customHeaders);
}
log.info("🌐 Sending GET request to: {}", url);
log.info("📦 Headers: {}", headers);
ResponseEntity<String> restResponse = restClient.get()
.uri(url)
.retrieve()
.toEntity(String.class);
.uri(url)
.headers(h -> h.addAll(headers))
.retrieve()
.toEntity(String.class);
response.put("respCode", String.valueOf(restResponse.getStatusCode().value()));
response.put("data", restResponse.getBody());
log.info("✅ GET Response: {}", restResponse.getStatusCode());
} catch (HttpClientErrorException | HttpServerErrorException httpException) {
response.put("data", "Exception : " + httpException.getResponseBodyAsString());
log.error("❌ HTTP Error: {}", httpException.getMessage(), httpException);
response.put("respCode", String.valueOf(httpException.getStatusCode().value()));
response.put("data", httpException.getResponseBodyAsString());
} catch (Exception e) {
response.put("data", "Exception :" + e.getMessage());
log.error("❌ Exception during GET call to {} -> {}", url, e.getMessage());
log.error("❌ Exception during GET call: {}", e.getMessage(), e);
response.put("respCode", "500");
response.put("data", "Exception: " + e.getMessage());
}
// 🟢 You missed this line earlier
return response;
}
public HashMap<String, String> getRequest(String url) {
HashMap<String, String> response = new HashMap<>();
try {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
log.info("🌐 Sending GET request to: {}", url);
log.info("📦 Headers: {}", headers);
ResponseEntity<String> restResponse = restClient.get()
.uri(url)
.headers(h -> h.addAll(headers))
.retrieve()
.toEntity(String.class);
response.put("respCode", String.valueOf(restResponse.getStatusCode().value()));
response.put("data", restResponse.getBody());
log.info("✅ GET Response: {}", restResponse.getStatusCode());
} catch (HttpClientErrorException | HttpServerErrorException httpException) {
log.error("❌ HTTP Error: {}", httpException.getMessage(), httpException);
response.put("respCode", String.valueOf(httpException.getStatusCode().value()));
response.put("data", httpException.getResponseBodyAsString());
} catch (Exception e) {
log.error("❌ Exception during GET call: {}", e.getMessage(), e);
response.put("respCode", "500");
response.put("data", "Exception: " + e.getMessage());
}
return response;
}
}