Search in sources :

Example 1 with MiraklUpdatedShopReturn

use of com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellerDocumentsExtractServiceImpl method miraklUpdateShopCall.

private Optional<MiraklUpdatedShops> miraklUpdateShopCall(final List<String> shopIdList) {
    if (CollectionUtils.isEmpty(shopIdList)) {
        return Optional.empty();
    }
    final List<MiraklUpdateShop> shopsToUpdate = shopIdList.stream().map(Long::valueOf).map(shopId -> {
        final MiraklUpdateShop miraklUpdateShop = new MiraklUpdateShop();
        miraklUpdateShop.setShopId(shopId);
        miraklUpdateShop.setAdditionalFieldValues(List.of(new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(KYCConstants.HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD, Boolean.FALSE.toString().toLowerCase())));
        return miraklUpdateShop;
    }).collect(Collectors.toList());
    final MiraklUpdateShopsRequest miraklUpdateShopRequest = new MiraklUpdateShopsRequest(shopsToUpdate);
    try {
        final MiraklUpdatedShops miraklUpdatedShops = miraklOperatorClient.updateShops(miraklUpdateShopRequest);
        // @formatter:on
        log.info("Setting required KYC flag for shops with ids [{}] to false", miraklUpdatedShops.getShopReturns().stream().map(MiraklUpdatedShopReturn::getShopUpdated).map(MiraklShop::getId).collect(Collectors.joining(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR)));
        return Optional.of(miraklUpdatedShops);
    // @formatter:off
    } catch (final MiraklException e) {
        log.error("Something went wrong when removing flag to retrieve documents for shops [{}]", String.join(",", shopIdList));
        kycMailNotificationUtil.sendPlainTextEmail("Issue setting push document flags to false in Mirakl", String.format("Something went wrong setting push document flag to false in Mirakl for shop Id [%s]%n%s", String.join(",", shopIdList), MiraklLoggingErrorsUtil.stringify(e)));
    }
    return Optional.empty();
}
Also used : Converter(com.paypal.infrastructure.converter.Converter) java.util(java.util) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklUpdatedShops(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops) CollectionUtils(org.apache.commons.collections4.CollectionUtils) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklException(com.mirakl.client.core.exception.MiraklException) Service(org.springframework.stereotype.Service) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) MiraklMarketplacePlatformOperatorApiClient(com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient) MiraklSellerDocumentsExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklSellerDocumentsExtractService) KYCConstants(com.paypal.kyc.model.KYCConstants) Predicate(java.util.function.Predicate) ObjectUtils(org.springframework.util.ObjectUtils) MiraklShops(com.mirakl.client.mmp.domain.shop.MiraklShops) MiraklGetShopsRequest(com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest) MiraklLoggingErrorsUtil(com.paypal.infrastructure.util.MiraklLoggingErrorsUtil) Collectors(java.util.stream.Collectors) MailNotificationUtil(com.paypal.infrastructure.mail.MailNotificationUtil) MiraklUpdatedShopReturn(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) MiraklShop(com.mirakl.client.mmp.domain.shop.MiraklShop) LoggingConstantsUtil(com.paypal.infrastructure.util.LoggingConstantsUtil) MiraklSellerDocumentDownloadExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklSellerDocumentDownloadExtractService) KYCDocumentInfoModel(com.paypal.kyc.model.KYCDocumentInfoModel) MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklUpdatedShops(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklShop(com.mirakl.client.mmp.domain.shop.MiraklShop) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)

Example 2 with MiraklUpdatedShopReturn

use of com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn in project mirakl-hyperwallet-connector by paypal.

the class AbstractKYCUserStatusNotificationStrategy method updateShop.

protected void updateShop(final KYCUserStatusNotificationBodyModel kycUserStatusNotificationBodyModel) {
    final MiraklShopKycStatus status = expectedKycMiraklStatus(kycUserStatusNotificationBodyModel);
    if (Objects.nonNull(status)) {
        final String shopId = kycUserStatusNotificationBodyModel.getClientUserId();
        final MiraklUpdateShopsRequest request = createUpdateShopRequest(kycUserStatusNotificationBodyModel, status);
        log.info("Updating KYC status for shop [{}]", shopId);
        try {
            final MiraklUpdatedShops response = miraklOperatorClient.updateShops(request);
            if (response == null) {
                log.error("No response was received for update request for shop [{}]", shopId);
            } else {
                final List<MiraklUpdatedShopReturn> shopReturns = response.getShopReturns();
                shopReturns.forEach(this::logShopUpdates);
            }
            deleteInvalidDocuments(kycUserStatusNotificationBodyModel);
        } catch (final MiraklException ex) {
            final String errorMessage = String.format(MSG_ERROR_DETECTED, shopId, MiraklLoggingErrorsUtil.stringify(ex));
            log.error(errorMessage);
            mailNotificationUtil.sendPlainTextEmail(MAIL_SUBJECT, ERROR_MESSAGE_PREFIX + errorMessage);
            // Rethrow exception to handle it in AbstractNotificationListener
            throw ex;
        }
    }
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklUpdatedShopReturn(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn) MiraklUpdatedShops(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklShopKycStatus(com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus)

Aggregations

MiraklException (com.mirakl.client.core.exception.MiraklException)2 MiraklUpdatedShopReturn (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn)2 MiraklUpdatedShops (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops)2 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)2 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)1 MiraklShopKycStatus (com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus)1 MiraklShops (com.mirakl.client.mmp.domain.shop.MiraklShops)1 MiraklMarketplacePlatformOperatorApiClient (com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient)1 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)1 MiraklRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)1 MiraklGetShopsRequest (com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest)1 Converter (com.paypal.infrastructure.converter.Converter)1 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)1 LoggingConstantsUtil (com.paypal.infrastructure.util.LoggingConstantsUtil)1 MiraklLoggingErrorsUtil (com.paypal.infrastructure.util.MiraklLoggingErrorsUtil)1 KYCConstants (com.paypal.kyc.model.KYCConstants)1 KYCDocumentInfoModel (com.paypal.kyc.model.KYCDocumentInfoModel)1 KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)1 MiraklSellerDocumentDownloadExtractService (com.paypal.kyc.service.documents.files.mirakl.MiraklSellerDocumentDownloadExtractService)1 MiraklSellerDocumentsExtractService (com.paypal.kyc.service.documents.files.mirakl.MiraklSellerDocumentsExtractService)1