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>
|
||||
<version>1.0-native-quarkus-jdk17</version>
|
||||
<name>bus-payment-instruction-request</name>
|
||||
<description>API Business - Create payment single request</description>
|
||||
<description>API Business - Create payment multiple request</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.release>17</maven.compiler.release>
|
||||
|
||||
Binary file not shown.
@ -28,10 +28,12 @@ public class PartyValidateHelper {
|
||||
!Objects.isNull(blackListRec) &&
|
||||
!StringUtil.isNullOrEmpty(blackListRec.getBlackListBanesco()) &&
|
||||
!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);
|
||||
|
||||
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);
|
||||
String error = String.join("-", errors);
|
||||
String desc = (!Objects.isNull(additionalStatus))
|
||||
@ -75,7 +88,6 @@ public class PartyValidateHelper {
|
||||
|
||||
private static List<String> extractErrorCodes(Status status) {
|
||||
List<String> errors = new ArrayList<>();
|
||||
|
||||
List<AdditionalStatus> additionalStatuses = status.getAdditionalStatus();
|
||||
|
||||
if(Objects.isNull(additionalStatuses) || additionalStatuses.isEmpty()) {
|
||||
|
||||
@ -58,117 +58,117 @@ public class HttpRequest {
|
||||
private boolean logResponseBody = true;
|
||||
|
||||
public static <T> HttpRequest forApiResponse(
|
||||
String url,
|
||||
HttpMethod method,
|
||||
Class<T> dataType
|
||||
String url,
|
||||
HttpMethod method,
|
||||
Class<T> dataType
|
||||
) {
|
||||
return HttpRequest.builder()
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(ApiResponse.class)
|
||||
.genericType(dataType)
|
||||
.apiResponse(true)
|
||||
.build();
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(ApiResponse.class)
|
||||
.genericType(dataType)
|
||||
.apiResponse(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static <T> HttpRequest forApiResponseList(
|
||||
String url,
|
||||
HttpMethod method,
|
||||
Class<T> elementType
|
||||
String url,
|
||||
HttpMethod method,
|
||||
Class<T> elementType
|
||||
) {
|
||||
return HttpRequest.builder()
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(ApiResponse.class)
|
||||
.complexType(TypeBuilder.listOf(elementType))
|
||||
.apiResponse(true)
|
||||
.listResponse(true)
|
||||
.build();
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(ApiResponse.class)
|
||||
.complexType(TypeBuilder.listOf(elementType))
|
||||
.apiResponse(true)
|
||||
.listResponse(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static <T> HttpRequest forApiPrivateResponse(
|
||||
String url,
|
||||
String statusSuccess,
|
||||
HttpMethod method,
|
||||
Class<T> successType
|
||||
String url,
|
||||
String statusSuccess,
|
||||
HttpMethod method,
|
||||
Class<T> successType
|
||||
) {
|
||||
return HttpRequest.builder()
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(ApiPrivateResponse.class)
|
||||
.complexType(TypeBuilder.parametricType(
|
||||
Either.class,
|
||||
successType,
|
||||
ApiPrivateError.class
|
||||
))
|
||||
.apiPrivateResponse(true)
|
||||
.eitherResponse(true)
|
||||
.errorType(ApiPrivateError.class)
|
||||
.statusSuccess(statusSuccess)
|
||||
.build();
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(ApiPrivateResponse.class)
|
||||
.complexType(TypeBuilder.parametricType(
|
||||
Either.class,
|
||||
successType,
|
||||
ApiPrivateError.class
|
||||
))
|
||||
.apiPrivateResponse(true)
|
||||
.eitherResponse(true)
|
||||
.errorType(ApiPrivateError.class)
|
||||
.statusSuccess(statusSuccess)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static <T> HttpRequest forApiPrivateResponseList(
|
||||
String url,
|
||||
String statusSuccess,
|
||||
HttpMethod method,
|
||||
Class<T> elementType
|
||||
String url,
|
||||
String statusSuccess,
|
||||
HttpMethod method,
|
||||
Class<T> elementType
|
||||
) {
|
||||
return HttpRequest.builder()
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(ApiPrivateResponse.class)
|
||||
.complexType(TypeBuilder.parametricType(
|
||||
Either.class,
|
||||
TypeBuilder.listOf(elementType),
|
||||
ApiPrivateError.class
|
||||
))
|
||||
.apiPrivateResponse(true)
|
||||
.eitherResponse(true)
|
||||
.listResponse(true)
|
||||
.errorType(ApiPrivateError.class)
|
||||
.statusSuccess(statusSuccess)
|
||||
.build();
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(ApiPrivateResponse.class)
|
||||
.complexType(TypeBuilder.parametricType(
|
||||
Either.class,
|
||||
TypeBuilder.listOf(elementType),
|
||||
ApiPrivateError.class
|
||||
))
|
||||
.apiPrivateResponse(true)
|
||||
.eitherResponse(true)
|
||||
.listResponse(true)
|
||||
.errorType(ApiPrivateError.class)
|
||||
.statusSuccess(statusSuccess)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static <T> HttpRequest forDirectResponse(
|
||||
String url,
|
||||
HttpMethod method,
|
||||
Class<T> responseType
|
||||
String url,
|
||||
HttpMethod method,
|
||||
Class<T> responseType
|
||||
) {
|
||||
return HttpRequest.builder()
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(responseType)
|
||||
.build();
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(responseType)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static <T, R> HttpRequest forDirectResponse(
|
||||
String url,
|
||||
HttpMethod method,
|
||||
Class<T> responseType,
|
||||
Class<R> errorType
|
||||
String url,
|
||||
HttpMethod method,
|
||||
Class<T> responseType,
|
||||
Class<R> errorType
|
||||
) {
|
||||
return HttpRequest.builder()
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(responseType)
|
||||
.errorType(errorType)
|
||||
.build();
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(responseType)
|
||||
.errorType(errorType)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static <T, U> HttpRequest forGenericResponse(
|
||||
String url,
|
||||
HttpMethod method,
|
||||
Class<T> rawType,
|
||||
Class<U> genericType
|
||||
String url,
|
||||
HttpMethod method,
|
||||
Class<T> rawType,
|
||||
Class<U> genericType
|
||||
) {
|
||||
return HttpRequest.builder()
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(rawType)
|
||||
.complexType(TypeBuilder.parametricType(rawType, genericType))
|
||||
.build();
|
||||
.url(url)
|
||||
.method(method)
|
||||
.responseType(rawType)
|
||||
.complexType(TypeBuilder.parametricType(rawType, genericType))
|
||||
.build();
|
||||
}
|
||||
|
||||
public HttpRequest withHeaders(Map<String, String> headers) {
|
||||
|
||||
@ -6,6 +6,8 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
@RegisterForReflection
|
||||
@ -13,4 +15,5 @@ public class SecurityTraceConfig {
|
||||
private String url;
|
||||
private TimeoutConfig timeout;
|
||||
private SecurityTraceRequest request;
|
||||
private Map<String, String> converters;
|
||||
}
|
||||
@ -29,6 +29,8 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
||||
private final RestClientConfig restClientConfig;
|
||||
private final SecurityTraceConfig securityTraceConfig;
|
||||
|
||||
private static final String PAYMENT_INSTRUCTION_TRANSACTION_KEY = "paymentInstructionTransaction";
|
||||
|
||||
@Inject
|
||||
public SecurityTraceClient(
|
||||
HttpClientUseCase httpClientUseCase,
|
||||
@ -148,7 +150,7 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
||||
|
||||
Map<String, Object> apiRequestMap = restClientConfig.toMap(apiRequest);
|
||||
Map<String, Object> paymentInstructionTransaction =
|
||||
(Map<String, Object>) apiRequestMap.get("paymentInstructionTransaction");
|
||||
(Map<String, Object>) apiRequestMap.get(PAYMENT_INSTRUCTION_TRANSACTION_KEY);
|
||||
|
||||
if(Objects.isNull(paymentInstructionTransaction)) {
|
||||
return Collections.emptyMap();
|
||||
@ -159,7 +161,7 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
||||
apiRequest.getPaymentInstructionTransaction().getPaymentArrangement().size()
|
||||
);
|
||||
|
||||
apiRequestMap.put("paymentInstructionTransaction", paymentInstructionTransaction);
|
||||
apiRequestMap.put(PAYMENT_INSTRUCTION_TRANSACTION_KEY, paymentInstructionTransaction);
|
||||
|
||||
return apiRequestMap;
|
||||
}
|
||||
@ -180,7 +182,7 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
||||
}
|
||||
|
||||
Map<String, Object> paymentInstructionTransaction =
|
||||
(Map<String, Object>) data.get("paymentInstructionTransaction");
|
||||
(Map<String, Object>) data.get(PAYMENT_INSTRUCTION_TRANSACTION_KEY);
|
||||
|
||||
if(Objects.isNull(paymentInstructionTransaction)) {
|
||||
return Collections.emptyMap();
|
||||
@ -191,7 +193,7 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
||||
apiResponseData.getData().getPaymentInstructionTransaction().getPaymentArrangement().size()
|
||||
);
|
||||
|
||||
data.put("paymentInstructionTransaction", paymentInstructionTransaction);
|
||||
data.put(PAYMENT_INSTRUCTION_TRANSACTION_KEY, paymentInstructionTransaction);
|
||||
|
||||
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