update error messages into private api; update generals
This commit is contained in:
parent
50b202c6cd
commit
cfd110e44d
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
|||||||
<artifactId>rec-payment-instruction-request</artifactId>
|
<artifactId>rec-payment-instruction-request</artifactId>
|
||||||
<version>1.0-native-quarkus-jdk17</version>
|
<version>1.0-native-quarkus-jdk17</version>
|
||||||
<name>rec-payment-instruction-request</name>
|
<name>rec-payment-instruction-request</name>
|
||||||
<description>API Reception - Create payment single request</description>
|
<description>API Reception - 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.
@ -16,6 +16,9 @@ import java.util.List;
|
|||||||
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
|
||||||
@ -29,7 +32,7 @@ public class RequestValidatorHelper {
|
|||||||
required(request.getRecipientId(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.arrangement[0].arrangementInvolvement[0].partyReference.partyIdentification[IDENTITY_CARD_NUMBER].partyIdentification.identifierValue");
|
required(request.getRecipientId(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.arrangement[0].arrangementInvolvement[0].partyReference.partyIdentification[IDENTITY_CARD_NUMBER].partyIdentification.identifierValue");
|
||||||
required(request.getRecipientPhone(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.arrangement[0].arrangementInvolvement[0].partyReference.partyIdentification[TELEPHONE_NUMBER].partyIdentification.identifierValue");
|
required(request.getRecipientPhone(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.arrangement[0].arrangementInvolvement[0].partyReference.partyIdentification[TELEPHONE_NUMBER].partyIdentification.identifierValue");
|
||||||
required(request.getBankCode(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.bankingProduct.productName");
|
required(request.getBankCode(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.bankingProduct.productName");
|
||||||
required(request.getAmount(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.amount");
|
required(request.getAmount(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.paymentAmount");
|
||||||
required(request.getPurpose(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.paymentPurpose");
|
required(request.getPurpose(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.paymentPurpose");
|
||||||
required(request.getEffectiveDate(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.paymentDate[0].date");
|
required(request.getEffectiveDate(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.paymentDate[0].date");
|
||||||
|
|
||||||
@ -40,10 +43,16 @@ public class RequestValidatorHelper {
|
|||||||
for (PaymentArrangement item: request.getPaymentArrangement()) {
|
for (PaymentArrangement item: request.getPaymentArrangement()) {
|
||||||
required(item.getApplicantId(), "paymentInstructionTransaction.paymentArrangement[%d].arrangement[0].arrangementInvolvement[PARTY_IS_OBLIGOR_IN_ARRANGEMENT].partyReference.partyIdentification[IDENTITY_CARD_NUMBER].partyIdentification.identifierValue".formatted(index));
|
required(item.getApplicantId(), "paymentInstructionTransaction.paymentArrangement[%d].arrangement[0].arrangementInvolvement[PARTY_IS_OBLIGOR_IN_ARRANGEMENT].partyReference.partyIdentification[IDENTITY_CARD_NUMBER].partyIdentification.identifierValue".formatted(index));
|
||||||
required(item.getApplicantPhone(), "paymentInstructionTransaction.paymentArrangement[%d].arrangement[0].arrangementInvolvement[PARTY_IS_OBLIGOR_IN_ARRANGEMENT].partyReference.partyIdentification[TELEPHONE_NUMBER].partyIdentification.identifierValue".formatted(index));
|
required(item.getApplicantPhone(), "paymentInstructionTransaction.paymentArrangement[%d].arrangement[0].arrangementInvolvement[PARTY_IS_OBLIGOR_IN_ARRANGEMENT].partyReference.partyIdentification[TELEPHONE_NUMBER].partyIdentification.identifierValue".formatted(index));
|
||||||
|
|
||||||
|
required(item.getAmount(), "paymentInstructionTransaction.paymentArrangement[%d].paymentAmount".formatted(index));
|
||||||
|
required(item.getPurpose(), "paymentInstructionTransaction.paymentArrangement[%d].paymentPurpose".formatted(index));
|
||||||
|
required(item.getEffectiveDate(), "paymentInstructionTransaction.paymentArrangement[%d].paymentDate[0].date".formatted(index));
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
required(request.getChannelCode(), "procedureRequest.instructionPurposeType");
|
required(request.getChannelCode(), "procedureRequest.instructionPurposeType");
|
||||||
|
required(request.getCustomerReferenceFintechId(), "customerReferenceFintechId");
|
||||||
required(request.getAppId(), "appId");
|
required(request.getAppId(), "appId");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +68,9 @@ public class RequestValidatorHelper {
|
|||||||
for (PaymentArrangement item: request.getPaymentArrangement()) {
|
for (PaymentArrangement item: request.getPaymentArrangement()) {
|
||||||
validate(item.getApplicantId(), config.applicantIdNumber(), "paymentInstructionTransaction.paymentArrangement[%d].arrangement[0].arrangementInvolvement[PARTY_IS_OBLIGOR_IN_ARRANGEMENT].partyReference.partyIdentification[IDENTITY_CARD_NUMBER].partyIdentification.identifierValue".formatted(index));
|
validate(item.getApplicantId(), config.applicantIdNumber(), "paymentInstructionTransaction.paymentArrangement[%d].arrangement[0].arrangementInvolvement[PARTY_IS_OBLIGOR_IN_ARRANGEMENT].partyReference.partyIdentification[IDENTITY_CARD_NUMBER].partyIdentification.identifierValue".formatted(index));
|
||||||
validate(item.getApplicantPhone(), config.applicantPhoneNumber(), "paymentInstructionTransaction.paymentArrangement[%d].arrangement[0].arrangementInvolvement[PARTY_IS_OBLIGOR_IN_ARRANGEMENT].partyReference.partyIdentification[TELEPHONE_NUMBER].partyIdentification.identifierValue".formatted(index));
|
validate(item.getApplicantPhone(), config.applicantPhoneNumber(), "paymentInstructionTransaction.paymentArrangement[%d].arrangement[0].arrangementInvolvement[PARTY_IS_OBLIGOR_IN_ARRANGEMENT].partyReference.partyIdentification[TELEPHONE_NUMBER].partyIdentification.identifierValue".formatted(index));
|
||||||
|
|
||||||
|
validate(item.getAmount(), "paymentInstructionTransaction.paymentArrangement[%d].paymentAmount".formatted(index));
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,31 +79,31 @@ 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 required(List<?> value, String fieldName) {
|
private void required(List<?> value, String fieldName) {
|
||||||
if (value == null || value.isEmpty()) {
|
if (value == null || value.isEmpty()) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,103 +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(
|
||||||
|
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,
|
||||||
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) {
|
||||||
|
|||||||
@ -436,7 +436,7 @@ public class PaymentInstructionRequestResource {
|
|||||||
})
|
})
|
||||||
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")
|
||||||
|
|||||||
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