|
|
|
|
@ -2,12 +2,10 @@ package com.mfsys.aconnect.client.service;
|
|
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.client.dto.DepositAuthorizationRequest;
|
|
|
|
|
import com.mfsys.aconnect.client.dto.GLAuthorizationDTO;
|
|
|
|
|
import com.mfsys.aconnect.configuration.config.WebClientConfig;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.http.*;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import static com.mfsys.common.configuration.constant.AconnectURI.ACONNECT;
|
|
|
|
|
|
|
|
|
|
@ -20,12 +18,11 @@ public class TransactionAuthorizationService {
|
|
|
|
|
@Value("${app.generalledger.uri}")
|
|
|
|
|
private String generalledgerURI;
|
|
|
|
|
|
|
|
|
|
private final RestTemplate restTemplate;
|
|
|
|
|
public TransactionAuthorizationService(RestTemplate restTemplate) {
|
|
|
|
|
this.restTemplate = restTemplate;
|
|
|
|
|
}
|
|
|
|
|
private final WebClientConfig webClientConfig;
|
|
|
|
|
public TransactionAuthorizationService(WebClientConfig webClientConfig) {
|
|
|
|
|
this.webClientConfig = webClientConfig;}
|
|
|
|
|
|
|
|
|
|
public Object processDepositAuthTransaction(DepositAuthorizationRequest authorizationRequest, String tokenHeader) {
|
|
|
|
|
public ResponseEntity<Object> processDepositAuthTransaction(DepositAuthorizationRequest authorizationRequest, String tokenHeader) {
|
|
|
|
|
String porOrgacode = authorizationRequest.getPorOrgacode();
|
|
|
|
|
String url = depositURI + "/deposit/" + "/organizations/" + porOrgacode + "/transactions" + ACONNECT + "/authorizations";
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
@ -35,19 +32,14 @@ public class TransactionAuthorizationService {
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
headers.setAccept(java.util.List.of(MediaType.APPLICATION_JSON));
|
|
|
|
|
|
|
|
|
|
HttpEntity<DepositAuthorizationRequest> entity = new HttpEntity<>(authorizationRequest, headers);
|
|
|
|
|
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.exchange(
|
|
|
|
|
return webClientConfig.post(
|
|
|
|
|
url,
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
entity,
|
|
|
|
|
Map.class
|
|
|
|
|
authorizationRequest,
|
|
|
|
|
headers
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object processGLAuthTransaction(GLAuthorizationDTO authorizationRequest, String tokenHeader) {
|
|
|
|
|
public ResponseEntity<Object> processGLAuthTransaction(GLAuthorizationDTO authorizationRequest, String tokenHeader) {
|
|
|
|
|
String porOrgacode = authorizationRequest.getPorOrgacode();
|
|
|
|
|
String url = generalledgerURI + "/generalledger/" + "/organizations/" + porOrgacode + "/transactions/authorizations";
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
@ -56,16 +48,11 @@ public class TransactionAuthorizationService {
|
|
|
|
|
headers.set("SUS_USERCODE", authorizationRequest.getSusUsercode());
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
|
|
HttpEntity<GLAuthorizationDTO> entity = new HttpEntity<>(authorizationRequest, headers);
|
|
|
|
|
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.exchange(
|
|
|
|
|
return webClientConfig.post(
|
|
|
|
|
url,
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
entity,
|
|
|
|
|
Map.class
|
|
|
|
|
authorizationRequest,
|
|
|
|
|
headers
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|