update error messages into private api; update generals
This commit is contained in:
parent
e335c3095a
commit
5c211aa0cf
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
|||||||
<artifactId>bus-payment-instruction-request</artifactId>
|
<artifactId>bus-payment-instruction-request</artifactId>
|
||||||
<version>1.0-native-quarkus-jdk17</version>
|
<version>1.0-native-quarkus-jdk17</version>
|
||||||
<name>bus-payment-instruction-request</name>
|
<name>bus-payment-instruction-request</name>
|
||||||
<description>API Business - Create payment single request</description>
|
<description>API Business - Create payment multiple request</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.release>17</maven.compiler.release>
|
<maven.compiler.release>17</maven.compiler.release>
|
||||||
|
|||||||
Binary file not shown.
@ -28,10 +28,12 @@ public class PartyValidateHelper {
|
|||||||
!Objects.isNull(blackListRec) &&
|
!Objects.isNull(blackListRec) &&
|
||||||
!StringUtil.isNullOrEmpty(blackListRec.getBlackListBanesco()) &&
|
!StringUtil.isNullOrEmpty(blackListRec.getBlackListBanesco()) &&
|
||||||
!StringUtil.isNullOrEmpty(blackListRec.getBlackListCbn()) &&
|
!StringUtil.isNullOrEmpty(blackListRec.getBlackListCbn()) &&
|
||||||
blackListRec.getBlackListBanesco().equalsIgnoreCase("N") &&
|
(
|
||||||
blackListRec.getBlackListCbn().equalsIgnoreCase("N")
|
!blackListRec.getBlackListBanesco().equalsIgnoreCase("N") ||
|
||||||
|
!blackListRec.getBlackListCbn().equalsIgnoreCase("N")
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return;
|
throw HttpStatusCodeException.unauthorized("VRN13");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +48,17 @@ public class PartyValidateHelper {
|
|||||||
List<String> errors = extractErrorCodes(status);
|
List<String> errors = extractErrorCodes(status);
|
||||||
|
|
||||||
if(!errors.isEmpty()) {
|
if(!errors.isEmpty()) {
|
||||||
|
if(
|
||||||
|
errors.size() == 1 &&
|
||||||
|
(
|
||||||
|
Objects.equals(errors.get(0), "388") ||
|
||||||
|
errors.get(0).equalsIgnoreCase("AFPM388")
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
log.error("Error del estatus controlado: {}", errors.get(0));
|
||||||
|
throw HttpStatusCodeException.forbidden("VRN20");
|
||||||
|
}
|
||||||
|
|
||||||
AdditionalStatus additionalStatus = getFirstAdditionalStatus(status);
|
AdditionalStatus additionalStatus = getFirstAdditionalStatus(status);
|
||||||
String error = String.join("-", errors);
|
String error = String.join("-", errors);
|
||||||
String desc = (!Objects.isNull(additionalStatus))
|
String desc = (!Objects.isNull(additionalStatus))
|
||||||
@ -75,7 +88,6 @@ public class PartyValidateHelper {
|
|||||||
|
|
||||||
private static List<String> extractErrorCodes(Status status) {
|
private static List<String> extractErrorCodes(Status status) {
|
||||||
List<String> errors = new ArrayList<>();
|
List<String> errors = new ArrayList<>();
|
||||||
|
|
||||||
List<AdditionalStatus> additionalStatuses = status.getAdditionalStatus();
|
List<AdditionalStatus> additionalStatuses = status.getAdditionalStatus();
|
||||||
|
|
||||||
if(Objects.isNull(additionalStatuses) || additionalStatuses.isEmpty()) {
|
if(Objects.isNull(additionalStatuses) || additionalStatuses.isEmpty()) {
|
||||||
|
|||||||
@ -58,117 +58,117 @@ public class HttpRequest {
|
|||||||
private boolean logResponseBody = true;
|
private boolean logResponseBody = true;
|
||||||
|
|
||||||
public static <T> HttpRequest forApiResponse(
|
public static <T> HttpRequest forApiResponse(
|
||||||
String url,
|
String url,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> dataType
|
Class<T> dataType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(ApiResponse.class)
|
.responseType(ApiResponse.class)
|
||||||
.genericType(dataType)
|
.genericType(dataType)
|
||||||
.apiResponse(true)
|
.apiResponse(true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> HttpRequest forApiResponseList(
|
public static <T> HttpRequest forApiResponseList(
|
||||||
String url,
|
String url,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> elementType
|
Class<T> elementType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(ApiResponse.class)
|
.responseType(ApiResponse.class)
|
||||||
.complexType(TypeBuilder.listOf(elementType))
|
.complexType(TypeBuilder.listOf(elementType))
|
||||||
.apiResponse(true)
|
.apiResponse(true)
|
||||||
.listResponse(true)
|
.listResponse(true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> HttpRequest forApiPrivateResponse(
|
public static <T> HttpRequest forApiPrivateResponse(
|
||||||
String url,
|
String url,
|
||||||
String statusSuccess,
|
String statusSuccess,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> successType
|
Class<T> successType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(ApiPrivateResponse.class)
|
.responseType(ApiPrivateResponse.class)
|
||||||
.complexType(TypeBuilder.parametricType(
|
.complexType(TypeBuilder.parametricType(
|
||||||
Either.class,
|
Either.class,
|
||||||
successType,
|
successType,
|
||||||
ApiPrivateError.class
|
ApiPrivateError.class
|
||||||
))
|
))
|
||||||
.apiPrivateResponse(true)
|
.apiPrivateResponse(true)
|
||||||
.eitherResponse(true)
|
.eitherResponse(true)
|
||||||
.errorType(ApiPrivateError.class)
|
.errorType(ApiPrivateError.class)
|
||||||
.statusSuccess(statusSuccess)
|
.statusSuccess(statusSuccess)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> HttpRequest forApiPrivateResponseList(
|
public static <T> HttpRequest forApiPrivateResponseList(
|
||||||
String url,
|
String url,
|
||||||
String statusSuccess,
|
String statusSuccess,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> elementType
|
Class<T> elementType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(ApiPrivateResponse.class)
|
.responseType(ApiPrivateResponse.class)
|
||||||
.complexType(TypeBuilder.parametricType(
|
.complexType(TypeBuilder.parametricType(
|
||||||
Either.class,
|
Either.class,
|
||||||
TypeBuilder.listOf(elementType),
|
TypeBuilder.listOf(elementType),
|
||||||
ApiPrivateError.class
|
ApiPrivateError.class
|
||||||
))
|
))
|
||||||
.apiPrivateResponse(true)
|
.apiPrivateResponse(true)
|
||||||
.eitherResponse(true)
|
.eitherResponse(true)
|
||||||
.listResponse(true)
|
.listResponse(true)
|
||||||
.errorType(ApiPrivateError.class)
|
.errorType(ApiPrivateError.class)
|
||||||
.statusSuccess(statusSuccess)
|
.statusSuccess(statusSuccess)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> HttpRequest forDirectResponse(
|
public static <T> HttpRequest forDirectResponse(
|
||||||
String url,
|
String url,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> responseType
|
Class<T> responseType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(responseType)
|
.responseType(responseType)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, R> HttpRequest forDirectResponse(
|
public static <T, R> HttpRequest forDirectResponse(
|
||||||
String url,
|
String url,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> responseType,
|
Class<T> responseType,
|
||||||
Class<R> errorType
|
Class<R> errorType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(responseType)
|
.responseType(responseType)
|
||||||
.errorType(errorType)
|
.errorType(errorType)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, U> HttpRequest forGenericResponse(
|
public static <T, U> HttpRequest forGenericResponse(
|
||||||
String url,
|
String url,
|
||||||
HttpMethod method,
|
HttpMethod method,
|
||||||
Class<T> rawType,
|
Class<T> rawType,
|
||||||
Class<U> genericType
|
Class<U> genericType
|
||||||
) {
|
) {
|
||||||
return HttpRequest.builder()
|
return HttpRequest.builder()
|
||||||
.url(url)
|
.url(url)
|
||||||
.method(method)
|
.method(method)
|
||||||
.responseType(rawType)
|
.responseType(rawType)
|
||||||
.complexType(TypeBuilder.parametricType(rawType, genericType))
|
.complexType(TypeBuilder.parametricType(rawType, genericType))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpRequest withHeaders(Map<String, String> headers) {
|
public HttpRequest withHeaders(Map<String, String> headers) {
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
@RegisterForReflection
|
@RegisterForReflection
|
||||||
@ -13,4 +15,5 @@ public class SecurityTraceConfig {
|
|||||||
private String url;
|
private String url;
|
||||||
private TimeoutConfig timeout;
|
private TimeoutConfig timeout;
|
||||||
private SecurityTraceRequest request;
|
private SecurityTraceRequest request;
|
||||||
|
private Map<String, String> converters;
|
||||||
}
|
}
|
||||||
@ -29,6 +29,8 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
|||||||
private final RestClientConfig restClientConfig;
|
private final RestClientConfig restClientConfig;
|
||||||
private final SecurityTraceConfig securityTraceConfig;
|
private final SecurityTraceConfig securityTraceConfig;
|
||||||
|
|
||||||
|
private static final String PAYMENT_INSTRUCTION_TRANSACTION_KEY = "paymentInstructionTransaction";
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SecurityTraceClient(
|
public SecurityTraceClient(
|
||||||
HttpClientUseCase httpClientUseCase,
|
HttpClientUseCase httpClientUseCase,
|
||||||
@ -148,7 +150,7 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
|||||||
|
|
||||||
Map<String, Object> apiRequestMap = restClientConfig.toMap(apiRequest);
|
Map<String, Object> apiRequestMap = restClientConfig.toMap(apiRequest);
|
||||||
Map<String, Object> paymentInstructionTransaction =
|
Map<String, Object> paymentInstructionTransaction =
|
||||||
(Map<String, Object>) apiRequestMap.get("paymentInstructionTransaction");
|
(Map<String, Object>) apiRequestMap.get(PAYMENT_INSTRUCTION_TRANSACTION_KEY);
|
||||||
|
|
||||||
if(Objects.isNull(paymentInstructionTransaction)) {
|
if(Objects.isNull(paymentInstructionTransaction)) {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
@ -159,7 +161,7 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
|||||||
apiRequest.getPaymentInstructionTransaction().getPaymentArrangement().size()
|
apiRequest.getPaymentInstructionTransaction().getPaymentArrangement().size()
|
||||||
);
|
);
|
||||||
|
|
||||||
apiRequestMap.put("paymentInstructionTransaction", paymentInstructionTransaction);
|
apiRequestMap.put(PAYMENT_INSTRUCTION_TRANSACTION_KEY, paymentInstructionTransaction);
|
||||||
|
|
||||||
return apiRequestMap;
|
return apiRequestMap;
|
||||||
}
|
}
|
||||||
@ -180,7 +182,7 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> paymentInstructionTransaction =
|
Map<String, Object> paymentInstructionTransaction =
|
||||||
(Map<String, Object>) data.get("paymentInstructionTransaction");
|
(Map<String, Object>) data.get(PAYMENT_INSTRUCTION_TRANSACTION_KEY);
|
||||||
|
|
||||||
if(Objects.isNull(paymentInstructionTransaction)) {
|
if(Objects.isNull(paymentInstructionTransaction)) {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
@ -191,7 +193,7 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
|||||||
apiResponseData.getData().getPaymentInstructionTransaction().getPaymentArrangement().size()
|
apiResponseData.getData().getPaymentInstructionTransaction().getPaymentArrangement().size()
|
||||||
);
|
);
|
||||||
|
|
||||||
data.put("paymentInstructionTransaction", paymentInstructionTransaction);
|
data.put(PAYMENT_INSTRUCTION_TRANSACTION_KEY, paymentInstructionTransaction);
|
||||||
|
|
||||||
apiResponseMap.put("data", data);
|
apiResponseMap.put("data", data);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user