|
12 | 12 | import lombok.extern.slf4j.Slf4j;
|
13 | 13 | import lombok.val;
|
14 | 14 | import org.cardanofoundation.lob.app.accounting_reporting_core.domain.core.TransactionType;
|
15 |
| -import org.cardanofoundation.lob.app.accounting_reporting_core.domain.entity.Rejection; |
16 | 15 | import org.cardanofoundation.lob.app.accounting_reporting_core.domain.entity.RejectionCode;
|
17 | 16 | import org.cardanofoundation.lob.app.accounting_reporting_core.resource.model.AccountingCorePresentationViewService;
|
18 | 17 | import org.cardanofoundation.lob.app.accounting_reporting_core.resource.model.AccountingCoreResourceService;
|
19 | 18 | import org.cardanofoundation.lob.app.accounting_reporting_core.resource.requests.BatchSearchRequest;
|
20 | 19 | import org.cardanofoundation.lob.app.accounting_reporting_core.resource.requests.ExtractionRequest;
|
21 | 20 | import org.cardanofoundation.lob.app.accounting_reporting_core.resource.requests.SearchRequest;
|
| 21 | +import org.cardanofoundation.lob.app.accounting_reporting_core.resource.requests.TransactionsApprove; |
22 | 22 | import org.cardanofoundation.lob.app.accounting_reporting_core.resource.views.BatchView;
|
23 | 23 | import org.cardanofoundation.lob.app.accounting_reporting_core.resource.views.BatchsDetailView;
|
| 24 | +import org.cardanofoundation.lob.app.accounting_reporting_core.resource.views.TransactionProcessView; |
24 | 25 | import org.cardanofoundation.lob.app.accounting_reporting_core.resource.views.TransactionView;
|
25 | 26 | import org.json.JSONArray;
|
26 | 27 | import org.json.JSONException;
|
@@ -63,14 +64,14 @@ public ResponseEntity<?> listAllAction(@Valid @RequestBody SearchRequest body) {
|
63 | 64 | {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = TransactionView.class))}
|
64 | 65 | )
|
65 | 66 | })
|
66 |
| - @GetMapping(value = "/transactions/{transactionId}", produces = MediaType.APPLICATION_JSON_VALUE) |
67 |
| - public ResponseEntity<?> transactionDetailSpecific(@Valid @PathVariable("transactionId") @Parameter(example = "7e9e8bcbb38a283b41eab57add98278561ab51d23a16f3e3baf3daa461b84ab4") String transactionId) { |
| 67 | + @GetMapping(value = "/transactions/{id}", produces = MediaType.APPLICATION_JSON_VALUE) |
| 68 | + public ResponseEntity<?> transactionDetailSpecific(@Valid @PathVariable("id") @Parameter(example = "7e9e8bcbb38a283b41eab57add98278561ab51d23a16f3e3baf3daa461b84ab4") String id) { |
68 | 69 |
|
69 |
| - val transactionEntity = accountingCorePresentationService.transactionDetailSpecific(transactionId); |
| 70 | + val transactionEntity = accountingCorePresentationService.transactionDetailSpecific(id); |
70 | 71 | if (transactionEntity.isEmpty()) {
|
71 | 72 | val issue = Problem.builder()
|
72 | 73 | .withTitle("TX_NOT_FOUND")
|
73 |
| - .withDetail(STR."Transaction with id: {\{transactionId}} could not be found") |
| 74 | + .withDetail(STR."Transaction with id: {\{id}} could not be found") |
74 | 75 | .withStatus(Status.NOT_FOUND)
|
75 | 76 | .build();
|
76 | 77 |
|
@@ -105,7 +106,7 @@ public ResponseEntity<?> transactionType() throws JSONException {
|
105 | 106 | @Tag(name = "Transactions", description = "Transactions API")
|
106 | 107 | @Operation(description = "Rejection types", responses = {
|
107 | 108 | @ApiResponse(content =
|
108 |
| - {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, array = @ArraySchema(schema = @Schema(implementation = RejectionCode.class)))} |
| 109 | + {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, array = @ArraySchema(schema = @Schema(implementation = RejectionCode.class)))} |
109 | 110 | )
|
110 | 111 | })
|
111 | 112 | @GetMapping(value = "/rejection-types", produces = MediaType.APPLICATION_JSON_VALUE, name = "Rejection types")
|
@@ -158,6 +159,29 @@ public ResponseEntity<?> extractionTrigger(@Valid @RequestBody ExtractionRequest
|
158 | 159 | .body(response.toString());
|
159 | 160 | }
|
160 | 161 |
|
| 162 | + @Tag(name = "Transactions", description = "Transactions API") |
| 163 | + @PostMapping(value = "/transactions/approve", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) |
| 164 | + @Operation(description = "Approve transactions", |
| 165 | + responses = { |
| 166 | + @ApiResponse(content = { |
| 167 | + @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, array = @ArraySchema(schema = @Schema(implementation = TransactionProcessView.class))) |
| 168 | + }) |
| 169 | + } |
| 170 | + ) |
| 171 | + public ResponseEntity<?> approveTransaction(@Valid @RequestBody TransactionsApprove transactionsApprove) { |
| 172 | + val resul = accountingCorePresentationService.approveTransactions(transactionsApprove.getTransactionApproves()); |
| 173 | + |
| 174 | + if (resul.isEmpty()) { |
| 175 | + return ResponseEntity |
| 176 | + .status(HttpStatusCode.valueOf(404)) |
| 177 | + .body(resul); |
| 178 | + } |
| 179 | + |
| 180 | + return ResponseEntity |
| 181 | + .status(HttpStatusCode.valueOf(202)) |
| 182 | + .body(resul); |
| 183 | + } |
| 184 | + |
161 | 185 | @Tag(name = "Batchs", description = "Batchs API")
|
162 | 186 | @PostMapping(value = "/batchs", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
163 | 187 | @Operation(description = "Batch list",
|
|
0 commit comments