-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INJIVER-587] - move vp-result to different controller
Signed-off-by: Sreenadh S <[email protected]>
- Loading branch information
Showing
2 changed files
with
38 additions
and
15 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
verify-service/src/main/java/io/inji/verify/controller/VPResultController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters