Search in sources :

Example 1 with KYCDocumentNotificationModel

use of com.paypal.kyc.model.KYCDocumentNotificationModel in project mirakl-hyperwallet-connector by paypal.

the class AbstractKYCUserStatusNotificationStrategy method deleteInvalidDocuments.

protected void deleteInvalidDocuments(final KYCUserStatusNotificationBodyModel kycUserNotification) {
    final String clientUserId = kycUserNotification.getClientUserId();
    final KYCDocumentInfoModel kycDocumentInfoModel = miraklSellerDocumentsExtractService.extractKYCSellerDocuments(clientUserId);
    final Map<String, LocalDateTime> documentsToBeDeleted = kycUserNotification.getDocuments().stream().filter(kycDocumentNotificationModel -> KYCDocumentStatusEnum.INVALID.equals(kycDocumentNotificationModel.getDocumentStatus())).map(kycDocumentNotificationModel -> Pair.of(kycDocumentNotificationModelListConverter.convert(kycDocumentNotificationModel), kycDocumentNotificationModel.getCreatedOn())).map(this::getMapDocumentUploadTime).flatMap(map -> map.entrySet().stream()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
    if (MapUtils.isNotEmpty(documentsToBeDeleted)) {
        final List<MiraklShopDocument> miraklDocumentsToBeDeleted = kycDocumentInfoModel.getMiraklShopDocuments().stream().filter(miraklShopDocument -> documentsToBeDeleted.containsKey(miraklShopDocument.getTypeCode())).filter(Predicate.not(miraklShopDocument -> isANewMiraklDocument(documentsToBeDeleted, miraklShopDocument))).collect(Collectors.toList());
        final String documentTypeCodesToBeDeleted = miraklDocumentsToBeDeleted.stream().map(MiraklShopDocument::getTypeCode).collect(Collectors.joining(COMMA));
        if (!StringUtils.isEmpty(documentTypeCodesToBeDeleted)) {
            log.info("Deleting documents [{}] for shop [{}]", documentTypeCodesToBeDeleted, clientUserId);
            miraklSellerDocumentsExtractService.deleteDocuments(miraklDocumentsToBeDeleted);
            log.info("Documents deleted");
        }
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) Converter(com.paypal.infrastructure.converter.Converter) java.util(java.util) LocalDateTime(java.time.LocalDateTime) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) KYCRejectionReasonService(com.paypal.kyc.service.KYCRejectionReasonService) StringUtils(org.apache.commons.lang3.StringUtils) MiraklUpdatedShops(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops) CollectionUtils(org.apache.commons.collections4.CollectionUtils) Value(org.springframework.beans.factory.annotation.Value) HMCException(com.paypal.infrastructure.exceptions.HMCException) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) Pair(org.apache.commons.lang3.tuple.Pair) MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklUpdateShopWithErrors(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShopWithErrors) MiraklMarketplacePlatformOperatorApiClient(com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient) MiraklSellerDocumentsExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklSellerDocumentsExtractService) MapUtils(org.apache.commons.collections4.MapUtils) MiraklSimpleRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) KYCDocumentNotificationModel(com.paypal.kyc.model.KYCDocumentNotificationModel) HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) Predicate(java.util.function.Predicate) MiraklLoggingErrorsUtil(com.paypal.infrastructure.util.MiraklLoggingErrorsUtil) Collectors(java.util.stream.Collectors) MailNotificationUtil(com.paypal.infrastructure.mail.MailNotificationUtil) Strategy(com.paypal.infrastructure.strategy.Strategy) ZoneId(java.time.ZoneId) MiraklShopKyc(com.mirakl.client.mmp.domain.shop.MiraklShopKyc) MiraklShopKycStatus(com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus) MiraklUpdatedShopReturn(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Slf4j(lombok.extern.slf4j.Slf4j) HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD(com.paypal.kyc.model.KYCConstants.HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD) KYCDocumentStatusEnum(com.paypal.kyc.model.KYCDocumentStatusEnum) KYCUserStatusNotificationBodyModel(com.paypal.kyc.model.KYCUserStatusNotificationBodyModel) ErrorBean(com.mirakl.client.domain.common.error.ErrorBean) HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD(com.paypal.kyc.model.KYCConstants.HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD) MiraklShopDocument(com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument) KYCDocumentInfoModel(com.paypal.kyc.model.KYCDocumentInfoModel) KYCDocumentInfoModel(com.paypal.kyc.model.KYCDocumentInfoModel) MiraklShopDocument(com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)

Aggregations

HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)1 MiraklException (com.mirakl.client.core.exception.MiraklException)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 MiraklShopDocument (com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)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 Converter (com.paypal.infrastructure.converter.Converter)1 HMCException (com.paypal.infrastructure.exceptions.HMCException)1 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)1 Strategy (com.paypal.infrastructure.strategy.Strategy)1 MiraklLoggingErrorsUtil (com.paypal.infrastructure.util.MiraklLoggingErrorsUtil)1 HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD (com.paypal.kyc.model.KYCConstants.HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD)1