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>
|
||||
<version>1.0-native-quarkus-jdk17</version>
|
||||
<name>rec-payment-instruction-request</name>
|
||||
<description>API Reception - Create payment single request</description>
|
||||
<description>API Reception - Create payment multiple request</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.release>17</maven.compiler.release>
|
||||
|
||||
Binary file not shown.
@ -16,6 +16,9 @@ import java.util.List;
|
||||
public class RequestValidatorHelper {
|
||||
private final RequestValidationConfig config;
|
||||
|
||||
private static final String REQUIRED_CODE = "VDE01";
|
||||
private static final String VALIDATE_CODE = "VDE02";
|
||||
|
||||
@Inject
|
||||
public RequestValidatorHelper(
|
||||
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.getRecipientPhone(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.arrangement[0].arrangementInvolvement[0].partyReference.partyIdentification[TELEPHONE_NUMBER].partyIdentification.identifierValue");
|
||||
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.getEffectiveDate(), "paymentInstructionTransaction.paymentInstruction.paymentArrangement.paymentDate[0].date");
|
||||
|
||||
@ -40,10 +43,16 @@ public class RequestValidatorHelper {
|
||||
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.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++;
|
||||
}
|
||||
|
||||
required(request.getChannelCode(), "procedureRequest.instructionPurposeType");
|
||||
required(request.getCustomerReferenceFintechId(), "customerReferenceFintechId");
|
||||
required(request.getAppId(), "appId");
|
||||
}
|
||||
|
||||
@ -59,6 +68,9 @@ public class RequestValidatorHelper {
|
||||
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.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++;
|
||||
}
|
||||
|
||||
@ -67,31 +79,31 @@ public class RequestValidatorHelper {
|
||||
|
||||
private void required(String value, String fieldName) {
|
||||
if (value == null || value.trim().isEmpty()) {
|
||||
throw HttpStatusCodeException.badRequest("VDE01", fieldName);
|
||||
throw HttpStatusCodeException.badRequest(REQUIRED_CODE, fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
private void required(BigDecimal value, String fieldName) {
|
||||
if (value == null) {
|
||||
throw HttpStatusCodeException.badRequest("VDE01", fieldName);
|
||||
throw HttpStatusCodeException.badRequest(REQUIRED_CODE, fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
private void required(List<?> value, String fieldName) {
|
||||
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) {
|
||||
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) {
|
||||
if (value != null && value.compareTo(BigDecimal.ZERO) < 1) {
|
||||
throw HttpStatusCodeException.badRequest("VDE02", fieldName);
|
||||
throw HttpStatusCodeException.badRequest(VALIDATE_CODE, fieldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,6 +143,20 @@ public class HttpRequest {
|
||||
.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(
|
||||
String url,
|
||||
HttpMethod method,
|
||||
|
||||
@ -436,7 +436,7 @@ public class PaymentInstructionRequestResource {
|
||||
})
|
||||
public Response initiate(
|
||||
@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,
|
||||
|
||||
@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