Search in sources :

Example 11 with MiraklShopDocument

use of com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImpl method populateMiraklShopBusinessStakeholderDocuments.

protected KYCDocumentBusinessStakeHolderInfoModel populateMiraklShopBusinessStakeholderDocuments(final KYCDocumentBusinessStakeHolderInfoModel kycBusinessStakeHolderInfoModel) {
    final MiraklGetShopDocumentsRequest getShopBusinessStakeholderDocumentsRequest = new MiraklGetShopDocumentsRequest(List.of(kycBusinessStakeHolderInfoModel.getClientUserId()));
    try {
        log.info("Retrieving business stakeholder documents for seller with id [{}]", kycBusinessStakeHolderInfoModel.getClientUserId());
        final List<MiraklShopDocument> shopDocuments = miraklMarketplacePlatformOperatorApiClient.getShopDocuments(getShopBusinessStakeholderDocumentsRequest);
        // @formatter:off
        log.info("Business stakeholder documents available for seller with id [{}]: [{}]", kycBusinessStakeHolderInfoModel.getClientUserId(), shopDocuments.stream().map(miraklDocument -> "Id:" + miraklDocument.getId() + " ,fileName:" + miraklDocument.getFileName() + " ,typeCode:" + miraklDocument.getTypeCode()).collect(Collectors.joining(" | ")));
        // @formatter:on
        return kycBusinessStakeHolderInfoModel.toBuilder().miraklShopDocuments(shopDocuments).build();
    } catch (final MiraklException e) {
        log.error("Something went wrong trying to receive business stakeholder documents from Mirakl for seller with id [{}]", kycBusinessStakeHolderInfoModel.getClientUserId());
        kycMailNotificationUtil.sendPlainTextEmail("Issue detected getting business stakeholder documents from Mirakl", String.format("Something went wrong getting documents from Mirakl for shop Id [%s]%n%s", String.join(",", kycBusinessStakeHolderInfoModel.getClientUserId()), MiraklLoggingErrorsUtil.stringify(e)));
    }
    return kycBusinessStakeHolderInfoModel.toBuilder().build();
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklGetShopDocumentsRequest(com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest) MiraklShopDocument(com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)

Example 12 with MiraklShopDocument

use of com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellerDocumentDownloadExtractServiceImpl method populateMiraklShopDocuments.

/**
 * {@inheritDoc}
 */
@Override
public KYCDocumentSellerInfoModel populateMiraklShopDocuments(final KYCDocumentSellerInfoModel kycDocumentSellerInfoModel) {
    final MiraklGetShopDocumentsRequest getShopDocumentsRequest = new MiraklGetShopDocumentsRequest(List.of(kycDocumentSellerInfoModel.getClientUserId()));
    try {
        log.info("Retrieving documents for seller with id [{}]", kycDocumentSellerInfoModel.getClientUserId());
        final List<MiraklShopDocument> shopDocuments = miraklMarketplacePlatformOperatorApiClient.getShopDocuments(getShopDocumentsRequest);
        log.info("Documents retrieved for seller with id [{}]: [{}]", kycDocumentSellerInfoModel.getClientUserId(), shopDocuments.stream().map(MiraklShopDocument::getId).collect(Collectors.joining(",")));
        return kycDocumentSellerInfoModel.toBuilder().miraklShopDocuments(shopDocuments).build();
    } catch (final MiraklException e) {
        log.error("Something went wrong trying to receive documents from Mirakl for seller with id [{}]", kycDocumentSellerInfoModel.getClientUserId());
        kycMailNotificationUtil.sendPlainTextEmail("Issue detected getting documents from Mirakl", String.format("Something went wrong getting documents from Mirakl for shop Id [%s]%n%s", String.join(",", kycDocumentSellerInfoModel.getClientUserId()), MiraklLoggingErrorsUtil.stringify(e)));
    }
    return kycDocumentSellerInfoModel.toBuilder().build();
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklGetShopDocumentsRequest(com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest) MiraklShopDocument(com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)

Aggregations

MiraklShopDocument (com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)12 Test (org.junit.jupiter.api.Test)9 MiraklGetShopDocumentsRequest (com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest)7 MiraklException (com.mirakl.client.core.exception.MiraklException)4 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 KYCDocumentModel (com.paypal.kyc.model.KYCDocumentModel)2 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)1 ErrorBean (com.mirakl.client.domain.common.error.ErrorBean)1 MiraklShopKyc (com.mirakl.client.mmp.domain.shop.MiraklShopKyc)1 MiraklShopKycStatus (com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus)1 MiraklMarketplacePlatformOperatorApiClient (com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient)1 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)1 MiraklUpdateShopWithErrors (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShopWithErrors)1 MiraklUpdatedShopReturn (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn)1 MiraklUpdatedShops (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops)1 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)1 MiraklRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)1 MiraklSimpleRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue)1 MiraklDownloadShopsDocumentsRequest (com.mirakl.client.mmp.request.shop.document.MiraklDownloadShopsDocumentsRequest)1