Compare commits
No commits in common. "b35968b5c60281aaadc0214123981239bf312bd2" and "9d4a4f4c54d41f36bf011f76b2150d0ef8f789d0" have entirely different histories.
b35968b5c6
...
9d4a4f4c54
4
pom.xml
4
pom.xml
@ -77,10 +77,6 @@
|
|||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-smallrye-health</artifactId>
|
<artifactId>quarkus-smallrye-health</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>commons-codec</groupId>
|
|
||||||
<artifactId>commons-codec</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
|||||||
Binary file not shown.
@ -40,14 +40,6 @@ public class MessageHelper {
|
|||||||
this.errorMappings = initializeErrorMappings();
|
this.errorMappings = initializeErrorMappings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Response handleSuccess(Object data, String statusCode) {
|
|
||||||
log.info(
|
|
||||||
"Respuesta exitosa controlada: {}",
|
|
||||||
statusCode
|
|
||||||
);
|
|
||||||
return buildResponse(data, statusCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Response handleException(HttpStatusCodeException exception) {
|
public Response handleException(HttpStatusCodeException exception) {
|
||||||
log.error(
|
log.error(
|
||||||
"Error interno controlado: {} -> {}",
|
"Error interno controlado: {} -> {}",
|
||||||
@ -118,25 +110,6 @@ public class MessageHelper {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response buildResponse(Object data, String statusCode) {
|
|
||||||
ErrorMapping mapping = errorMappings.getOrDefault(
|
|
||||||
statusCode, errorMappings.getOrDefault(
|
|
||||||
statusCode, createDefaultMapping()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
StatusResponse status = createError(mapping, null);
|
|
||||||
|
|
||||||
log.error(
|
|
||||||
"[Success] Message {} -> {}",
|
|
||||||
statusCode,
|
|
||||||
status.getMessage()
|
|
||||||
);
|
|
||||||
|
|
||||||
return Response.status(mapping.getHttpCode())
|
|
||||||
.entity(new ApiResponse<>(data, status))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, ErrorMapping> initializeErrorMappings() {
|
private Map<String, ErrorMapping> initializeErrorMappings() {
|
||||||
try {
|
try {
|
||||||
String json;
|
String json;
|
||||||
|
|||||||
@ -1,17 +1,12 @@
|
|||||||
package com.banesco.common.application.helper;
|
package com.banesco.common.application.helper;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.netty.util.internal.StringUtil;
|
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.util.Base64;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
@ -38,14 +33,6 @@ public class SerializationHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String encodeStringToBase64(String text) {
|
|
||||||
if (StringUtil.isNullOrEmpty(text)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.UTF_8));
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> T decodeBase64(String base64String, Class<T> clazz) {
|
public <T> T decodeBase64(String base64String, Class<T> clazz) {
|
||||||
try {
|
try {
|
||||||
byte[] decodedBytes = Base64.getDecoder().decode(base64String);
|
byte[] decodedBytes = Base64.getDecoder().decode(base64String);
|
||||||
@ -57,116 +44,4 @@ public class SerializationHelper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String encodeSha256(String json) {
|
|
||||||
return DigestUtils.sha256Hex(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> String toJsonString(T element) {
|
|
||||||
if (element == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return objectMapper.writeValueAsString(element);
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
log.error("Error al convertir objeto a Json String: {}", e.getMessage());
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> Map<String, Object> toMap(T element) {
|
|
||||||
return toMap(element, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> Map<String, Object> toMap(
|
|
||||||
T element,
|
|
||||||
List<String> excludedFields
|
|
||||||
) {
|
|
||||||
if (element == null) {
|
|
||||||
return new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Map<String, Object> map = objectMapper.convertValue(
|
|
||||||
element, new TypeReference<>() {}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (excludedFields != null && !excludedFields.isEmpty()) {
|
|
||||||
Set<String> excludedSet = new HashSet<>(excludedFields);
|
|
||||||
excludedSet.forEach(map::remove);
|
|
||||||
}
|
|
||||||
|
|
||||||
return map;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Error al convertir objeto a Map: {}", e.getMessage());
|
|
||||||
return new HashMap<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> Map<String, Object> toTreeMap(T element) {
|
|
||||||
return toTreeMap(element, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> Map<String, Object> toTreeMap(
|
|
||||||
T element,
|
|
||||||
List<String> excludedFields
|
|
||||||
) {
|
|
||||||
if (element == null) {
|
|
||||||
return new TreeMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Map<String, Object> tempMap = objectMapper.convertValue(
|
|
||||||
element, new TypeReference<>() {}
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, Object> treeMap = new TreeMap<>(tempMap);
|
|
||||||
|
|
||||||
if (excludedFields != null && !excludedFields.isEmpty()) {
|
|
||||||
Set<String> excludedSet = new HashSet<>(excludedFields);
|
|
||||||
excludedSet.forEach(treeMap::remove);
|
|
||||||
}
|
|
||||||
|
|
||||||
return treeMap;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Error al convertir objeto a TreeMap: {}", e.getMessage());
|
|
||||||
return new TreeMap<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String generateSignature(
|
|
||||||
Object operation,
|
|
||||||
String channelOrigin
|
|
||||||
) {
|
|
||||||
Map<String, Object> operationSortedMap = toTreeMap(operation);
|
|
||||||
StringBuilder concatenatedValues = new StringBuilder();
|
|
||||||
String channelBase64 = encodeStringToBase64(channelOrigin);
|
|
||||||
|
|
||||||
for (Object value : operationSortedMap.values()) {
|
|
||||||
if(!Objects.isNull(value)) {
|
|
||||||
concatenatedValues.append(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String finalString = concatenatedValues + channelBase64;
|
|
||||||
|
|
||||||
log.info("1. Operation concatenando valores: {}", concatenatedValues);
|
|
||||||
log.info("2. Channel Origin codificado: {}", channelBase64);
|
|
||||||
|
|
||||||
return encodeSha256(finalString);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String generateSignature(
|
|
||||||
Long id,
|
|
||||||
String channelOrigin
|
|
||||||
) {
|
|
||||||
String channelBase64 = encodeStringToBase64(channelOrigin);
|
|
||||||
String finalString = id + channelBase64;
|
|
||||||
|
|
||||||
log.info("1. Operation concatenando valores: {}", finalString);
|
|
||||||
log.info("2. Channel Origin codificado: {}", channelBase64);
|
|
||||||
|
|
||||||
return encodeSha256(finalString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,8 +17,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -36,61 +34,56 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T execute(HttpRequest request) {
|
public <T> T execute(HttpRequest request) {
|
||||||
return executeRequest(request);
|
return executeInternal(request);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T, R> Either<T, R> executeEither(HttpRequest request) {
|
|
||||||
return executeEitherInternal(request, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T, R> Either<List<T>, R> executeEitherList(HttpRequest request) {
|
|
||||||
return executeEitherInternal(request, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> ApiResponse<T> executeApiResponse(HttpRequest request) {
|
public <T> ApiResponse<T> executeApiResponse(HttpRequest request) {
|
||||||
return executeRequest(request);
|
return executeInternal(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> ApiResponse<List<T>> executeApiResponseList(HttpRequest request) {
|
public <T> ApiResponse<List<T>> executeApiResponseList(
|
||||||
return executeRequest(request);
|
HttpRequest request
|
||||||
|
) {
|
||||||
|
return executeInternal(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> ApiPrivateResponse<Either<T, ApiPrivateError>> executeApiPrivateResponse(HttpRequest request) {
|
public <T> ApiPrivateResponse<Either<T, ApiPrivateError>> executeApiPrivateResponse(
|
||||||
return executeRequest(request);
|
HttpRequest request
|
||||||
|
) {
|
||||||
|
return executeInternal(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> ApiPrivateResponse<Either<List<T>, ApiPrivateError>> executeApiPrivateResponseList(HttpRequest request) {
|
public <T> ApiPrivateResponse<Either<List<T>, ApiPrivateError>> executeApiPrivateResponseList(
|
||||||
return executeRequest(request);
|
HttpRequest request
|
||||||
|
) {
|
||||||
|
return executeInternal(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T, R> Either<T, R> executeEitherInternal(HttpRequest request, boolean isList) {
|
private <T> T executeInternal(HttpRequest request) {
|
||||||
try (Client client = createClient(request.getConnectTimeout(), request.getReadTimeout())) {
|
String finalUrl = buildFinalUrl(request);
|
||||||
WebTarget target = client.target(buildFinalUrl(request));
|
|
||||||
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON);
|
|
||||||
|
|
||||||
if (request.getHeaders() != null) {
|
if (request.isLogRequestBody()) {
|
||||||
request.getHeaders().forEach(builder::header);
|
log.info("URL final: {}", finalUrl);
|
||||||
|
|
||||||
|
if (request.getHeaders() != null && !request.getHeaders().isEmpty()) {
|
||||||
|
log.info("Headers: {}", request.getHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
Response response = buildRequest(builder, request);
|
if (request.getQueryParams() != null && !request.getQueryParams().isEmpty()) {
|
||||||
return handleEitherResponse(request, response, isList);
|
log.info("Query params: {}", request.getQueryParams());
|
||||||
|
}
|
||||||
|
|
||||||
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
if (request.getBody() != null) {
|
||||||
throw e;
|
log.info("Body: {}", request.getBody());
|
||||||
} catch (Exception e) {
|
}
|
||||||
throw handleConnectionError(request, e);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private <T> T executeRequest(HttpRequest request) {
|
|
||||||
try (Client client = createClient(request.getConnectTimeout(), request.getReadTimeout())) {
|
try (Client client = createClient(request.getConnectTimeout(), request.getReadTimeout())) {
|
||||||
WebTarget target = client.target(buildFinalUrl(request));
|
WebTarget target = client.target(finalUrl);
|
||||||
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON);
|
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
if (request.getHeaders() != null) {
|
if (request.getHeaders() != null) {
|
||||||
@ -102,122 +95,14 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw handleConnectionError(request, e);
|
log.error("Error de conexion {}: {}", request.getMethod(), e.getMessage());
|
||||||
|
throw HttpStatusCodeException.serviceUnavailable(
|
||||||
|
"503",
|
||||||
|
"Error de conexion con el servicio externo: " + e.getMessage()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <T, R> Either<T, R> handleEitherResponse(HttpRequest request, Response response, boolean isList) {
|
|
||||||
int statusCode = response.getStatus();
|
|
||||||
|
|
||||||
try (response) {
|
|
||||||
String responseBody = response.readEntity(String.class);
|
|
||||||
logResponse(request, statusCode, responseBody);
|
|
||||||
|
|
||||||
if (statusCode >= 200 && statusCode < 300) {
|
|
||||||
Object successData = isList
|
|
||||||
? parseSuccessListResponse(request, responseBody)
|
|
||||||
: parseSuccessResponse(request, responseBody);
|
|
||||||
return Either.left((T) successData);
|
|
||||||
} else {
|
|
||||||
logErrorResponse(request, statusCode, responseBody);
|
|
||||||
R errorData = tryParseErrorResponse(request, responseBody);
|
|
||||||
|
|
||||||
if (errorData != null) {
|
|
||||||
return Either.right(errorData);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw mapHttpStatusToException(statusCode, responseBody);
|
|
||||||
}
|
|
||||||
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
|
||||||
throw e;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw handleProcessingError(request, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <T> T parseSuccessResponse(HttpRequest request, String responseBody) throws JsonProcessingException {
|
|
||||||
Type successType = extractSuccessType(request);
|
|
||||||
|
|
||||||
if (successType != null) {
|
|
||||||
if (successType instanceof Class) {
|
|
||||||
return objectMapper.readValue(responseBody, (Class<T>) successType);
|
|
||||||
} else if (successType instanceof ParameterizedType) {
|
|
||||||
JavaType javaType = objectMapper.getTypeFactory().constructType(successType);
|
|
||||||
return objectMapper.readValue(responseBody, javaType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.getResponseType() != null && request.getResponseType() != Object.class) {
|
|
||||||
return objectMapper.readValue(responseBody, objectMapper.getTypeFactory().constructType(request.getResponseType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return (T) objectMapper.readValue(responseBody, Object.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <T> List<T> parseSuccessListResponse(HttpRequest request, String responseBody) throws JsonProcessingException {
|
|
||||||
Type successType = extractSuccessType(request);
|
|
||||||
|
|
||||||
if (
|
|
||||||
successType instanceof ParameterizedType paramType &&
|
|
||||||
paramType.getRawType() == List.class &&
|
|
||||||
paramType.getActualTypeArguments().length > 0
|
|
||||||
) {
|
|
||||||
Type elementType = paramType.getActualTypeArguments()[0];
|
|
||||||
if (elementType instanceof Class) {
|
|
||||||
JavaType javaType = objectMapper.getTypeFactory().constructCollectionType(
|
|
||||||
List.class, (Class<T>) elementType
|
|
||||||
);
|
|
||||||
return objectMapper.readValue(responseBody, javaType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return objectMapper.readValue(responseBody, List.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Type extractSuccessType(HttpRequest request) {
|
|
||||||
if (
|
|
||||||
request.getComplexType() != null &&
|
|
||||||
request.getComplexType() instanceof ParameterizedType paramType &&
|
|
||||||
paramType.getRawType() == Either.class &&
|
|
||||||
paramType.getActualTypeArguments().length > 0
|
|
||||||
) {
|
|
||||||
return paramType.getActualTypeArguments()[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.getGenericType() != null) {
|
|
||||||
return request.getGenericType();
|
|
||||||
}
|
|
||||||
|
|
||||||
return request.getResponseType();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <R> R tryParseErrorResponse(HttpRequest request, String responseBody) {
|
|
||||||
if (responseBody == null || responseBody.trim().isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (request.getErrorType() != null) {
|
|
||||||
return (R) objectMapper.readValue(responseBody, request.getErrorType());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.getComplexType() != null && request.getComplexType() instanceof ParameterizedType paramType) {
|
|
||||||
Type[] typeArgs = paramType.getActualTypeArguments();
|
|
||||||
if (typeArgs.length >= 2 && typeArgs[1] instanceof Class) {
|
|
||||||
return objectMapper.readValue(responseBody, (Class<R>) typeArgs[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("No se pudo parsear la respuesta como error type: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String buildFinalUrl(HttpRequest request) {
|
private String buildFinalUrl(HttpRequest request) {
|
||||||
String finalUrl = request.getUrl();
|
String finalUrl = request.getUrl();
|
||||||
|
|
||||||
@ -228,11 +113,7 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String url = appendQueryParams(finalUrl, request.getQueryParams());
|
return appendQueryParams(finalUrl, request.getQueryParams());
|
||||||
|
|
||||||
log.info("Url Final: {}", url);
|
|
||||||
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String appendQueryParams(String url, Map<String, String> queryParams) {
|
private String appendQueryParams(String url, Map<String, String> queryParams) {
|
||||||
@ -251,24 +132,20 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
urlBuilder.append("&");
|
urlBuilder.append("&");
|
||||||
}
|
}
|
||||||
|
|
||||||
String encodedKey = URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8);
|
urlBuilder.append(entry.getKey())
|
||||||
String encodedValue = entry.getValue() != null
|
.append("=")
|
||||||
? URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8)
|
.append(entry.getValue() != null ? entry.getValue() : "");
|
||||||
: "";
|
|
||||||
|
|
||||||
urlBuilder.append(encodedKey).append("=").append(encodedValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return urlBuilder.toString();
|
return urlBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response buildRequest(Invocation.Builder builder, HttpRequest request) {
|
private Response buildRequest(
|
||||||
|
Invocation.Builder builder,
|
||||||
|
HttpRequest request
|
||||||
|
) {
|
||||||
log.info("Metodo HTTP: {}", request.getMethod().name());
|
log.info("Metodo HTTP: {}", request.getMethod().name());
|
||||||
|
|
||||||
if(request.getBody() != null) {
|
|
||||||
log.info("Peticion Cuerpo: {}", request.getBody());
|
|
||||||
}
|
|
||||||
|
|
||||||
return switch (request.getMethod()) {
|
return switch (request.getMethod()) {
|
||||||
case GET -> builder.get();
|
case GET -> builder.get();
|
||||||
case POST -> builder.post(Entity.entity(request.getBody(), MediaType.APPLICATION_JSON));
|
case POST -> builder.post(Entity.entity(request.getBody(), MediaType.APPLICATION_JSON));
|
||||||
@ -283,26 +160,43 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
|
|
||||||
private Client createClient(int connectTimeout, int readTimeout) {
|
private Client createClient(int connectTimeout, int readTimeout) {
|
||||||
return ClientBuilder.newBuilder()
|
return ClientBuilder.newBuilder()
|
||||||
.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
|
.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
|
||||||
.readTimeout(readTimeout, TimeUnit.MILLISECONDS)
|
.readTimeout(readTimeout, TimeUnit.MILLISECONDS)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T handleResponse(HttpRequest request, Response response) {
|
private <T> T handleResponse(
|
||||||
|
HttpRequest request,
|
||||||
|
Response response
|
||||||
|
) {
|
||||||
int statusCode = response.getStatus();
|
int statusCode = response.getStatus();
|
||||||
|
log.info("Respuesta {} - Status: {}", request.getMethod(), statusCode);
|
||||||
|
|
||||||
try (response) {
|
try (response) {
|
||||||
String responseBody = response.readEntity(String.class);
|
String responseBody = response.readEntity(String.class);
|
||||||
logResponse(request, statusCode, responseBody);
|
|
||||||
|
if (request.isLogResponseBody()) {
|
||||||
|
log.info("Respuesta Cuerpo: {}", responseBody);
|
||||||
|
}
|
||||||
|
|
||||||
if (statusCode >= 200 && statusCode < 300) {
|
if (statusCode >= 200 && statusCode < 300) {
|
||||||
if (request.getResponseType() == Void.class || request.getResponseType() == void.class) {
|
if (request.getResponseType() == Void.class || request.getResponseType() == void.class) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return responseResult(request, responseBody);
|
T result = responseResult(request, responseBody);
|
||||||
|
|
||||||
|
log.debug("Respuesta exitosa {} {}: {}", request.getMethod(), request.getUrl(), result);
|
||||||
|
|
||||||
|
return result;
|
||||||
} else {
|
} else {
|
||||||
logErrorResponse(request, statusCode, responseBody);
|
log.error(
|
||||||
|
"Error HTTP {} {} - Status: {} - Body: {}",
|
||||||
|
request.getMethod(),
|
||||||
|
request.getUrl(),
|
||||||
|
statusCode,
|
||||||
|
responseBody
|
||||||
|
);
|
||||||
|
|
||||||
if (isApiResponseFormat(responseBody)) {
|
if (isApiResponseFormat(responseBody)) {
|
||||||
ApiResponse<?> apiResponse = deserializeApiResponse(responseBody, request);
|
ApiResponse<?> apiResponse = deserializeApiResponse(responseBody, request);
|
||||||
@ -314,72 +208,53 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw handleProcessingError(request, e);
|
log.error(
|
||||||
|
"Error procesando respuesta {} {}: {}",
|
||||||
|
request.getMethod(),
|
||||||
|
request.getUrl(),
|
||||||
|
e.getMessage()
|
||||||
|
);
|
||||||
|
throw HttpStatusCodeException.internalServer(
|
||||||
|
"500", "Error procesando respuesta del servicio externo: " + e.getMessage()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logResponse(HttpRequest request, int statusCode, String responseBody) {
|
private <T> T responseResult(
|
||||||
if (request.isLogResponseBody()) {
|
HttpRequest request,
|
||||||
log.info("Respuesta {} - Status: {}", request.getMethod(), statusCode);
|
String responseBody
|
||||||
log.info("Respuesta Cuerpo: {}", responseBody);
|
) throws JsonProcessingException {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void logErrorResponse(HttpRequest request, int statusCode, String responseBody) {
|
|
||||||
log.error(
|
|
||||||
"Error HTTP {} {} - Status: {} - Body: {}",
|
|
||||||
request.getMethod(),
|
|
||||||
request.getUrl(),
|
|
||||||
statusCode,
|
|
||||||
responseBody
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HttpStatusCodeException handleConnectionError(HttpRequest request, Exception e) {
|
|
||||||
log.error("Error de conexion {}: {}", request.getMethod(), e.getMessage());
|
|
||||||
|
|
||||||
return HttpStatusCodeException.serviceUnavailable(
|
|
||||||
"503", "Error de conexion con el servicio externo: " + e.getMessage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HttpStatusCodeException handleProcessingError(HttpRequest request, Exception e) {
|
|
||||||
log.error(
|
|
||||||
"Error procesando respuesta {} {}: {}",
|
|
||||||
request.getMethod(),
|
|
||||||
request.getUrl(),
|
|
||||||
e.getMessage()
|
|
||||||
);
|
|
||||||
return HttpStatusCodeException.internalServer(
|
|
||||||
"500", "Error procesando respuesta del servicio externo: " + e.getMessage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> T responseResult(HttpRequest request, String responseBody) throws JsonProcessingException {
|
|
||||||
if (request.isApiPrivateResponse() && request.isEitherResponse()) {
|
if (request.isApiPrivateResponse() && request.isEitherResponse()) {
|
||||||
return handleApiPrivateResponseWithEither(request, responseBody);
|
return handleApiPrivateResponseWithEither(request, responseBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T result;
|
||||||
|
|
||||||
if (request.getResponseType() == ApiResponse.class) {
|
if (request.getResponseType() == ApiResponse.class) {
|
||||||
return deserializeApiResponse(responseBody, request);
|
result = deserializeApiResponse(responseBody, request);
|
||||||
} else if (request.getComplexType() != null) {
|
} else if (request.getComplexType() != null) {
|
||||||
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
||||||
request.getResponseType(), objectMapper.getTypeFactory().constructType(request.getComplexType())
|
request.getResponseType(), objectMapper.getTypeFactory().constructType(request.getComplexType())
|
||||||
);
|
);
|
||||||
return objectMapper.readValue(responseBody, javaType);
|
result = objectMapper.readValue(responseBody, javaType);
|
||||||
} else if (request.getGenericType() != null) {
|
} else if (request.getGenericType() != null) {
|
||||||
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
||||||
request.getResponseType(), objectMapper.getTypeFactory().constructType(request.getGenericType())
|
request.getResponseType(), objectMapper.getTypeFactory().constructType(request.getGenericType())
|
||||||
);
|
);
|
||||||
return objectMapper.readValue(responseBody, javaType);
|
result = objectMapper.readValue(responseBody, javaType);
|
||||||
} else {
|
} else {
|
||||||
return objectMapper.readValue(
|
result = objectMapper.readValue(
|
||||||
responseBody, objectMapper.getTypeFactory().constructType(request.getResponseType())
|
responseBody, objectMapper.getTypeFactory().constructType(request.getResponseType())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T handleApiPrivateResponseWithEither(HttpRequest request, String responseBody) throws JsonProcessingException {
|
private <T> T handleApiPrivateResponseWithEither(
|
||||||
|
HttpRequest request,
|
||||||
|
String responseBody
|
||||||
|
) throws JsonProcessingException {
|
||||||
JsonNode rootNode = objectMapper.readTree(responseBody);
|
JsonNode rootNode = objectMapper.readTree(responseBody);
|
||||||
String status = rootNode.has("estatus") ? rootNode.get("estatus").asText() : null;
|
String status = rootNode.has("estatus") ? rootNode.get("estatus").asText() : null;
|
||||||
String message = rootNode.has("mensaje") ? rootNode.get("mensaje").asText() : null;
|
String message = rootNode.has("mensaje") ? rootNode.get("mensaje").asText() : null;
|
||||||
@ -393,7 +268,12 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> T handleSuccessResponse(HttpRequest request, String status, String message, JsonNode detailNode) {
|
private <T> T handleSuccessResponse(
|
||||||
|
HttpRequest request,
|
||||||
|
String status,
|
||||||
|
String message,
|
||||||
|
JsonNode detailNode
|
||||||
|
) {
|
||||||
Object successData;
|
Object successData;
|
||||||
|
|
||||||
if (request.isListResponse()) {
|
if (request.isListResponse()) {
|
||||||
@ -415,7 +295,10 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object handleListSuccess(HttpRequest request, JsonNode detailNode) {
|
private Object handleListSuccess(
|
||||||
|
HttpRequest request,
|
||||||
|
JsonNode detailNode
|
||||||
|
) {
|
||||||
Class<?> elementType = getElementTypeFromRequest(request);
|
Class<?> elementType = getElementTypeFromRequest(request);
|
||||||
JavaType listType = objectMapper.getTypeFactory().constructCollectionType(List.class, elementType);
|
JavaType listType = objectMapper.getTypeFactory().constructCollectionType(List.class, elementType);
|
||||||
|
|
||||||
@ -426,7 +309,10 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object handleObjectSuccess(HttpRequest request, JsonNode detailNode) {
|
private Object handleObjectSuccess(
|
||||||
|
HttpRequest request,
|
||||||
|
JsonNode detailNode
|
||||||
|
) {
|
||||||
Class<?> elementType = getElementTypeFromRequest(request);
|
Class<?> elementType = getElementTypeFromRequest(request);
|
||||||
|
|
||||||
if (detailNode != null && !detailNode.isNull()) {
|
if (detailNode != null && !detailNode.isNull()) {
|
||||||
@ -437,7 +323,11 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> T handleErrorResponse(String status, String message, JsonNode detailNode) {
|
private <T> T handleErrorResponse(
|
||||||
|
String status,
|
||||||
|
String message,
|
||||||
|
JsonNode detailNode
|
||||||
|
) {
|
||||||
ApiPrivateError error = buildApiPrivateError(detailNode, message);
|
ApiPrivateError error = buildApiPrivateError(detailNode, message);
|
||||||
ApiPrivateResponse<Either<Object, ApiPrivateError>> response = new ApiPrivateResponse<>();
|
ApiPrivateResponse<Either<Object, ApiPrivateError>> response = new ApiPrivateResponse<>();
|
||||||
|
|
||||||
@ -448,7 +338,10 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
return (T) response;
|
return (T) response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiPrivateError buildApiPrivateError(JsonNode detailNode, String message) {
|
private ApiPrivateError buildApiPrivateError(
|
||||||
|
JsonNode detailNode,
|
||||||
|
String message
|
||||||
|
) {
|
||||||
if (detailNode != null && !detailNode.isNull()) {
|
if (detailNode != null && !detailNode.isNull()) {
|
||||||
try {
|
try {
|
||||||
return objectMapper.convertValue(detailNode, ApiPrivateError.class);
|
return objectMapper.convertValue(detailNode, ApiPrivateError.class);
|
||||||
@ -492,11 +385,15 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> T deserializeApiResponse(String responseBody, HttpRequest request) {
|
private <T> T deserializeApiResponse(
|
||||||
|
String responseBody,
|
||||||
|
HttpRequest request
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
if (request.getGenericType() != null) {
|
if (request.getGenericType() != null) {
|
||||||
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
||||||
ApiResponse.class, objectMapper.getTypeFactory().constructType(request.getGenericType())
|
ApiResponse.class,
|
||||||
|
objectMapper.getTypeFactory().constructType(request.getGenericType())
|
||||||
);
|
);
|
||||||
return objectMapper.readValue(responseBody, javaType);
|
return objectMapper.readValue(responseBody, javaType);
|
||||||
} else {
|
} else {
|
||||||
@ -530,7 +427,10 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpStatusCodeException mapHttpStatusToException(int statusCode, String errorBody) {
|
private HttpStatusCodeException mapHttpStatusToException(
|
||||||
|
int statusCode,
|
||||||
|
String errorBody
|
||||||
|
) {
|
||||||
String errorCode = "HTTP_" + statusCode;
|
String errorCode = "HTTP_" + statusCode;
|
||||||
String defaultMessage = "Error en servicio externo: HTTP " + statusCode;
|
String defaultMessage = "Error en servicio externo: HTTP " + statusCode;
|
||||||
String message = errorBody != null && !errorBody.isEmpty()
|
String message = errorBody != null && !errorBody.isEmpty()
|
||||||
|
|||||||
@ -8,10 +8,6 @@ public interface HttpClientUseCase {
|
|||||||
|
|
||||||
<T> T execute(HttpRequest request);
|
<T> T execute(HttpRequest request);
|
||||||
|
|
||||||
<T, R> Either<T, R> executeEither(HttpRequest request);
|
|
||||||
|
|
||||||
<T, R> Either<List<T>, R> executeEitherList(HttpRequest request);
|
|
||||||
|
|
||||||
<T> ApiResponse<T> executeApiResponse(HttpRequest request);
|
<T> ApiResponse<T> executeApiResponse(HttpRequest request);
|
||||||
|
|
||||||
<T> ApiResponse<List<T>> executeApiResponseList(HttpRequest request);
|
<T> ApiResponse<List<T>> executeApiResponseList(HttpRequest request);
|
||||||
|
|||||||
@ -1,17 +0,0 @@
|
|||||||
package com.banesco.common.domain.model;
|
|
||||||
|
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@ToString
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@RegisterForReflection
|
|
||||||
public class Device {
|
|
||||||
private String deviceType;
|
|
||||||
private String deviceDescription;
|
|
||||||
private String deviceIp;
|
|
||||||
private String deviceSessionReference;
|
|
||||||
}
|
|
||||||
@ -6,9 +6,7 @@ public class RequestContext {
|
|||||||
|
|
||||||
private RequestContext() {}
|
private RequestContext() {}
|
||||||
|
|
||||||
public static final String REQUEST_ID = "requestId";
|
private static final String REQUEST_ID = "requestId";
|
||||||
public static final String DEVICE = "device";
|
|
||||||
public static final String DEVICE_SESSION_REFERENCE = "deviceSessionReference";
|
|
||||||
|
|
||||||
public static String getRequestId() {
|
public static String getRequestId() {
|
||||||
return MDC.get(REQUEST_ID);
|
return MDC.get(REQUEST_ID);
|
||||||
|
|||||||
@ -6,88 +6,15 @@ import jakarta.ws.rs.container.ContainerRequestFilter;
|
|||||||
import jakarta.ws.rs.container.ContainerResponseContext;
|
import jakarta.ws.rs.container.ContainerResponseContext;
|
||||||
import jakarta.ws.rs.container.ContainerResponseFilter;
|
import jakarta.ws.rs.container.ContainerResponseFilter;
|
||||||
import jakarta.ws.rs.ext.Provider;
|
import jakarta.ws.rs.ext.Provider;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Provider
|
@Provider
|
||||||
public class RequestIdFilter implements ContainerRequestFilter, ContainerResponseFilter {
|
public class RequestIdFilter implements ContainerRequestFilter, ContainerResponseFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void filter(ContainerRequestContext requestContext) {
|
public void filter(ContainerRequestContext requestContext) {
|
||||||
String requestId = requestContext.getHeaderString(RequestContext.DEVICE_SESSION_REFERENCE);
|
RequestContext.setRequestId(UUID.randomUUID().toString().substring(0, 13));
|
||||||
|
|
||||||
if (isEmpty(requestId)) {
|
|
||||||
requestId = requestContext.getUriInfo()
|
|
||||||
.getQueryParameters()
|
|
||||||
.getFirst(RequestContext.DEVICE_SESSION_REFERENCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isEmpty(requestId) && hasJsonBody(requestContext)) {
|
|
||||||
requestId = extractRequestIdFromBody(requestContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isEmpty(requestId)) {
|
|
||||||
requestId = UUID.randomUUID().toString().substring(0, 13);
|
|
||||||
}
|
|
||||||
|
|
||||||
RequestContext.setRequestId(requestId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isEmpty(String value) {
|
|
||||||
return value == null || value.trim().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasJsonBody(ContainerRequestContext context) {
|
|
||||||
try {
|
|
||||||
String method = context.getMethod();
|
|
||||||
String contentType = context.getHeaderString("Content-Type");
|
|
||||||
|
|
||||||
return ("POST".equals(method) || "PUT".equals(method))
|
|
||||||
&& contentType != null
|
|
||||||
&& contentType.contains("application/json");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn("La peticion no es un POST o PUT: {}", e.getMessage());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String extractRequestIdFromBody(ContainerRequestContext context) {
|
|
||||||
try {
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
||||||
context.getEntityStream().transferTo(buffer);
|
|
||||||
byte[] bodyBytes = buffer.toByteArray();
|
|
||||||
|
|
||||||
context.setEntityStream(new ByteArrayInputStream(bodyBytes));
|
|
||||||
|
|
||||||
String bodyString = new String(bodyBytes, StandardCharsets.UTF_8);
|
|
||||||
io.vertx.core.json.JsonObject jsonObject = new io.vertx.core.json.JsonObject(bodyString);
|
|
||||||
|
|
||||||
if (jsonObject.containsKey(RequestContext.DEVICE)) {
|
|
||||||
io.vertx.core.json.JsonObject device = jsonObject.getJsonObject(RequestContext.DEVICE);
|
|
||||||
|
|
||||||
if (device.containsKey(RequestContext.DEVICE_SESSION_REFERENCE)) {
|
|
||||||
return device.getString(RequestContext.DEVICE_SESSION_REFERENCE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonObject.containsKey(RequestContext.REQUEST_ID)) {
|
|
||||||
return jsonObject.getString(RequestContext.REQUEST_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonObject.containsKey(RequestContext.DEVICE_SESSION_REFERENCE)) {
|
|
||||||
return jsonObject.getString(RequestContext.DEVICE_SESSION_REFERENCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Error extrayendo el requestId del cuerpo de la peticion: {}", e.getMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -95,10 +22,6 @@ public class RequestIdFilter implements ContainerRequestFilter, ContainerRespons
|
|||||||
ContainerRequestContext requestContext,
|
ContainerRequestContext requestContext,
|
||||||
ContainerResponseContext responseContext
|
ContainerResponseContext responseContext
|
||||||
) {
|
) {
|
||||||
try {
|
RequestContext.clear();
|
||||||
RequestContext.clear();
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Error limpiando el filtro: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,5 +7,4 @@ public enum BankingProductType {
|
|||||||
BROKERED_PRODUCT,
|
BROKERED_PRODUCT,
|
||||||
TERM_DEPOSIT_PRODUCT,
|
TERM_DEPOSIT_PRODUCT,
|
||||||
MOBILE_PAYMENT,
|
MOBILE_PAYMENT,
|
||||||
NETUNO
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
package com.banesco.module.instruction.domain.model;
|
package com.banesco.module.instruction.domain.model;
|
||||||
|
|
||||||
|
import com.banesco.common.domain.exception.HttpStatusCodeException;
|
||||||
import com.banesco.common.domain.model.Identifier;
|
import com.banesco.common.domain.model.Identifier;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@Builder
|
@Builder
|
||||||
@ -15,12 +19,21 @@ import lombok.*;
|
|||||||
public class Instruction {
|
public class Instruction {
|
||||||
private InstructionIdentification instructionIdentifier; // Request JSON: "id"
|
private InstructionIdentification instructionIdentifier; // Request JSON: "id"
|
||||||
private String instructionDescription; // Request JSON: "signature"
|
private String instructionDescription; // Request JSON: "signature"
|
||||||
private String instructionPurposeType; // Request JSON: "channelOrigin" (BOLE)
|
private InstructionPurposeType instructionPurposeType; // Request JSON: "channelOrigin" (BOLE)
|
||||||
|
|
||||||
public static Instruction fromResource(
|
public static Instruction fromResource(
|
||||||
String paymentStatusId,
|
String paymentStatusId,
|
||||||
String channelCode
|
String channelCode,
|
||||||
|
String signatureIdentifier
|
||||||
) {
|
) {
|
||||||
|
boolean isChannelCodeValid = (Arrays.stream(
|
||||||
|
InstructionPurposeType.values()
|
||||||
|
).anyMatch(type -> Objects.equals(type.name(), channelCode)));
|
||||||
|
|
||||||
|
if(!isChannelCodeValid) {
|
||||||
|
throw HttpStatusCodeException.badRequest("VDE02", "channelCode");
|
||||||
|
}
|
||||||
|
|
||||||
return Instruction.builder()
|
return Instruction.builder()
|
||||||
.instructionIdentifier(
|
.instructionIdentifier(
|
||||||
InstructionIdentification.builder()
|
InstructionIdentification.builder()
|
||||||
@ -32,7 +45,8 @@ public class Instruction {
|
|||||||
.identificationType(InstructionIdentificationType.INSTRUCTION_NUMBER)
|
.identificationType(InstructionIdentificationType.INSTRUCTION_NUMBER)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.instructionPurposeType(channelCode)
|
.instructionPurposeType(InstructionPurposeType.valueOf(channelCode))
|
||||||
|
.instructionDescription(signatureIdentifier)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.banesco.module.instruction.domain.model;
|
||||||
|
|
||||||
|
public enum InstructionPurposeType {
|
||||||
|
BOLE,
|
||||||
|
BOL,
|
||||||
|
}
|
||||||
@ -35,4 +35,8 @@ public class PaymentStatus {
|
|||||||
private String uuidPasskey;
|
private String uuidPasskey;
|
||||||
private String dateCreate;
|
private String dateCreate;
|
||||||
private String dateModify;
|
private String dateModify;
|
||||||
|
|
||||||
|
private Long codError;
|
||||||
|
private String mensajeError;
|
||||||
|
private String constraintName;
|
||||||
}
|
}
|
||||||
@ -38,8 +38,7 @@ public class PaymentStatusClient implements PaymentStatusUseCase {
|
|||||||
PaymentStatusRequest params,
|
PaymentStatusRequest params,
|
||||||
Class<T> responseType
|
Class<T> responseType
|
||||||
) {
|
) {
|
||||||
String fintechId = params.getFintechId();
|
String signatureIdentifier = serializationHelper.encodeBase64(params);
|
||||||
String signatureIdentifier = getSignatureIdentifier(params);
|
|
||||||
HttpRequest request = HttpRequest.forApiPrivateResponse(
|
HttpRequest request = HttpRequest.forApiPrivateResponse(
|
||||||
paymentStatusConfig.getUrl(),
|
paymentStatusConfig.getUrl(),
|
||||||
paymentStatusConfig.getStatusSuccess(),
|
paymentStatusConfig.getStatusSuccess(),
|
||||||
@ -47,12 +46,14 @@ public class PaymentStatusClient implements PaymentStatusUseCase {
|
|||||||
responseType
|
responseType
|
||||||
)
|
)
|
||||||
.withPathParams(Map.of("signatureIdentifier", signatureIdentifier))
|
.withPathParams(Map.of("signatureIdentifier", signatureIdentifier))
|
||||||
.withHeaders(Map.of("fintechId", fintechId))
|
.withHeaders(Map.of("fintechId", params.getFintechId()))
|
||||||
.withTimeout(
|
.withTimeout(
|
||||||
paymentStatusConfig.getTimeout().getConnect(),
|
paymentStatusConfig.getTimeout().getConnect(),
|
||||||
paymentStatusConfig.getTimeout().getResponse()
|
paymentStatusConfig.getTimeout().getResponse()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
log.debug("Request configurado: {}", request);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ApiPrivateResponse<Either<T, ApiPrivateError>> response =
|
ApiPrivateResponse<Either<T, ApiPrivateError>> response =
|
||||||
httpClientUseCase.executeApiPrivateResponse(request);
|
httpClientUseCase.executeApiPrivateResponse(request);
|
||||||
@ -62,7 +63,7 @@ public class PaymentStatusClient implements PaymentStatusUseCase {
|
|||||||
log.error(
|
log.error(
|
||||||
"API retorno exitoso pero con detalle vacio. Codigo: {}, Mensaje: {}",
|
"API retorno exitoso pero con detalle vacio. Codigo: {}, Mensaje: {}",
|
||||||
response.getEstatus(),
|
response.getEstatus(),
|
||||||
response.getMensaje()
|
response.getMensaje()
|
||||||
);
|
);
|
||||||
|
|
||||||
throw ApiPrivateException.builder()
|
throw ApiPrivateException.builder()
|
||||||
@ -88,8 +89,8 @@ public class PaymentStatusClient implements PaymentStatusUseCase {
|
|||||||
throw ApiPrivateException.builder()
|
throw ApiPrivateException.builder()
|
||||||
.statusCode(response.getEstatus())
|
.statusCode(response.getEstatus())
|
||||||
.message((error.getCodError() != null)
|
.message((error.getCodError() != null)
|
||||||
? error.getCodError() + ":" + error.getMensajeError()
|
? error.getCodError() + ":" + error.getMensajeError()
|
||||||
: "EMPTY_MESSAGE"
|
: "EMPTY_MESSAGE"
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
} catch (ApiPrivateException e) {
|
} catch (ApiPrivateException e) {
|
||||||
@ -107,23 +108,4 @@ public class PaymentStatusClient implements PaymentStatusUseCase {
|
|||||||
throw HttpStatusCodeException.serviceUnavailable("503");
|
throw HttpStatusCodeException.serviceUnavailable("503");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSignatureIdentifier(PaymentStatusRequest params) {
|
|
||||||
Map<String, Object> paymentStatusRequest = serializationHelper.toMap(params);
|
|
||||||
String signature = serializationHelper.generateSignature(
|
|
||||||
params.getId(), params.getChannelOrigin()
|
|
||||||
);
|
|
||||||
|
|
||||||
paymentStatusRequest.put("signature", signature);
|
|
||||||
|
|
||||||
paymentStatusRequest.remove("fintechId");
|
|
||||||
|
|
||||||
String signatureIdentifier = serializationHelper.encodeBase64(paymentStatusRequest);
|
|
||||||
|
|
||||||
log.info("3. Firma generada: {}", signature);
|
|
||||||
log.info("4. Parametros de la solicitud: {}", paymentStatusRequest);
|
|
||||||
log.info("5. Solicitud final: {} -> {}", paymentStatusRequest, signatureIdentifier);
|
|
||||||
|
|
||||||
return signatureIdentifier;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -9,7 +9,6 @@ import com.banesco.module.service_issue_payment_status.domain.dto.request.Servic
|
|||||||
import com.banesco.module.service_issue_payment_status.domain.dto.response.ServiceIssuePaymentStatusResponse;
|
import com.banesco.module.service_issue_payment_status.domain.dto.response.ServiceIssuePaymentStatusResponse;
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -29,32 +28,27 @@ public class ServiceIssuePaymentStatusService implements ServiceIssuePaymentStat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response execute(
|
public ApiResponse<ServiceIssuePaymentStatusResponse> execute(
|
||||||
ServiceIssuePaymentStatusRequest request
|
ServiceIssuePaymentStatusRequest request
|
||||||
) {
|
) {
|
||||||
log.info("Iniciando ejecucion para el id: {}", request.getId());
|
log.info("Iniciando ejecucion para el id: {}", request.getId());
|
||||||
|
|
||||||
Response response;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ApiResponse<ServiceIssuePaymentStatusResponse> apiResponse = apiPrivate(request);
|
return apiPrivate(request);
|
||||||
|
|
||||||
response = messageHelper.handleSuccess(
|
|
||||||
apiResponse.getData(),
|
|
||||||
apiResponse.getStatusResponse().getStatusCode()
|
|
||||||
);
|
|
||||||
} catch (ApiPrivateException e) {
|
} catch (ApiPrivateException e) {
|
||||||
log.warn("Excepcion de la api privada: {} -> {}", e.getStatusCode(), e.getMessage());
|
log.warn(
|
||||||
response = messageHelper.handleException(HttpStatusCodeException.badRequest("400"));
|
"Excepcion de la api privada: {} -> {}",
|
||||||
|
e.getStatusCode(),
|
||||||
|
e.getMessage()
|
||||||
|
);
|
||||||
|
throw HttpStatusCodeException.badRequest("400");
|
||||||
} catch (HttpStatusCodeException e) {
|
} catch (HttpStatusCodeException e) {
|
||||||
log.error("Excepcion HTTP del api privada: {} - {}", e.getStatusCode(), e.getErrorCode());
|
log.error("Excepcion HTTP del api privada: {} - {}", e.getStatusCode(), e.getErrorCode());
|
||||||
response = messageHelper.handleException(e);
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Excepcion generica del api privada: {}", e.getMessage());
|
log.error("Excepcion generica del api privada: {}", e.getMessage());
|
||||||
response = messageHelper.handleGenericException(e);
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiResponse<ServiceIssuePaymentStatusResponse> apiPrivate(
|
private ApiResponse<ServiceIssuePaymentStatusResponse> apiPrivate(
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
package com.banesco.module.service_issue_payment_status.application.usecase;
|
package com.banesco.module.service_issue_payment_status.application.usecase;
|
||||||
|
|
||||||
|
import com.banesco.common.domain.model.ApiResponse;
|
||||||
import com.banesco.module.service_issue_payment_status.domain.dto.request.ServiceIssuePaymentStatusRequest;
|
import com.banesco.module.service_issue_payment_status.domain.dto.request.ServiceIssuePaymentStatusRequest;
|
||||||
import jakarta.ws.rs.core.Response;
|
import com.banesco.module.service_issue_payment_status.domain.dto.response.ServiceIssuePaymentStatusResponse;
|
||||||
|
|
||||||
public interface ServiceIssuePaymentStatusUseCase {
|
public interface ServiceIssuePaymentStatusUseCase {
|
||||||
Response execute(
|
ApiResponse<ServiceIssuePaymentStatusResponse> execute(
|
||||||
ServiceIssuePaymentStatusRequest request
|
ServiceIssuePaymentStatusRequest request
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,9 @@
|
|||||||
package com.banesco.module.service_issue_payment_status.domain.dto.request;
|
package com.banesco.module.service_issue_payment_status.domain.dto.request;
|
||||||
|
|
||||||
import com.banesco.common.domain.model.Device;
|
|
||||||
import com.banesco.common.infrastructure.context.RequestContext;
|
|
||||||
import com.banesco.module.instruction.domain.model.Instruction;
|
import com.banesco.module.instruction.domain.model.Instruction;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import io.netty.util.internal.StringUtil;
|
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static java.util.Map.entry;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@Builder
|
@Builder
|
||||||
@ -26,43 +17,8 @@ public class ServiceIssuePaymentStatusRequest {
|
|||||||
private String appId;
|
private String appId;
|
||||||
@NonNull
|
@NonNull
|
||||||
private Instruction procedureRequest;
|
private Instruction procedureRequest;
|
||||||
@NonNull
|
|
||||||
private Device device;
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return procedureRequest
|
return getProcedureRequest().getInstructionIdentifier().getIdentification().getIdentifierValue();
|
||||||
.getInstructionIdentifier()
|
|
||||||
.getIdentification()
|
|
||||||
.getIdentifierValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public String getChannelCode() {
|
|
||||||
return procedureRequest
|
|
||||||
.getInstructionPurposeType();
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public Map<String, String> toParams() {
|
|
||||||
return Map.ofEntries(
|
|
||||||
entry("paymentStatusId", Objects.toString(getId(), "")),
|
|
||||||
entry("channelCode", Objects.toString(getChannelCode(), ""))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public Map<String, String> toQueryString() {
|
|
||||||
return Map.ofEntries(
|
|
||||||
entry("appId", Objects.toString(getAppId(), "")),
|
|
||||||
entry("customerReferenceFintechId", Objects.toString(getCustomerReferenceFintechId(), "")),
|
|
||||||
entry("deviceType", Objects.toString(getDevice().getDeviceType(), "")),
|
|
||||||
entry("deviceDescription", Objects.toString(getDevice().getDeviceDescription(), "")),
|
|
||||||
entry("deviceIp", Objects.toString(getDevice().getDeviceIp(), "")),
|
|
||||||
entry("deviceSessionReference", (!StringUtil.isNullOrEmpty(getDevice().getDeviceSessionReference()))
|
|
||||||
? getDevice().getDeviceSessionReference()
|
|
||||||
: RequestContext.getRequestId()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,7 +23,8 @@ public class ServicingIssueMapper {
|
|||||||
return PaymentStatusRequest.builder()
|
return PaymentStatusRequest.builder()
|
||||||
.fintechId(request.getCustomerReferenceFintechId())
|
.fintechId(request.getCustomerReferenceFintechId())
|
||||||
.id(Long.valueOf(request.getId()))
|
.id(Long.valueOf(request.getId()))
|
||||||
.channelOrigin(request.getChannelCode())
|
.channelOrigin(request.getProcedureRequest().getInstructionPurposeType().name())
|
||||||
|
.signature(request.getProcedureRequest().getInstructionDescription())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,25 +160,19 @@ public class ServicingIssueMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return switch (codeStatusRequest.toUpperCase()) {
|
return switch (codeStatusRequest.toUpperCase()) {
|
||||||
case "ACT", "ACTIVO", "ACTIVA" -> TransactionStatusType.ACTIVE;
|
|
||||||
case "PENDIENTE" -> TransactionStatusType.PENDING;
|
case "PENDIENTE" -> TransactionStatusType.PENDING;
|
||||||
case "EXITO", "EXITOSA", "COMPLETADO", "FINALIZADO" -> TransactionStatusType.COMPLETED;
|
case "EXITO", "EXITOSA", "COMPLETADO", "FINALIZADO" -> TransactionStatusType.COMPLETED;
|
||||||
case "APROBADO", "APROBADA" -> TransactionStatusType.APPROVED;
|
case "APROBADO", "CONFIRMADO" -> TransactionStatusType.CONFIRMED;
|
||||||
case "CONF", "CONFIRMADO", "CONFIRMADA" -> TransactionStatusType.CONFIRMED;
|
|
||||||
case "INICIADO" -> TransactionStatusType.INITIATED;
|
case "INICIADO" -> TransactionStatusType.INITIATED;
|
||||||
case "EN_PROCESO", "PROCESANDO", "EN CURSO" -> TransactionStatusType.IN_PROGRESS;
|
case "EN_PROCESO", "PROCESANDO", "EN CURSO" -> TransactionStatusType.IN_PROGRESS;
|
||||||
case "RECH", "RECHAZADO", "FALLA", "FALLIDO", "RECHAZADA", "FALLIDA" -> TransactionStatusType.REJECTED;
|
case "RECHAZADO", "FALLIDO" -> TransactionStatusType.REJECTED;
|
||||||
case "CANCELADO" -> TransactionStatusType.CANCELLED;
|
case "CANCELADO" -> TransactionStatusType.CANCELLED;
|
||||||
case "SUSPENDIDO" -> TransactionStatusType.SUSPENDED;
|
case "SUSPENDIDO" -> TransactionStatusType.SUSPENDED;
|
||||||
case "NOTIFICADO" -> TransactionStatusType.NOTIFIED;
|
case "NOTIFICADO" -> TransactionStatusType.NOTIFIED;
|
||||||
case "CONTABILIZADO" -> TransactionStatusType.BOOKED;
|
case "CONTABILIZADO" -> TransactionStatusType.BOOKED;
|
||||||
case "EJECUTADO" -> TransactionStatusType.EXECUTED;
|
case "EJECUTADO" -> TransactionStatusType.EXECUTED;
|
||||||
case "EXP", "EXPIRADO", "EXPIRADA" -> TransactionStatusType.EXPIRED;
|
case "EXP" -> TransactionStatusType.EXPIRED;
|
||||||
case "ENVIADO", "ENVIADA" -> TransactionStatusType.SENT;
|
case "ENVIADO" -> TransactionStatusType.SENT;
|
||||||
case "RECIBIDO", "RECIBIDA" -> TransactionStatusType.RECEIVED;
|
|
||||||
case "LEIDA" -> TransactionStatusType.READ;
|
|
||||||
case "PROG", "PROGRAMADO", "PROGRAMADA" -> TransactionStatusType.PROGRAMED;
|
|
||||||
case "TRANSATIP" -> TransactionStatusType.ATYPICAL_TRANSACTION;
|
|
||||||
default -> TransactionStatusType.DEFAULT;
|
default -> TransactionStatusType.DEFAULT;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
package com.banesco.module.service_issue_payment_status.infrastructure.resource;
|
package com.banesco.module.service_issue_payment_status.infrastructure.resource;
|
||||||
|
|
||||||
|
import com.banesco.common.application.helper.MessageHelper;
|
||||||
|
import com.banesco.common.domain.exception.HttpStatusCodeException;
|
||||||
import com.banesco.common.domain.model.ApiResponse;
|
import com.banesco.common.domain.model.ApiResponse;
|
||||||
import com.banesco.common.domain.model.Device;
|
|
||||||
import com.banesco.common.domain.model.StatusResponse;
|
import com.banesco.common.domain.model.StatusResponse;
|
||||||
import com.banesco.module.instruction.domain.model.Instruction;
|
import com.banesco.module.instruction.domain.model.Instruction;
|
||||||
import com.banesco.module.service_issue_payment_status.application.usecase.ServiceIssuePaymentStatusUseCase;
|
import com.banesco.module.service_issue_payment_status.application.usecase.ServiceIssuePaymentStatusUseCase;
|
||||||
@ -30,16 +31,19 @@ import java.util.Objects;
|
|||||||
public class ServiceIssuePaymentStatusResource {
|
public class ServiceIssuePaymentStatusResource {
|
||||||
|
|
||||||
private final ServiceIssuePaymentStatusUseCase useCase;
|
private final ServiceIssuePaymentStatusUseCase useCase;
|
||||||
|
private final MessageHelper messageHelper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ServiceIssuePaymentStatusResource(
|
public ServiceIssuePaymentStatusResource(
|
||||||
|
MessageHelper messageHelper,
|
||||||
ServiceIssuePaymentStatusUseCase useCase
|
ServiceIssuePaymentStatusUseCase useCase
|
||||||
) {
|
) {
|
||||||
|
this.messageHelper = messageHelper;
|
||||||
this.useCase = useCase;
|
this.useCase = useCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/retrieve/{paymentStatusId}/{channelCode}")
|
@Path("/retrieve/{paymentStatusId}/{channelCode}/{signatureIdentifier}")
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Recuperar informacion de la transaccion",
|
summary = "Recuperar informacion de la transaccion",
|
||||||
description = "Consulta de una trasanccion de pago por id de archivo"
|
description = "Consulta de una trasanccion de pago por id de archivo"
|
||||||
@ -308,48 +312,34 @@ public class ServiceIssuePaymentStatusResource {
|
|||||||
@Parameter(description = "Codigo del canal (BOL, BOLE)", required = true, example = "BOLE")
|
@Parameter(description = "Codigo del canal (BOL, BOLE)", required = true, example = "BOLE")
|
||||||
String channelCode,
|
String channelCode,
|
||||||
|
|
||||||
|
@PathParam("signatureIdentifier")
|
||||||
|
@Parameter(description = "Firma del archivo", required = true, example = "add7c6375b8659a798a998258fb049b98119ea97d8116b95e1ee00cc9ffafa84")
|
||||||
|
String signatureIdentifier,
|
||||||
|
|
||||||
@QueryParam("customerReferenceFintechId")
|
@QueryParam("customerReferenceFintechId")
|
||||||
@Parameter(description = "ID de la fintech", example = "pranical-test")
|
@Parameter(description = "ID de la fintech", example = "pranical-test")
|
||||||
String customerReferenceFintechId,
|
String customerReferenceFintechId,
|
||||||
|
|
||||||
@QueryParam("appId")
|
@QueryParam("appId")
|
||||||
@Parameter(description = "ID de la aplicacion", example = "DANIAPP")
|
@Parameter(description = "ID de la aplicacion", example = "DANIAPP")
|
||||||
String appId,
|
String appId
|
||||||
|
|
||||||
@QueryParam("deviceType")
|
|
||||||
@Parameter(description = "Tipo de dispositivo", example = "Mobile")
|
|
||||||
String deviceType,
|
|
||||||
|
|
||||||
@QueryParam("deviceDescription")
|
|
||||||
@Parameter(description = "Descripcion del dispositivo", example = "Xiaomi Note 11 PRO")
|
|
||||||
String deviceDescription,
|
|
||||||
|
|
||||||
@QueryParam("deviceIp")
|
|
||||||
@Parameter(description = "Direccion IP del dispositivo", example = "127.0.0.1")
|
|
||||||
String deviceIp,
|
|
||||||
|
|
||||||
@QueryParam("deviceSessionReference")
|
|
||||||
@Parameter(description = "Referencia de la peticion del dispositivo", example = "12345678901304")
|
|
||||||
String deviceSessionReference
|
|
||||||
) {
|
) {
|
||||||
log.info("Iniciando consulta para instruccion de archivo id: {}", paymentStatusId);
|
log.info("Iniciando consulta para instruccion de archivo id: {}", paymentStatusId);
|
||||||
|
|
||||||
return useCase.execute(
|
try {
|
||||||
ServiceIssuePaymentStatusRequest.builder()
|
return Response.ok(useCase.execute(
|
||||||
.customerReferenceFintechId(Objects.toString(customerReferenceFintechId, ""))
|
ServiceIssuePaymentStatusRequest.builder()
|
||||||
.appId(Objects.toString(appId, ""))
|
.customerReferenceFintechId(Objects.toString(customerReferenceFintechId, ""))
|
||||||
.procedureRequest(Instruction.fromResource(
|
.appId(Objects.toString(appId, ""))
|
||||||
paymentStatusId, channelCode
|
.procedureRequest(Instruction.fromResource(
|
||||||
))
|
paymentStatusId, channelCode, signatureIdentifier
|
||||||
.device(
|
))
|
||||||
Device.builder()
|
.build()
|
||||||
.deviceType(deviceType)
|
)).build();
|
||||||
.deviceDescription(deviceDescription)
|
} catch (HttpStatusCodeException e) {
|
||||||
.deviceIp(deviceIp)
|
return messageHelper.handleException(e);
|
||||||
.deviceSessionReference(deviceSessionReference)
|
} catch (Exception e) {
|
||||||
.build()
|
return messageHelper.handleGenericException(e);
|
||||||
)
|
}
|
||||||
.build()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,7 +7,6 @@ public enum TransactionStatusType {
|
|||||||
EXECUTED,
|
EXECUTED,
|
||||||
CANCELLED,
|
CANCELLED,
|
||||||
CONFIRMED,
|
CONFIRMED,
|
||||||
APPROVED,
|
|
||||||
SUSPENDED,
|
SUSPENDED,
|
||||||
PENDING,
|
PENDING,
|
||||||
COMPLETED,
|
COMPLETED,
|
||||||
@ -16,9 +15,4 @@ public enum TransactionStatusType {
|
|||||||
REJECTED,
|
REJECTED,
|
||||||
EXPIRED,
|
EXPIRED,
|
||||||
SENT,
|
SENT,
|
||||||
RECEIVED,
|
|
||||||
ACTIVE,
|
|
||||||
READ,
|
|
||||||
PROGRAMED,
|
|
||||||
ATYPICAL_TRANSACTION,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,6 @@ api:
|
|||||||
dom-service-issue-payment-status:
|
dom-service-issue-payment-status:
|
||||||
messages:
|
messages:
|
||||||
key: 'dom-service-issue-payment-status'
|
key: 'dom-service-issue-payment-status'
|
||||||
content: '[{"backendCode":"200","httpCode":200,"statusCode":"200","description":"Operacion exitosa"},{"backendCode":"R404","httpCode":404,"statusCode":"404","description":"Datos de validacion no encontrado."},{"backendCode":"503","httpCode":503,"statusCode":"503","description":"Uso interno"},{"backendCode":"422","httpCode":422,"statusCode":"422","description":"Uso interno"},{"backendCode":"500","httpCode":500,"statusCode":"500","description":"Uso interno"},{"backendCode":"100","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-382505","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-380002","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"ERROR","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"400","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"401","httpCode":401,"statusCode":"401","description":"Uso interno"},{"backendCode":"403","httpCode":403,"statusCode":"403","description":"Uso interno"},{"backendCode":"404","httpCode":404,"statusCode":"404","description":"Uso interno"},{"backendCode":"default","httpCode":409,"statusCode":"409","description":"Conflicto"},{"backendCode":"424","httpCode":424,"statusCode":"424","description":"Error de dependencia"},{"backendCode":"VDE01","httpCode":400,"statusCode":"VDE01","description":"VDE01 - Error en dato de entrada obligatorio: %s"},{"backendCode":"VDE02","httpCode":400,"statusCode":"VDE02","description":"VDE02 - Error en valor permitido para campo: %s"},{"backendCode":"VRN02","httpCode":"204","statusCode":"VRN02","description":"Cliente sin productos"}]'
|
content: '[{"backendCode":"200","httpCode":200,"statusCode":"200","description":"Operacion exitosa"},{"backendCode":"R404","httpCode":404,"statusCode":"404","description":"Datos de validacion no encontrado."},{"backendCode":"503","httpCode":503,"statusCode":"503","description":"Uso interno"},{"backendCode":"422","httpCode":422,"statusCode":"422","description":"Uso interno"},{"backendCode":"500","httpCode":500,"statusCode":"500","description":"Uso interno"},{"backendCode":"100","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-382505","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-380002","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"ERROR","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"400","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"401","httpCode":401,"statusCode":"401","description":"Uso interno"},{"backendCode":"403","httpCode":403,"statusCode":"403","description":"Uso interno"},{"backendCode":"404","httpCode":404,"statusCode":"404","description":"Uso interno"},{"backendCode":"default","httpCode":409,"statusCode":"409","description":"Conflicto"},{"backendCode":"424","httpCode":424,"statusCode":"424","description":"Error de dependencia"},{"backendCode":"VDE01","httpCode":400,"statusCode":"VDE01","description":"VDE01 - Error en dato de entrada obligatorio: %s"},{"backendCode":"VDE02","httpCode":400,"statusCode":"VDE02","description":"VDE02 - Error en valor permitido para campo: %s"},{"backend_code":"204","http_code":"200","status_code":"200","description":"Cliente sin productos","status":"ok"}]'
|
||||||
rest-client:
|
rest-client:
|
||||||
payment-status-by-id: '{"url":"http://10.135.193.156:8080/RequestPayment/notificationRequestPayment/v1/querys/getRequestPayStatusById/{signatureIdentifier}","timeout":{"connect":10000,"response":10000},"statusSuccess":"00"}'
|
payment-status-by-id: '{"url":"http://10.135.193.156:8080/RequestPayment/notificationRequestPayment/v1/querys/getRequestPayStatusById/{signatureIdentifier}","timeout":{"connect":10000,"response":10000},"statusSuccess":"00"}'
|
||||||
Loading…
x
Reference in New Issue
Block a user