|
|
|
@ -1,16 +1,11 @@
|
|
|
|
package com.mfsys.aconnect.client.service;
|
|
|
|
package com.mfsys.aconnect.client.service;
|
|
|
|
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.client.dto.ApproveCRMRequestDTO;
|
|
|
|
import com.mfsys.aconnect.client.dto.ApproveCRMRequestDTO;
|
|
|
|
import com.mfsys.aconnect.client.dto.WorkflowApprovalDTO;
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.client.dto.WorkflowRequestDTO;
|
|
|
|
import com.mfsys.aconnect.client.dto.WorkflowRequestDTO;
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.configuration.config.WebClientConfig;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.http.*;
|
|
|
|
import org.springframework.http.*;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class CRMService {
|
|
|
|
public class CRMService {
|
|
|
|
@ -18,9 +13,9 @@ public class CRMService {
|
|
|
|
@Value("${app.crm.uri}")
|
|
|
|
@Value("${app.crm.uri}")
|
|
|
|
private String crmURI;
|
|
|
|
private String crmURI;
|
|
|
|
|
|
|
|
|
|
|
|
private final RestTemplate restTemplate;
|
|
|
|
private final WebClientConfig webClientConfig;
|
|
|
|
public CRMService(RestTemplate restTemplate) {
|
|
|
|
public CRMService(WebClientConfig webClientConfig) {
|
|
|
|
this.restTemplate = restTemplate;
|
|
|
|
this.webClientConfig = webClientConfig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Object createIndividualCRM(WorkflowRequestDTO workflowRequestDTO, String token) {
|
|
|
|
public Object createIndividualCRM(WorkflowRequestDTO workflowRequestDTO, String token) {
|
|
|
|
@ -32,16 +27,12 @@ public class CRMService {
|
|
|
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUsercode());
|
|
|
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUsercode());
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
|
|
|
|
HttpEntity<WorkflowRequestDTO> entity = new HttpEntity<>(workflowRequestDTO, headers);
|
|
|
|
return webClientConfig.post(
|
|
|
|
|
|
|
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.exchange(
|
|
|
|
|
|
|
|
url,
|
|
|
|
url,
|
|
|
|
HttpMethod.POST,
|
|
|
|
workflowRequestDTO,
|
|
|
|
entity,
|
|
|
|
headers
|
|
|
|
Map.class
|
|
|
|
)
|
|
|
|
);
|
|
|
|
.getBody();
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Object createBusinessCRM(WorkflowRequestDTO workflowRequestDTO, String token) {
|
|
|
|
public Object createBusinessCRM(WorkflowRequestDTO workflowRequestDTO, String token) {
|
|
|
|
@ -53,16 +44,12 @@ public class CRMService {
|
|
|
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUsercode());
|
|
|
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUsercode());
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
|
|
|
|
HttpEntity<WorkflowRequestDTO> entity = new HttpEntity<>(workflowRequestDTO, headers);
|
|
|
|
return webClientConfig.post(
|
|
|
|
|
|
|
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.exchange(
|
|
|
|
|
|
|
|
url,
|
|
|
|
url,
|
|
|
|
HttpMethod.POST,
|
|
|
|
workflowRequestDTO,
|
|
|
|
entity,
|
|
|
|
headers
|
|
|
|
Map.class
|
|
|
|
)
|
|
|
|
);
|
|
|
|
.getBody();
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Object approveIndividualCRM(ApproveCRMRequestDTO approveCRMRequestDTO, String token) {
|
|
|
|
public Object approveIndividualCRM(ApproveCRMRequestDTO approveCRMRequestDTO, String token) {
|
|
|
|
@ -74,16 +61,12 @@ public class CRMService {
|
|
|
|
headers.set("SUS_USERCODE", approveCRMRequestDTO.getSusUserCode());
|
|
|
|
headers.set("SUS_USERCODE", approveCRMRequestDTO.getSusUserCode());
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
|
|
|
|
HttpEntity<ApproveCRMRequestDTO> entity = new HttpEntity<>(approveCRMRequestDTO, headers);
|
|
|
|
return webClientConfig.patch(
|
|
|
|
|
|
|
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.exchange(
|
|
|
|
|
|
|
|
url,
|
|
|
|
url,
|
|
|
|
HttpMethod.PATCH,
|
|
|
|
approveCRMRequestDTO,
|
|
|
|
entity,
|
|
|
|
headers
|
|
|
|
Map.class
|
|
|
|
)
|
|
|
|
);
|
|
|
|
.getBody();
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Object approveBusinessCRM(ApproveCRMRequestDTO approveCRMRequestDTO, String token) {
|
|
|
|
public Object approveBusinessCRM(ApproveCRMRequestDTO approveCRMRequestDTO, String token) {
|
|
|
|
@ -95,16 +78,12 @@ public class CRMService {
|
|
|
|
headers.set("SUS_USERCODE", approveCRMRequestDTO.getSusUserCode());
|
|
|
|
headers.set("SUS_USERCODE", approveCRMRequestDTO.getSusUserCode());
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
|
|
|
|
HttpEntity<ApproveCRMRequestDTO> entity = new HttpEntity<>(approveCRMRequestDTO, headers);
|
|
|
|
return webClientConfig.patch(
|
|
|
|
|
|
|
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.exchange(
|
|
|
|
|
|
|
|
url,
|
|
|
|
url,
|
|
|
|
HttpMethod.PATCH,
|
|
|
|
approveCRMRequestDTO,
|
|
|
|
entity,
|
|
|
|
headers
|
|
|
|
Map.class
|
|
|
|
)
|
|
|
|
);
|
|
|
|
.getBody();
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|