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;
}
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)));
}
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();
}
}
Aggregations