Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FINERACT-1724: Fix swagger of loan reschedule api #3116

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -101,8 +101,7 @@ public String retrieveTemplate(@Context final UriInfo uriInfo) {
this.platformSecurityContext.authenticatedUser().validateHasReadPermission(RescheduleLoansApiConstants.ENTITY_NAME);
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());

LoanRescheduleRequestData loanRescheduleReasons = null;
loanRescheduleReasons = this.loanRescheduleRequestReadPlatformService
LoanRescheduleRequestData loanRescheduleReasons = this.loanRescheduleRequestReadPlatformService
.retrieveAllRescheduleReasons(RescheduleLoansApiConstants.LOAN_RESCHEDULE_REASON);

return this.loanRescheduleRequestToApiJsonSerializer.serialize(settings, loanRescheduleReasons);
Expand Down Expand Up @@ -137,7 +136,7 @@ public String readLoanRescheduleRequest(@Context final UriInfo uriInfo, @PathPar
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Create loan reschedule request", description = "Create a loan reschedule request.")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = String.class)), description = "{\"submittedOnDate\": \"05/02/2022\",\"rescheduleFromDate\": \"05/02/2022\",\"rescheduleReasonId\": 67,\"adjustedDueDate\": \"07/01/2022\",\"loanId\": \"18\",\"dateFormat\": \"MM/dd/yyyy\",\"locale\": \"en\"}")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = RescheduleLoansApiResourceSwagger.PostCreateRescheduleLoansRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = RescheduleLoansApiResourceSwagger.PostCreateRescheduleLoansResponse.class))) })
public String createLoanRescheduleRequest(final String apiRequestBodyAsJson) {
Expand All @@ -154,12 +153,12 @@ public String createLoanRescheduleRequest(final String apiRequestBodyAsJson) {
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Update loan reschedule request", description = "Update a loan reschedule request by either approving/rejecting it.")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = String.class)), description = "{\"approvedOnDate\": \"05/02/2022\",\"dateFormat\": \"MM/dd/yyyy\",\"locale\": \"en\"}")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = RescheduleLoansApiResourceSwagger.PostUpdateRescheduleLoansRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = RescheduleLoansApiResourceSwagger.PostUpdateRescheduleLoansResponse.class))) })
public String updateLoanRescheduleRequest(@PathParam("scheduleId") final Long scheduleId, @QueryParam("command") final String command,
final String apiRequestBodyAsJson) {
CommandWrapper commandWrapper = null;
CommandWrapper commandWrapper;

if (compareIgnoreCase(command, "approve")) {
commandWrapper = new CommandWrapperBuilder().approveLoanRescheduleRequest(RescheduleLoansApiConstants.ENTITY_NAME, scheduleId)
Expand All @@ -172,7 +171,7 @@ else if (compareIgnoreCase(command, "reject")) {
}

else {
throw new UnrecognizedQueryParamException("command", command, new Object[] { "approve", "reject" });
throw new UnrecognizedQueryParamException("command", command, "approve", "reject");
}

final CommandProcessingResult commandProcessingResult = this.commandsSourceWritePlatformService.logCommandSource(commandWrapper);
Expand Down Expand Up @@ -205,9 +204,9 @@ public String retrieveAllRescheduleRequest(@Context final UriInfo uriInfo, @Quer

final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
if (StringUtils.isNotBlank(command) && !RescheduleLoansApiConstants.commandParams.contains(command.toLowerCase())) {
throw new UnrecognizedQueryParamException("command", command,
new Object[] { RescheduleLoansApiConstants.allCommandParamName, RescheduleLoansApiConstants.pendingCommandParamName,
RescheduleLoansApiConstants.approveCommandParamName, RescheduleLoansApiConstants.rejectCommandParamName });
throw new UnrecognizedQueryParamException("command", command, RescheduleLoansApiConstants.allCommandParamName,
RescheduleLoansApiConstants.pendingCommandParamName, RescheduleLoansApiConstants.approveCommandParamName,
RescheduleLoansApiConstants.rejectCommandParamName);
}
final List<LoanRescheduleRequestData> loanRescheduleRequestsData = this.loanRescheduleRequestReadPlatformService
.retrieveAllRescheduleRequests(command);
Expand Down
Expand Up @@ -173,6 +173,48 @@ private LoanTermVariationsData() {}
public Set<LoanTermVariationsData> loanTermVariationsData;
}

@Schema(description = "PostCreateRescheduleLoansRequest")
public static final class PostCreateRescheduleLoansRequest {

@Schema(example = "20 September 2011")
public String adjustedDueDate;
@Schema(example = "en")
public String locale;
@Schema(example = "dd MMMM yyyy")
public String dateFormat;
@Schema(example = "1")
public Integer extraTerms;
@Schema(example = "1")
public Integer graceOnInterest;
@Schema(example = "1")
public Integer graceOnPrincipal;
@Schema(example = "1")
public Long loanId;
@Schema(example = "1.1")
public BigDecimal newInterestRate;
@Schema(example = "20 September 2011")
public String rescheduleFromDate;
@Schema(example = "comment")
public String rescheduleReasonComment;
@Schema(example = "1")
public Long rescheduleReasonId;
@Schema(example = "20 September 2011")
public String submittedOnDate;
}

@Schema(description = "PostUpdateRescheduleLoansRequest")
public static final class PostUpdateRescheduleLoansRequest {

@Schema(example = "20 September 2011")
public String approvedOnDate;
@Schema(example = "20 September 2011")
public String rejectedOnDate;
@Schema(example = "en")
public String locale;
@Schema(example = "dd MMMM yyyy")
public String dateFormat;
}

@Schema(description = "PostCreateRescheduleLoansResponse ")
public static final class PostCreateRescheduleLoansResponse {

Expand Down