update error messages into private api; update generals
This commit is contained in:
parent
f34cb89110
commit
14f0b0b049
Binary file not shown.
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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) {
|
||||||
|
|||||||
@ -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
|
|
||||||
}
|
|
||||||
@ -32,8 +32,7 @@ public class PaymentInitiationRequestRequest {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public String getPaymentTransactionType() {
|
public String getPaymentTransactionType() {
|
||||||
return paymentInitiationTransaction
|
return paymentInitiationTransaction
|
||||||
.getPaymentTransactionType()
|
.getPaymentTransactionType();
|
||||||
.name();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
package com.banesco.module.payment_initiation_request.domain.model;
|
|
||||||
|
|
||||||
public enum PaymentTransactionType {
|
|
||||||
MOBILE_PAYMENT,
|
|
||||||
}
|
|
||||||
@ -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
Loading…
x
Reference in New Issue
Block a user