WIP.Inermediate commit

This commit is contained in:
echerniak 2021-09-13 15:37:11 +03:00
parent 81667b79ca
commit 41479becc6
No known key found for this signature in database
GPG Key ID: 7D79B3A9CB749B36
2 changed files with 61 additions and 40 deletions

View File

@ -16,6 +16,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import static com.rbkmoney.anapi.v2.util.OpenApiUtil.mapToCategory;
@Service
@RequiredArgsConstructor
public class SearchService {
@ -92,25 +94,7 @@ public class SearchService {
return null;
}
private ChargebackCategory mapToCategory(InvoicePaymentChargebackCategory chargebackCategory) {
if (chargebackCategory.isSetAuthorisation()) {
return ChargebackCategory.AUTHORISATION;
}
if (chargebackCategory.isSetDispute()) {
return ChargebackCategory.DISPUTE;
}
if (chargebackCategory.isSetFraud()) {
return ChargebackCategory.FRAUD;
}
if (chargebackCategory.isSetProcessingError()) {
return ChargebackCategory.PROCESSING_ERROR;
}
return null;
}
public InlineResponse2009 findInvoices(InvoiceSearchQuery query) {
try {
@ -147,26 +131,6 @@ public class SearchService {
return null;
}
private Invoice.StatusEnum mapToStatus(InvoiceStatus status) {
if (status.isSetFulfilled()) {
return Invoice.StatusEnum.FULFILLED;
}
if (status.isSetPaid()) {
return Invoice.StatusEnum.PAID;
}
if (status.isSetUnpaid()) {
return Invoice.StatusEnum.UNPAID;
}
if (status.isSetCancelled()) {
return Invoice.StatusEnum.CANCELLED;
}
throw new IllegalArgumentException("");
}
public InlineResponse20011 findPayouts(PayoutSearchQuery query) {
try {
StatPayoutResponse magistaResponse = magistaClient.searchPayouts(query);
@ -288,8 +252,14 @@ public class SearchService {
.shopID(refund.getShopId())
.status(mapToStatus(refund.getStatus()))
.externalID(refund.getExternalId())
.error(new RefundStatusError()
.code());
.error(refund.getStatus().isSetFailed() ?
new RefundStatusError()
.code(refund.getStatus().getFailed().getFailure().getFailure().getCode())
.message(refund.getStatus().getFailed().getFailure().getFailure().getReason())
: null)
.invoiceID(refund.getInvoiceId())
.paymentID(refund.getPaymentId())
.reason(refund.getReason());
results.add(result);
}
return new InlineResponse20012()

View File

@ -0,0 +1,51 @@
package com.rbkmoney.anapi.v2.util;
import com.rbkmoney.damsel.domain.InvoicePaymentChargebackCategory;
import com.rbkmoney.magista.InvoiceStatus;
import com.rbkmoney.openapi.anapi_v2.model.ChargebackCategory;
import com.rbkmoney.openapi.anapi_v2.model.Invoice;
import lombok.experimental.UtilityClass;
@UtilityClass
public class OpenApiUtil {
public static ChargebackCategory mapToCategory(InvoicePaymentChargebackCategory chargebackCategory) {
if (chargebackCategory.isSetAuthorisation()) {
return ChargebackCategory.AUTHORISATION;
}
if (chargebackCategory.isSetDispute()) {
return ChargebackCategory.DISPUTE;
}
if (chargebackCategory.isSetFraud()) {
return ChargebackCategory.FRAUD;
}
if (chargebackCategory.isSetProcessingError()) {
return ChargebackCategory.PROCESSING_ERROR;
}
return null;
}
public static Invoice.StatusEnum mapToStatus(InvoiceStatus status) {
if (status.isSetFulfilled()) {
return Invoice.StatusEnum.FULFILLED;
}
if (status.isSetPaid()) {
return Invoice.StatusEnum.PAID;
}
if (status.isSetUnpaid()) {
return Invoice.StatusEnum.UNPAID;
}
if (status.isSetCancelled()) {
return Invoice.StatusEnum.CANCELLED;
}
throw new IllegalArgumentException("");
}
}