Search in sources :

Example 16 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class AbstractMiraklSelectedDocumentsStrategy method downloadDocument.

private KYCDocumentModel downloadDocument(final Pair<String, MiraklDownloadShopsDocumentsRequest> fieldNameAndDocumentIdPair) {
    final MiraklDownloadShopsDocumentsRequest miraklDownloadShopsDocumentsRequest = fieldNameAndDocumentIdPair.getValue();
    final String fieldName = fieldNameAndDocumentIdPair.getKey();
    final String documentId = miraklDownloadShopsDocumentsRequest.getDocumentIds().stream().findAny().orElse(null);
    try {
        log.info("Trying to download file with id [{}]", documentId);
        final FileWrapper fileWrapper = miraklApiClient.downloadShopsDocuments(miraklDownloadShopsDocumentsRequest);
        log.info("Document with id [{}] downloaded", documentId);
        return KYCDocumentModel.builder().file(fileWrapper.getFile()).documentFieldName(fieldName).build();
    } catch (MiraklException e) {
        log.error("Something went wrong trying to download document with id [{}]", documentId);
        log.error(e.getMessage(), e);
    }
    return null;
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklDownloadShopsDocumentsRequest(com.mirakl.client.mmp.request.shop.document.MiraklDownloadShopsDocumentsRequest) FileWrapper(com.mirakl.client.mmp.domain.common.FileWrapper)

Example 17 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class ReportsMiraklExtractServiceImplTest method getAllTransactions_shouldSendAnEmailWhenMiraklSDKThrowsAnException.

@Test
void getAllTransactions_shouldSendAnEmailWhenMiraklSDKThrowsAnException() {
    final MiraklException thrownException = new MiraklException("Something went wrong contacting Mirakl");
    when(reportsMiraklApiClientMock.getTransactionLogs(any())).thenThrow(thrownException);
    final List<HmcMiraklTransactionLine> result = testObj.getAllTransactionLinesByDate(startDate, endDate);
    assertThat(result).isEmpty();
    verify(mailNotificationMock).sendPlainTextEmail("Issue detected retrieving log lines from Mirakl", String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting transaction log information from %s to %s\n%s", convertToString(convertToLocalDateTime(startDate), DATE_FORMAT), convertToString(convertToLocalDateTime(endDate), DATE_FORMAT), MiraklLoggingErrorsUtil.stringify(thrownException)));
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) HmcMiraklTransactionLine(com.paypal.reports.reportsextract.model.HmcMiraklTransactionLine) Test(org.junit.jupiter.api.Test)

Example 18 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class ReportsMiraklExtractServiceImpl method getAllTransactionLinesByDate.

@Override
public List<HmcMiraklTransactionLine> getAllTransactionLinesByDate(final Date startDate, final Date endDate) {
    log.info("Retrieving Mirakl transaction logs from {} to {}", startDate, endDate);
    final var miraklGetTransactionLogsRequest = new MiraklGetTransactionLogsRequest();
    miraklGetTransactionLogsRequest.setStartDate(startDate);
    miraklGetTransactionLogsRequest.setEndDate(endDate);
    miraklGetTransactionLogsRequest.setPaginate(false);
    try {
        final MiraklTransactionLogs transactionLogs = reportsMiraklMarketplacePlatformOperatorApiClient.getTransactionLogs(miraklGetTransactionLogsRequest);
        log.info("{} Mirakl transaction logs from {} to {}", transactionLogs.getTotalCount(), startDate, endDate);
        // @formatter:off
        return Optional.ofNullable(transactionLogs.getLines()).orElse(List.of()).stream().map(miraklTransactionLogMiraklTransactionLineConverter::convert).collect(Collectors.toList());
    // @formatter:on
    } catch (final MiraklException e) {
        log.error("Something went wrong retrieving log lines from Mirakl from {} to {}", startDate, endDate);
        mailNotificationUtil.sendPlainTextEmail(EMAIL_SUBJECT_MESSAGE, String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting transaction log information from %s to %s\n%s", convertToString(convertToLocalDateTime(startDate), DATE_FORMAT), convertToString(convertToLocalDateTime(endDate), DATE_FORMAT), MiraklLoggingErrorsUtil.stringify(e)));
        return List.of();
    }
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklGetTransactionLogsRequest(com.mirakl.client.mmp.request.payment.MiraklGetTransactionLogsRequest) MiraklTransactionLogs(com.mirakl.client.mmp.domain.payment.MiraklTransactionLogs)

Aggregations

MiraklException (com.mirakl.client.core.exception.MiraklException)18 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)9 Test (org.junit.jupiter.api.Test)8 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)4 MiraklRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)4 MiraklGetShopDocumentsRequest (com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest)4 MiraklShopDocument (com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)3 MiraklUpdatedShops (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops)3 KYCUserDocumentFlagsNotificationBodyModel (com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)3 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)2 MiraklMarketplacePlatformOperatorApiClient (com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient)2 MiraklUpdatedShopReturn (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn)2 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)2 MiraklLoggingErrorsUtil (com.paypal.infrastructure.util.MiraklLoggingErrorsUtil)2 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)2 KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)2 Collectors (java.util.stream.Collectors)2 Slf4j (lombok.extern.slf4j.Slf4j)2 CollectionUtils (org.apache.commons.collections4.CollectionUtils)2