Search in sources :

Example 1 with FileWrapper

use of com.mirakl.client.mmp.domain.common.FileWrapper 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)

Aggregations

MiraklException (com.mirakl.client.core.exception.MiraklException)1 FileWrapper (com.mirakl.client.mmp.domain.common.FileWrapper)1 MiraklDownloadShopsDocumentsRequest (com.mirakl.client.mmp.request.shop.document.MiraklDownloadShopsDocumentsRequest)1