Skip to content

Commit

Permalink
[INJIVER-587] - move vp-result to different controller
Browse files Browse the repository at this point in the history
Signed-off-by: Sreenadh S <[email protected]>
  • Loading branch information
sree96 committed Dec 26, 2024
1 parent da42c40 commit 9906bdb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.inji.verify.controller;

import io.inji.verify.dto.submission.VPTokenResultDto;
import io.inji.verify.enums.ErrorCode;
import io.inji.verify.shared.Constants;
import io.inji.verify.spi.VerifiablePresentationRequestService;
import io.inji.verify.spi.VerifiablePresentationSubmissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
public class VPResultController {
@Autowired
VerifiablePresentationRequestService verifiablePresentationRequestService;

@Autowired
VerifiablePresentationSubmissionService verifiablePresentationSubmissionService;

@GetMapping(path = "/vp-result/{transactionId}")
public ResponseEntity<VPTokenResultDto> getVPResult(@PathVariable String transactionId) {
List<String> requestIds = verifiablePresentationRequestService.getLatestRequestIdFor(transactionId);

if (requestIds.isEmpty()) {
return new ResponseEntity<>(new VPTokenResultDto(null,null,null, ErrorCode.ERR_100, Constants.ERR_100), HttpStatus.OK);
}

VPTokenResultDto result = verifiablePresentationSubmissionService.getVPResult(requestIds,transactionId);
if (result != null) {
return new ResponseEntity<>(result, HttpStatus.OK);
}
return new ResponseEntity<>(new VPTokenResultDto(null,null,null, ErrorCode.ERR_101, Constants.ERR_101),HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@ public class VPSubmissionController {
@Autowired
Gson gson;

@GetMapping(path = "/result/{transactionId}")
public ResponseEntity<VPTokenResultDto> getVPResult(@PathVariable String transactionId) {
List<String> requestIds = verifiablePresentationRequestService.getLatestRequestIdFor(transactionId);

if (requestIds.isEmpty()) {
return new ResponseEntity<>(new VPTokenResultDto(null,null,null, ErrorCode.ERR_100, Constants.ERR_100),HttpStatus.OK);
}

VPTokenResultDto result = verifiablePresentationSubmissionService.getVPResult(requestIds,transactionId);
if (result != null) {
return new ResponseEntity<>(result, HttpStatus.OK);
}
return new ResponseEntity<>(new VPTokenResultDto(null,null,null, ErrorCode.ERR_101, Constants.ERR_101),HttpStatus.OK);
}

@PostMapping(path = Constants.RESPONSE_SUBMISSION_URI, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<VPSubmissionResponseDto> submitVP(@RequestParam(value = "vp_token") String vpToken, @RequestParam(value = "presentation_submission") String presentationSubmission, @RequestParam(value = "state") String state) {
PresentationSubmissionDto presentationSubmissionDto = gson.fromJson(presentationSubmission, PresentationSubmissionDto.class);
Expand Down

0 comments on commit 9906bdb

Please sign in to comment.