Search in sources :

Example 21 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.

the class IndividualKYCBusinessStakeholderStatusExecutorNotificationStrategyTest method updateMiraklProofIdentityFlagStatus_whenAPICallThrowsException_shouldThrowException.

@Test
void updateMiraklProofIdentityFlagStatus_whenAPICallThrowsException_shouldThrowException() {
    final MiraklException exception = new MiraklException("An error has occurred");
    when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(miraklUpdateShopsRequestArgumentCaptor.capture())).thenThrow(exception);
    final Throwable throwable = catchThrowable(() -> testObj.updateMiraklProofIdentityFlagStatus(MIRAKL_SHOP_ID, BSTK_PROOF_IDENTITY_FIELD, HyperwalletUser.VerificationStatus.REQUIRED));
    assertThat(throwable).isEqualTo(exception);
    final MiraklUpdateShopsRequest result = miraklUpdateShopsRequestArgumentCaptor.getValue();
    final List<MiraklRequestAdditionalFieldValue> additionalFieldValuesToBeChanged = result.getShops().get(0).getAdditionalFieldValues();
    assertThat(additionalFieldValuesToBeChanged).hasSize(1);
    final MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue miraklSimpleRequestAdditionalFieldValue = (MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) additionalFieldValuesToBeChanged.get(0);
    assertThat(miraklSimpleRequestAdditionalFieldValue.getCode()).isEqualTo(BSTK_PROOF_IDENTITY_FIELD);
    assertThat(miraklSimpleRequestAdditionalFieldValue.getValue()).isEqualTo("true");
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test)

Example 22 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellerDocumentsExtractServiceImplTest method setFlagToPushSellerDocumentsToFalse_shouldCallMiraklWithTheClientUsersIdPassedAsParam.

@Test
void setFlagToPushSellerDocumentsToFalse_shouldCallMiraklWithTheClientUsersIdPassedAsParam() {
    final KYCDocumentSellerInfoModel kycDocumentOne = KYCDocumentSellerInfoModel.builder().clientUserId("2000").build();
    final KYCDocumentSellerInfoModel kycDocumentTwo = KYCDocumentSellerInfoModel.builder().clientUserId("2001").build();
    final List<KYCDocumentSellerInfoModel> successfullyPushedDocumentsList = List.of(kycDocumentOne, kycDocumentTwo);
    when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(any(MiraklUpdateShopsRequest.class))).thenReturn(miraklUpdateShopsMock);
    final Optional<MiraklUpdatedShops> result = testObj.setFlagToPushProofOfIdentityAndBusinessSellerDocumentsToFalse(successfullyPushedDocumentsList);
    verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopArgumentCaptor.capture());
    final MiraklUpdateShopsRequest miraklUpdateShopRequest = miraklUpdateShopArgumentCaptor.getValue();
    final List<Long> updatedSellerIdList = miraklUpdateShopRequest.getShops().stream().map(MiraklUpdateShop::getShopId).collect(Collectors.toList());
    final List<String> updatedFlagValueList = miraklUpdateShopRequest.getShops().stream().map(MiraklUpdateShop::getAdditionalFieldValues).flatMap(Collection::stream).filter(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class::isInstance).map(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class::cast).map(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue::getValue).collect(Collectors.toList());
    final List<String> updatedFlagCodeList = miraklUpdateShopRequest.getShops().stream().map(MiraklUpdateShop::getAdditionalFieldValues).flatMap(Collection::stream).filter(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class::isInstance).map(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class::cast).map(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue::getCode).collect(Collectors.toList());
    assertThat(updatedSellerIdList).containsExactlyInAnyOrder(2000L, 2001L);
    assertThat(updatedFlagValueList).containsExactlyInAnyOrder("false", "false");
    assertThat(updatedFlagCodeList).containsExactlyInAnyOrder(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD, HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD);
    assertThat(result).hasValue(miraklUpdateShopsMock);
}
Also used : MiraklUpdatedShops(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) Collection(java.util.Collection) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test)

Example 23 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.

the class AbstractUserDocumentFlagsStrategyTest method fillMiraklProofIdentityOrBusinessFlagStatus_shouldSetFlagProofIdentificationToTrueInMirakl.

