added constant in bbps constant

This commit is contained in:
Lincpay Tech
2025-11-24 17:48:54 +05:30
parent c9dfb6f9ba
commit 435ee0dacf
7 changed files with 368 additions and 351 deletions
@@ -8,7 +8,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClient;
@@ -20,13 +19,11 @@ import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsTicketsRequest;
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsRequest;
import com.billpaymentservice.bbps.dto.response.ComplaintHistoryStatusResponse;
import com.billpaymentservice.bbps.dto.response.ComplaintResponse;
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
import com.billpaymentservice.bbps.dto.response.TxnStatusResponse;
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsResponse;
import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
import com.billpaymentservice.bbps.entites.ComplaintStatusOptionsMaster;
@@ -90,7 +87,7 @@ public class ComplainServiceImpl implements ComplainService {
LOGGER.info("Initiating add Complain for request ID: {} and MID {}", complainRequestDTO.getReqId(),
complainRequestDTO.getMid());
String apiName = "ADD_COMPLAIN";
String apiName = BBPSConstant.API_ADD_COMPLAIN;
String txnId = helper.generateTxnId(15);
String requestId = complainRequestDTO.getReqId();
String fullUrl = complainDataUrl + BBPSConstant.ADD_COMPLAIN_ENDPOINT;
@@ -101,13 +98,13 @@ public class ComplainServiceImpl implements ComplainService {
String requestJson = helper.convertObjectToJson(complainRequestDTO);
// Fetch tenant & agent from DB
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
HttpHeaders headers = helper.buildHeaders(headersData);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, complainRequestDTO.getMid(),
"POST", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST", null);
BBPSConstant.HTTP_POST, requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, BBPSConstant.HTTP_POST, null);
try {
// Inject tenantId + agentId into request JSON
@@ -121,13 +118,13 @@ public class ComplainServiceImpl implements ComplainService {
// IMPORTANT: Send finalJson, not requestJson
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("Fetched response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
// Handle HttpService error wrapper
if (responseData.startsWith("HttpService Error")) {
if (responseData.startsWith(BBPSConstant.HTTP_SERVICE_ERROR_PREFIX)) {
int start = responseData.indexOf("{");
int end = responseData.lastIndexOf("}");
if (start != -1 && end != -1) {
@@ -141,12 +138,13 @@ public class ComplainServiceImpl implements ComplainService {
new TypeReference<Map<String, Object>>() {
});
int statusCode = Integer.parseInt(String.valueOf(dataMap.get("statusCode")));
int statusCode = Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY)));
// Throw exception for non-200
if (statusCode != 200) {
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
statusCode, String.valueOf(dataMap.get("remarks")));
if (statusCode != BBPSConstant.HTTP_OK_INT) {
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), statusCode,
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
}
// Convert to response wrapper
@@ -160,7 +158,7 @@ public class ComplainServiceImpl implements ComplainService {
} catch (JsonProcessingException e) {
LOGGER.error("JSON Parsing Error: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}
@@ -170,7 +168,7 @@ public class ComplainServiceImpl implements ComplainService {
LOGGER.info("Fetching Complaint Status for TicketId={} ReqId={}", request.getTicketId(), request.getReqId());
String apiName = "COMPLAINT_STATUS";
String apiName = BBPSConstant.API_COMPLAINT_STATUS;
String txnId = helper.generateTxnId(15);
String reqId = request.getReqId();
String complaintId = request.getTicketId();
@@ -178,17 +176,17 @@ public class ComplainServiceImpl implements ComplainService {
helper.validateMerchant(request.getMid());
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
HttpHeaders headers = helper.buildHeaders(headersData);
// Convert request to JSON
String requestJson = helper.convertObjectToJson(request);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "POST",
requestJson);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_POST,
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", complaintId);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_POST, complaintId);
try {
@@ -201,12 +199,13 @@ public class ComplainServiceImpl implements ComplainService {
// LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("Complaint Fetch Response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
if (responseData.startsWith("HttpService Error")) {
// Handle HttpService error wrapper
if (responseData.startsWith(BBPSConstant.HTTP_SERVICE_ERROR_PREFIX)) {
int start = responseData.indexOf("{");
int end = responseData.lastIndexOf("}");
if (start != -1 && end != -1) {
@@ -220,11 +219,12 @@ public class ComplainServiceImpl implements ComplainService {
new TypeReference<Map<String, Object>>() {
});
int statusCode = Integer.parseInt(String.valueOf(dataMap.get("statusCode")));
int statusCode = Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY)));
if (statusCode != 200) {
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
statusCode, String.valueOf(dataMap.get("remarks")));
if (statusCode != BBPSConstant.HTTP_OK_INT) {
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), statusCode,
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
}
TicketCheckStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TicketCheckStatusResponse.class);
@@ -236,7 +236,7 @@ public class ComplainServiceImpl implements ComplainService {
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing JSON in complaint status API: {}", e.getMessage(), e);
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}
@@ -245,7 +245,7 @@ public class ComplainServiceImpl implements ComplainService {
public ResponseModel viewComplaintHistory(ComplainStatusRequest request) {
LOGGER.info("Fetching View Complaint History Complaint by Complaint Id={}", request.getTicketId(),
request.getReqId());
String apiName = "View_Complaint_History";
String apiName = BBPSConstant.API_VIEW_COMPLAINT_HISTORY;
String txnId = helper.generateTxnId(15);
String reqId = request.getReqId();
String ticketId = request.getTicketId();
@@ -253,20 +253,20 @@ public class ComplainServiceImpl implements ComplainService {
helper.validateMerchant(request.getMid());
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
HttpHeaders headers = helper.buildHeaders(headersData);
String requestJson = helper.convertObjectToJson(request);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", ticketId);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_GET,
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, ticketId);
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
try {
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("Complaint History Complaint FetchById Response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -275,11 +275,12 @@ public class ComplainServiceImpl implements ComplainService {
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(""));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), String.valueOf(""));
}
ComplaintHistoryStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
@@ -297,7 +298,7 @@ public class ComplainServiceImpl implements ComplainService {
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing Complaint Id JSON: {}", e.getMessage(), e);
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}
@@ -306,7 +307,7 @@ public class ComplainServiceImpl implements ComplainService {
public ResponseModel viewComplaintById(ComplainStatusRequest request) {
LOGGER.info("Fetching View Complaint Complaint by Complaint Id={}", request.getTicketId(), request.getReqId());
String apiName = "View_Complaint_By_ID";
String apiName = BBPSConstant.API_VIEW_COMPLAINT_BY_ID;
String txnId = helper.generateTxnId(15);
String reqId = request.getReqId();
String ticketId = request.getTicketId();
@@ -314,20 +315,20 @@ public class ComplainServiceImpl implements ComplainService {
helper.validateMerchant(request.getMid());
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
HttpHeaders headers = helper.buildHeaders(headersData);
String requestJson = helper.convertObjectToJson(request);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", ticketId);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_GET,
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, ticketId);
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
try {
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("Complaint History Complaint FetchById Response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -336,11 +337,12 @@ public class ComplainServiceImpl implements ComplainService {
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(""));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), String.valueOf(""));
}
ViewComplainByIdResponse responseWrapper = objectMapper.convertValue(dataMap,
@@ -358,7 +360,7 @@ public class ComplainServiceImpl implements ComplainService {
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing Complaint Id JSON: {}", e.getMessage(), e);
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}
@@ -368,17 +370,17 @@ public class ComplainServiceImpl implements ComplainService {
try {
LOGGER.info("Fetch All Master Options - MID: {}", request.getMid());
String apiName = "View All Options Fetch By Id";
String apiName = BBPSConstant.API_GET_ALL_MASTER_OPTIONS;
String txnId = helper.generateTxnId(15);
String reqId = request.getReqId();
String fullUrl = "Data Base Options";
String fullUrl = BBPSConstant.DB_OPTIONS;
String requestJson = helper.convertObjectToJson(request);
// Validate merchant
helper.validateMerchant(request.getMid());
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_GET,
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
// Fetch data from DB
@@ -389,27 +391,29 @@ public class ComplainServiceImpl implements ComplainService {
// Check empty or null
if (allActiveStatuses == null || allActiveStatuses.isEmpty()) {
helper.updateInboundLogFailure(inboundLog, allActiveStatuses.toString(), "Null Data From DB");
return new ResponseModel("No Master Fields Found", "failed", 404, null, 0);
helper.updateInboundLogFailure(inboundLog, String.valueOf(allActiveStatuses), BBPSConstant.NULL_DATA_FROM_DB);
return new ResponseModel(BBPSConstant.NO_MASTER_FIELDS_FOUND, BBPSConstant.FAILED_STATUS,
BBPSConstant.HTTP_NOT_FOUND, null, 0);
}
helper.updateInboundLogSuccess(inboundLog, allActiveStatuses.toString(), "200");
helper.updateInboundLogSuccess(inboundLog, String.valueOf(allActiveStatuses), String.valueOf(BBPSConstant.HTTP_OK_INT));
// SUCCESS RESPONSE
return new ResponseModel("All Master Fields Fetch", "SUCCESS", 200, allActiveStatuses,
return new ResponseModel(BBPSConstant.ALL_MASTER_FIELDS_FETCH, BBPSConstant.SUCCESS_RESPONSE, BBPSConstant.HTTP_OK_INT, allActiveStatuses,
allActiveStatuses.size());
}
catch (Exception e) {
LOGGER.error("Error while fetching master options", e);
return new ResponseModel("Something went wrong", "failed", 500, null, 0);
return new ResponseModel(BBPSConstant.SOMETHING_WENT_WRONG, BBPSConstant.FAILED_STATUS,
BBPSConstant.HTTP_INTERNAL_SERVER_ERROR, null, 0);
}
}
public ResponseModel checkTxnStatus(TxnStatusRequest request) {
LOGGER.info("Check Txn Status Request by Id={} and ReqId ={}", request.getId(), request.getReqId());
String apiName = "CheckTxnStatus";
String apiName = BBPSConstant.API_CHECK_TXN_STATUS;
String txnId = helper.generateTxnId(15);
String reqId = request.getReqId();
String ID = request.getId();
@@ -417,20 +421,20 @@ public class ComplainServiceImpl implements ComplainService {
helper.validateMerchant(request.getMid());
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
HttpHeaders headers = helper.buildHeaders(headersData);
String requestJson = helper.convertObjectToJson(request);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", ID);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_GET,
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET, ID);
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
try {
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("checkTxnStatus: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -439,11 +443,12 @@ public class ComplainServiceImpl implements ComplainService {
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(""));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), String.valueOf(""));
}
TxnStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TxnStatusResponse.class);
@@ -457,7 +462,7 @@ public class ComplainServiceImpl implements ComplainService {
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing Complaint Id JSON: {}", e.getMessage(), e);
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
@@ -468,30 +473,30 @@ public class ComplainServiceImpl implements ComplainService {
LOGGER.info("Fetching All Complaint for status Type={} and reqId={} ", request.getStatusType(),
request.getReqId());
String apiName = "View_All_Complaint_By_Status_Type";
String apiName = BBPSConstant.API_VIEW_ALL_COMPLAINTS_BY_STATUS;
String txnId = helper.generateTxnId(15);
String reqId = request.getReqId();
String fullUrl = complainDataUrl + BBPSConstant.VIEW_ALL_COMPLAINTS_BASE + "?pageNo=" + request.getPageNo()
+ "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType="
+ request.getTicketType();
+ "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType="
+ request.getTicketType();
helper.validateMerchant(request.getMid());
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
HttpHeaders headers = helper.buildHeaders(headersData);
String requestJson = helper.convertObjectToJson(request);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "POST",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET",
request.getStatusType());
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), BBPSConstant.HTTP_POST,
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
request.getStatusType());
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
try {
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("Response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -500,11 +505,12 @@ public class ComplainServiceImpl implements ComplainService {
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(""));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), String.valueOf(""));
}
ViewAllComplaintsTicketsResponse responseWrapper = objectMapper.convertValue(dataMap,
@@ -521,7 +527,7 @@ public class ComplainServiceImpl implements ComplainService {
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing Complaint Id JSON: {}", e.getMessage(), e);
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}