implemented customerParam Api
This commit is contained in:
@@ -15,15 +15,20 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.MasterApiResponse;
|
||||
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.CustomerParamRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.MerchantRequestModel;
|
||||
import com.billpaymentservice.bbps.dto.response.BillerDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillerResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ContactMasterResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.CustomParamResp;
|
||||
import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
|
||||
import com.billpaymentservice.bbps.exception.AppException;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.MerchantRepository;
|
||||
import com.billpaymentservice.bbps.service.MasterDataService;
|
||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||
import com.billpaymentservice.bbps.util.Helper;
|
||||
import com.billpaymentservice.bbps.util.ResponseParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
@@ -39,33 +44,36 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Value("${master.data.url}")
|
||||
private String masterRegisterUrl;
|
||||
|
||||
@Autowired
|
||||
private MerchantRepository merchantRegisterRepo;
|
||||
|
||||
@Autowired
|
||||
private HttpClientApi httpClientApi;
|
||||
|
||||
@Autowired
|
||||
private ResponseParser responseParser;
|
||||
private Helper helper;
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MasterDataServiceImpl.class);
|
||||
private final HttpService httpService;
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
@Value("${bbps.billerDataFetch.url}")
|
||||
private String billerDataFetchUrl;
|
||||
|
||||
|
||||
// Inject HttpService
|
||||
public MasterDataServiceImpl(HttpService httpService) {
|
||||
this.httpService = httpService;
|
||||
}
|
||||
|
||||
public MasterDataServiceImpl(MerchantRepository merchantRegisterRepo,
|
||||
HttpService httpService,
|
||||
HttpClientApi httpClientApi,
|
||||
Helper helper,
|
||||
ResponseParser responseParser) {
|
||||
this.merchantRegisterRepo = merchantRegisterRepo;
|
||||
this.httpService = httpService;
|
||||
this.httpClientApi = httpClientApi;
|
||||
this.helper = helper;
|
||||
this.responseParser = responseParser;
|
||||
}
|
||||
@Override
|
||||
public BillerDataResponse getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
||||
|
||||
|
||||
String billerId = billerDetailRequest.getBillerId();
|
||||
String url = billerDataFetchUrl + billerId;
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL+billerId;
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
log.info("data is :{}", responseData);
|
||||
|
||||
@@ -186,4 +194,40 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
return ResponseEntity.ok(responseModel);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomParamResp getCustomerParamByBillerId(CustomerParamRequest customerParamRequest) {
|
||||
String billerId = customerParamRequest.getBillerId();
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMPARAM_URL+billerId;
|
||||
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
log.info("data is :{}", responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
throw new CustomException(String.valueOf(dataMap.get("statusCode")),
|
||||
String.valueOf(dataMap.get("status")), String.valueOf(dataMap.get("message")),
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
CustomParamResp responseWrapper = objectMapper.convertValue(dataMap, CustomParamResp.class);
|
||||
return responseWrapper;
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContactMasterResponse getContactMaster(ContactMasterRequest contactMasterRequest) {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user