Feedback edits

This commit is contained in:
echerniak 2021-09-24 12:55:50 +03:00
parent ac6cfa05df
commit 16bc0d0438
No known key found for this signature in database
GPG Key ID: 7D79B3A9CB749B36

View File

@ -1,7 +1,9 @@
package com.rbkmoney.anapi.v2.converter.search.request;
import com.rbkmoney.anapi.v2.exception.BadRequestException;
import com.rbkmoney.magista.*;
import com.rbkmoney.magista.InvoiceSearchQuery;
import com.rbkmoney.magista.InvoiceStatus;
import com.rbkmoney.magista.PaymentParams;
import org.springframework.stereotype.Component;
import java.time.OffsetDateTime;
@ -34,15 +36,24 @@ public class ParamsToInvoiceSearchQueryConverter {
fillCommonParams(fromTime, toTime, limit, partyID, merge(shopID, shopIDs),
continuationToken))
.setPaymentParams(
new PaymentParams()
.setPaymentAmountFrom(invoiceAmountFrom != null ? invoiceAmountFrom : 0L)
.setPaymentAmountTo(invoiceAmountTo != null ? invoiceAmountTo : 0L)
getPaymentParams(invoiceAmountFrom, invoiceAmountTo)
)
.setInvoiceStatus(invoiceStatus != null ? mapStatus(invoiceStatus) : null)
.setInvoiceIds(merge(invoiceID, invoiceIDs))
.setExternalId(externalID);
}
private PaymentParams getPaymentParams(Long invoiceAmountFrom, Long invoiceAmountTo) {
var params = new PaymentParams();
if (invoiceAmountFrom != null) {
params.setPaymentAmountFrom(invoiceAmountFrom);
}
if (invoiceAmountTo != null) {
params.setPaymentAmountTo(invoiceAmountTo);
}
return params;
}
private InvoiceStatus mapStatus(String statusParam) {
var status = Enum.valueOf(com.rbkmoney.openapi.anapi_v2.model.InvoiceStatus.StatusEnum.class, statusParam);
return switch (status) {