use of uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse in project probate-back-office by hmcts.
the class NextStepsController method validate.
@PostMapping(path = "/validate", consumes = APPLICATION_JSON_VALUE, produces = { APPLICATION_JSON_VALUE })
public ResponseEntity<CallbackResponse> validate(@RequestHeader(value = "Authorization") String authToken, @Validated({ ApplicationCreatedGroup.class, ApplicationUpdatedGroup.class, ApplicationReviewedGroup.class }) @RequestBody CallbackRequest callbackRequest, BindingResult bindingResult, HttpServletRequest request) {
logRequest(request.getRequestURI(), callbackRequest);
CallbackResponse callbackResponse;
Optional<String> newState = stateChangeService.getChangedStateForCaseReview(callbackRequest.getCaseDetails().getData());
if (newState.isPresent()) {
callbackResponse = callbackResponseTransformer.transformWithConditionalStateChange(callbackRequest, newState);
} else {
if (bindingResult.hasErrors()) {
log.error(CASE_ID_ERROR, callbackRequest.getCaseDetails().getId(), bindingResult);
throw new BadRequestException("Invalid payload", bindingResult);
}
CCDData ccdData = ccdBeanTransformer.transform(callbackRequest);
FeesResponse feesResponse = feeService.getAllFeesData(ccdData.getIht().getNetValueInPounds(), ccdData.getFee().getExtraCopiesOfGrant(), ccdData.getFee().getOutsideUKGrantCopies());
if (feesResponse.getTotalAmount().doubleValue() > 0) {
solicitorPaymentMethodValidationRule.validate(callbackRequest.getCaseDetails());
CreditAccountPayment creditAccountPayment = creditAccountPaymentTransformer.transform(callbackRequest.getCaseDetails(), feesResponse);
PaymentResponse paymentResponse = paymentsService.getCreditAccountPaymentResponse(authToken, creditAccountPayment);
CallbackResponse creditPaymentResponse = eventValidationService.validatePaymentResponse(callbackRequest.getCaseDetails(), paymentResponse, creditAccountPaymentValidationRule);
if (creditPaymentResponse.getErrors().isEmpty()) {
callbackResponse = callbackResponseTransformer.transformForSolicitorComplete(callbackRequest, feesResponse, paymentResponse);
} else {
callbackResponse = creditPaymentResponse;
}
} else {
callbackResponse = callbackResponseTransformer.transformForSolicitorComplete(callbackRequest, feesResponse, null);
}
}
return ResponseEntity.ok(callbackResponse);
}
use of uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse in project probate-back-office by hmcts.
the class NotificationController method sendCaseStoppedNotification.
@PostMapping(path = "/case-stopped")
public ResponseEntity<CallbackResponse> sendCaseStoppedNotification(@Validated({ EmailAddressNotifyValidationRule.class }) @RequestBody CallbackRequest callbackRequest) throws NotificationClientException {
CaseDetails caseDetails = callbackRequest.getCaseDetails();
CaseData caseData = caseDetails.getData();
CallbackResponse response = CallbackResponse.builder().errors(new ArrayList<>()).build();
Document document;
List<Document> documents = new ArrayList<>();
String letterId = null;
if (caseData.isCaveatStopNotificationRequested() && caseData.isCaveatStopEmailNotificationRequested()) {
response = eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
if (response.getErrors().isEmpty()) {
log.info("Initiate call to send caveat email for case id {} ", callbackRequest.getCaseDetails().getId());
document = notificationService.sendEmail(CASE_STOPPED_CAVEAT, caseDetails);
documents.add(document);
log.info("Successful response for caveat email for case id {} ", callbackRequest.getCaseDetails().getId());
}
} else if (caseData.isCaveatStopNotificationRequested() && !caseData.isCaveatStopEmailNotificationRequested()) {
Document coversheet = documentGeneratorService.generateCoversheet(callbackRequest);
documents.add(coversheet);
log.info("Initiate call to generate Caveat stopped document for case id {} ", callbackRequest.getCaseDetails().getId());
Map<String, Object> placeholders = gorDocmosisService.caseDataForStoppedMatchedCaveat(callbackRequest.getCaseDetails());
Document caveatRaisedDoc = pdfManagementService.generateDocmosisDocumentAndUpload(placeholders, DocumentType.CAVEAT_STOPPED);
documents.add(caveatRaisedDoc);
log.info("Successful response for caveat stopped document for case id {} ", callbackRequest.getCaseDetails().getId());
if (caseData.isCaveatStopSendToBulkPrintRequested()) {
log.info("Initiate call to bulk print for Caveat stopped document and coversheet for case id {} ", callbackRequest.getCaseDetails().getId());
SendLetterResponse sendLetterResponse = bulkPrintService.sendToBulkPrintForGrant(callbackRequest, caveatRaisedDoc, coversheet);
letterId = sendLetterResponse != null ? sendLetterResponse.letterId.toString() : null;
response = eventValidationService.validateBulkPrintResponse(letterId, bulkPrintValidationRules);
}
} else {
response = eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
if (response.getErrors().isEmpty()) {
log.info("Initiate call to notify applicant for case id {} ", callbackRequest.getCaseDetails().getId());
document = notificationService.sendEmail(CASE_STOPPED, caseDetails);
documents.add(document);
log.info("Successful response from notify for case id {} ", callbackRequest.getCaseDetails().getId());
}
}
if (response.getErrors().isEmpty()) {
response = callbackResponseTransformer.caseStopped(callbackRequest, documents, letterId);
}
return ResponseEntity.ok(response);
}
use of uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse in project probate-back-office by hmcts.
the class NotificationController method sendApplicationReceivedNotification.
@PostMapping(path = "/application-received")
public ResponseEntity<ProbateDocument> sendApplicationReceivedNotification(@RequestBody CallbackRequest callbackRequest) throws NotificationClientException {
CaseDetails caseDetails = callbackRequest.getCaseDetails();
CaseData caseData = callbackRequest.getCaseDetails().getData();
if (isDigitalApplication(caseData) && isAnEmailAddressPresent(caseData)) {
CallbackResponse response = eventValidationService.validateEmailRequest(callbackRequest, emailAddressNotifyValidationRules);
if (response.getErrors().isEmpty()) {
Document sentEmailAsDocument = notificationService.sendEmail(APPLICATION_RECEIVED, caseDetails);
return ResponseEntity.ok(buildProbateDocument(sentEmailAsDocument));
}
}
log.info("No email sent or document returned to case: {}", caseDetails.getId());
return ResponseEntity.ok(null);
}
use of uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse in project probate-back-office by hmcts.
the class ProbateManController method resetSearch.
@PostMapping(path = "/legacy/resetSearch", consumes = APPLICATION_JSON_VALUE, produces = { APPLICATION_JSON_VALUE })
public ResponseEntity<CallbackResponse> resetSearch(@RequestBody CallbackRequest callbackRequest, BindingResult bindingResult, HttpServletRequest request) {
log.info("submitting legacy search - invalid action");
List<String> errors = Arrays.asList(businessValidationMessageService.generateError(SUBMISSION_NOT_ALLOWED, "legacyCaseSubmissionNotAllowed").getMessage());
CallbackResponse callbackResponse = CallbackResponse.builder().errors(errors).build();
return ResponseEntity.ok(callbackResponse);
}
use of uk.gov.hmcts.probate.model.ccd.raw.response.CallbackResponse in project probate-back-office by hmcts.
the class BusinessValidationController method solsValidateAdmon.
@PostMapping(path = "/sols-validate-admon", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<CallbackResponse> solsValidateAdmon(@Validated({ ApplicationAdmonGroup.class }) @RequestBody CallbackRequest callbackRequest, BindingResult bindingResult, HttpServletRequest request) {
logRequest(request.getRequestURI(), callbackRequest);
validateForPayloadErrors(callbackRequest, bindingResult);
numberOfApplyingExecutorsValidationRule.validate(callbackRequest.getCaseDetails());
CallbackResponse response = eventValidationService.validateRequest(callbackRequest, allValidationRules);
if (response.getErrors().isEmpty()) {
caseDataTransformer.transformCaseDataForValidateAdmon(callbackRequest);
Optional<String> newState = stateChangeService.getChangedStateForAdmonUpdate(callbackRequest.getCaseDetails().getData());
response = getCallbackResponseForGenerateAndUpload(callbackRequest, newState, LEGAL_STATEMENT_ADMON, ADMON_WILL_NAME);
}
return ResponseEntity.ok(response);
}
Aggregations