mirror of
https://github.com/valitydev/anapi-v2.git
synced 2024-11-06 08:35:19 +00:00
WIP.Inermediate commit
This commit is contained in:
parent
81667b79ca
commit
41479becc6
@ -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()
|
||||
|
51
src/main/java/com/rbkmoney/anapi/v2/util/OpenApiUtil.java
Normal file
51
src/main/java/com/rbkmoney/anapi/v2/util/OpenApiUtil.java
Normal 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("");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user