@Test
void fillMiraklProofIdentityOrBusinessFlagStatus_shouldSetFlagProofIdentificationToTrueInMirakl() {
    // @formatter:off
    final KYCUserDocumentFlagsNotificationBodyModel kycUserDocumentFlagsNotificationBodyModel = KYCUserDocumentFlagsNotificationBodyModel.builder().clientUserId(SHOP_ID).profileType(HyperwalletUser.ProfileType.INDIVIDUAL).verificationStatus(HyperwalletUser.VerificationStatus.REQUIRED).build();
    // @formatter:on
    testObj.fillMiraklProofIdentityOrBusinessFlagStatus(kycUserDocumentFlagsNotificationBodyModel);
    verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopsRequestArgumentCaptor.capture());
    final MiraklUpdateShopsRequest updateShopRequest = miraklUpdateShopsRequestArgumentCaptor.getValue();
    final MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue additionalValue = new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD, "true");
    assertThat(updateShopRequest.getShops()).hasSize(1);
    final MiraklUpdateShop shop = updateShopRequest.getShops().get(0);
    assertThat(shop.getShopId()).isEqualTo(Long.valueOf(SHOP_ID));
    final List<MiraklRequestAdditionalFieldValue> additionalFieldValues = shop.getAdditionalFieldValues();
    assertThat(additionalFieldValues).hasSize(1);
    final MiraklRequestAdditionalFieldValue additionalFieldValue = additionalFieldValues.get(0);
    assertThat(additionalFieldValue.getCode()).isEqualTo(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD);
    assertThat(additionalFieldValue).isInstanceOf(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class);
    assertThat(((MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) additionalFieldValue).getValue()).isEqualTo(Boolean.TRUE.toString());
}
Also used : KYCUserDocumentFlagsNotificationBodyModel(com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test)

Example 24 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.

the class KYCUserDocumentFlagProofIdentityBusinessStakeHolderStrategyTest method execute_shouldCallUpdateShopWithBusinessStakeHolderCustomValueFlags.

@Test
void execute_shouldCallUpdateShopWithBusinessStakeHolderCustomValueFlags() {
    // @formatter:off
    final KYCUserDocumentFlagsNotificationBodyModel kycUserDocumentFlagsNotificationBodyModel = KYCUserDocumentFlagsNotificationBodyModel.builder().hyperwalletProgram(HYPERWALLET_PROGRAM).userToken(USER_TOKEN).clientUserId(SHOP_ID).profileType(HyperwalletUser.ProfileType.BUSINESS).businessStakeholderVerificationStatus(HyperwalletUser.BusinessStakeholderVerificationStatus.REQUIRED).build();
    // @formatter:on
    when(hyperwalletBusinessStakeholderExtractServiceMock.getKYCRequiredVerificationBusinessStakeHolders(HYPERWALLET_PROGRAM, USER_TOKEN)).thenReturn(List.of(BUSINESS_STAKE_HOLDER_TOKEN));
    when(miraklBusinessStakeholderDocumentsExtractServiceMock.getKYCCustomValuesRequiredVerificationBusinessStakeholders(SHOP_ID, List.of(BUSINESS_STAKE_HOLDER_TOKEN))).thenReturn(List.of(HW_STAKEHOLDER_PROOF_IDENTITY_TYPE_1));
    testObj.execute(kycUserDocumentFlagsNotificationBodyModel);
    verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopsRequestArgumentCaptor.capture());
    final MiraklUpdateShopsRequest miraklRequest = miraklUpdateShopsRequestArgumentCaptor.getValue();
    assertThat(miraklRequest.getShops()).hasSize(1);
    final MiraklUpdateShop updateShop = miraklRequest.getShops().get(0);
    assertThat(updateShop.getShopId()).isEqualTo(Long.valueOf(SHOP_ID));
    final List<MiraklRequestAdditionalFieldValue> additionalFieldValues = updateShop.getAdditionalFieldValues();
    assertThat(additionalFieldValues).hasSize(1);
    final MiraklRequestAdditionalFieldValue additionalFieldValue = additionalFieldValues.get(0);
    assertThat(additionalFieldValue.getCode()).isEqualTo(HW_STAKEHOLDER_PROOF_IDENTITY_TYPE_1);
    assertThat(additionalFieldValue).isInstanceOf(MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue.class);
    assertThat(((MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) additionalFieldValue).getValue()).isEqualTo(Boolean.TRUE.toString());
}
Also used : KYCUserDocumentFlagsNotificationBodyModel(com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test)

