update error messages into private api; update generals

This commit is contained in:
Ramon Ramirez 2026-01-30 15:37:38 -04:00
parent f34cb89110
commit 14f0b0b049
10 changed files with 98 additions and 100 deletions

View File

@ -14,6 +14,9 @@ import java.math.BigDecimal;
public class RequestValidatorHelper { public class RequestValidatorHelper {
private final RequestValidationConfig config; private final RequestValidationConfig config;
private static final String REQUIRED_CODE = "VDE01";
private static final String VALIDATE_CODE = "VDE02";
@Inject @Inject
public RequestValidatorHelper( public RequestValidatorHelper(
RequestValidationConfig config RequestValidationConfig config
@ -32,6 +35,7 @@ public class RequestValidatorHelper {
required(request.getPurpose(), "paymentInitiationTransaction.paymentPurpose"); required(request.getPurpose(), "paymentInitiationTransaction.paymentPurpose");
required(request.getPurpose(), "paymentInitiationTransaction.paymentPurpose"); required(request.getPurpose(), "paymentInitiationTransaction.paymentPurpose");
required(request.getChannelCode(), "procedureRequest.instructionPurposeType"); required(request.getChannelCode(), "procedureRequest.instructionPurposeType");
required(request.getCustomerReferenceFintechId(), "customerReferenceFintechId");
required(request.getAppId(), "appId"); required(request.getAppId(), "appId");
} }
@ -46,25 +50,25 @@ public class RequestValidatorHelper {
private void required(String value, String fieldName) { private void required(String value, String fieldName) {
if (value == null || value.trim().isEmpty()) { if (value == null || value.trim().isEmpty()) {
throw HttpStatusCodeException.badRequest("VDE01", fieldName); throw HttpStatusCodeException.badRequest(REQUIRED_CODE, fieldName);
} }
} }
private void required(BigDecimal value, String fieldName) { private void required(BigDecimal value, String fieldName) {
if (value == null) { if (value == null) {
throw HttpStatusCodeException.badRequest("VDE01", fieldName); throw HttpStatusCodeException.badRequest(REQUIRED_CODE, fieldName);
} }
} }
private void validate(String value, String regex, String fieldName) { private void validate(String value, String regex, String fieldName) {
if (value != null && !value.isEmpty() && !value.matches(regex)) { if (value != null && !value.isEmpty() && !value.matches(regex)) {
throw HttpStatusCodeException.badRequest("VDE02", fieldName); throw HttpStatusCodeException.badRequest(VALIDATE_CODE, fieldName);
} }
} }
private void validate(BigDecimal value, String fieldName) { private void validate(BigDecimal value, String fieldName) {
if (value != null && value.compareTo(BigDecimal.ZERO) < 1) { if (value != null && value.compareTo(BigDecimal.ZERO) < 1) {
throw HttpStatusCodeException.badRequest("VDE02", fieldName); throw HttpStatusCodeException.badRequest(VALIDATE_CODE, fieldName);
} }
} }
} }

View File

@ -143,6 +143,20 @@ public class HttpRequest {
.build(); .build();
} }
public static <T, R> HttpRequest forDirectResponse(
String url,
HttpMethod method,
Class<T> responseType,
Class<R> errorType
) {
return HttpRequest.builder()
.url(url)
.method(method)
.responseType(responseType)
.errorType(errorType)
.build();
}
public static <T, U> HttpRequest forGenericResponse( public static <T, U> HttpRequest forGenericResponse(
String url, String url,
HttpMethod method, HttpMethod method,

View File

@ -1,14 +0,0 @@
package com.banesco.common.domain.model;
import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.*;
@Getter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
@RegisterForReflection
public class Location {
private String locationValue; // directorio
}

View File

@ -32,8 +32,7 @@ public class PaymentInitiationRequestRequest {
@JsonIgnore @JsonIgnore
public String getPaymentTransactionType() { public String getPaymentTransactionType() {
return paymentInitiationTransaction return paymentInitiationTransaction
.getPaymentTransactionType() .getPaymentTransactionType();
.name();
} }
@JsonIgnore @JsonIgnore

View File

@ -14,7 +14,7 @@ import java.math.BigDecimal;
@AllArgsConstructor @AllArgsConstructor
@RegisterForReflection @RegisterForReflection
public class PaymentInitiationTransactionInstanceRecord { public class PaymentInitiationTransactionInstanceRecord {
private PaymentTransactionType paymentTransactionType; // operationTypeCode private String paymentTransactionType; // operationTypeCode
private Payer payerReference; // applicantId private Payer payerReference; // applicantId
private Payee payeeReference; // recipientId private Payee payeeReference; // recipientId
private BigDecimal amount; // amount private BigDecimal amount; // amount

View File

@ -1,5 +0,0 @@
package com.banesco.module.payment_initiation_request.domain.model;
public enum PaymentTransactionType {
MOBILE_PAYMENT,
}

View File

@ -217,7 +217,7 @@ public class PaymentInitiationRequestResource {
}) })
public Response initiate( public Response initiate(
@HeaderParam("customerReferenceFintechId") @HeaderParam("customerReferenceFintechId")
@Parameter(description = "ID de la fintech", required = true, example = "pranical-test") @Parameter(description = "ID de la fintech", required = true, example = "provider-test")
String customerReferenceFintechId, String customerReferenceFintechId,
@HeaderParam("appId") @HeaderParam("appId")
@ -234,7 +234,7 @@ public class PaymentInitiationRequestResource {
value = """ value = """
{ {
"paymentInitiationTransaction": { "paymentInitiationTransaction": {
"paymentTransactionType": "MOBILE_PAYMENT", "paymentTransactionType": "PAGO_MOVIL",
"payerReference": { "payerReference": {
"partyIdentification": [ "partyIdentification": [
{ {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long