Example 25 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.

the class KYCUserDocumentFlagProofIdentityBusinessStakeHolderStrategy method fillMiraklProofIdentityOrBusinessFlagStatus.

protected void fillMiraklProofIdentityOrBusinessFlagStatus(final KYCUserDocumentFlagsNotificationBodyModel source, final List<String> kycCustomValuesRequiredVerificationBusinessStakeholders) {
    if (CollectionUtils.isNotEmpty(kycCustomValuesRequiredVerificationBusinessStakeholders)) {
        final MiraklUpdateShop updateShop = new MiraklUpdateShop();
        final List<MiraklRequestAdditionalFieldValue> additionalFieldValues = kycCustomValuesRequiredVerificationBusinessStakeholders.stream().map(kycCustomValueRequiredVerification -> new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(kycCustomValueRequiredVerification, Boolean.TRUE.toString())).collect(Collectors.toList());
        updateShop.setShopId(Long.valueOf(source.getClientUserId()));
        updateShop.setAdditionalFieldValues(additionalFieldValues);
        try {
            log.info("Updating KYC proof of identity flag in Mirakl for business Stakeholder for shopId [{}]", source.getClientUserId());
            final MiraklUpdateShopsRequest miraklUpdateShopsRequest = new MiraklUpdateShopsRequest(List.of(updateShop));
            miraklMarketplacePlatformOperatorApiClient.updateShops(miraklUpdateShopsRequest);
            log.info("Proof of identity flag updated for business Stakeholder for shopId [{}]", source.getClientUserId());
        } catch (final MiraklException ex) {
            log.error("Something went wrong updating KYC business stakeholder information of shop [{}]. Details [{}]", source.getClientUserId(), ex.getMessage());
            mailNotificationUtil.sendPlainTextEmail("Issue detected updating KYC business stakeholder information in Mirakl", String.format(EMAIL_BODY_PREFIX + "Something went wrong updating KYC business stakeholder information for shop [%s]%n%s", source.getClientUserId(), MiraklLoggingErrorsUtil.stringify(ex)));
            // Rethrow exception to handle it in AbstractNotificationListener
            throw ex;
        }
    }
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) HyperwalletBusinessStakeholderExtractService(com.paypal.kyc.service.documents.files.hyperwallet.HyperwalletBusinessStakeholderExtractService) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklLoggingErrorsUtil(com.paypal.infrastructure.util.MiraklLoggingErrorsUtil) KYCUserDocumentFlagsNotificationBodyModel(com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel) Profile(org.springframework.context.annotation.Profile) Collectors(java.util.stream.Collectors) MailNotificationUtil(com.paypal.infrastructure.mail.MailNotificationUtil) CollectionUtils(org.apache.commons.collections4.CollectionUtils) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) MiraklBusinessStakeholderDocumentsExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentsExtractService) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) AbstractUserDocumentFlagsStrategy(com.paypal.kyc.strategies.documents.flags.AbstractUserDocumentFlagsStrategy) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklException(com.mirakl.client.core.exception.MiraklException) Service(org.springframework.stereotype.Service) MiraklMarketplacePlatformOperatorApiClient(com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient) MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)

Aggregations

MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)28 MiraklRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)20 Test (org.junit.jupiter.api.Test)16 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)15 MiraklSimpleRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue)9 MiraklException (com.mirakl.client.core.exception.MiraklException)6 MiraklUpdatedShops (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops)5 MiraklApiException (com.mirakl.client.core.exception.MiraklApiException)3 MiraklMarketplacePlatformOperatorApiClient (com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient)3 KYCUserDocumentFlagsNotificationBodyModel (com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel)3 Collectors (java.util.stream.Collectors)3 Slf4j (lombok.extern.slf4j.Slf4j)3 CollectionUtils (org.apache.commons.collections4.CollectionUtils)3 DisplayName (org.junit.jupiter.api.DisplayName)3 Service (org.springframework.stereotype.Service)3 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)2 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)2 MiraklUpdatedShopReturn (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn)2 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)2 MiraklLoggingErrorsUtil (com.paypal.infrastructure.util.MiraklLoggingErrorsUtil)2