Search in sources :

Example 11 with MiraklRequestAdditionalFieldValue

use of com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue 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 12 with MiraklRequestAdditionalFieldValue

use of com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue 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 13 with MiraklRequestAdditionalFieldValue

use of com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue 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 14 with MiraklRequestAdditionalFieldValue

use of com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue 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)

Example 15 with MiraklRequestAdditionalFieldValue

use of com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue in project mirakl-hyperwallet-connector by paypal.

the class IndividualKYCBusinessStakeholderStatusNotificationStrategy method updateMiraklProofIdentityFlagStatus.

protected void updateMiraklProofIdentityFlagStatus(final String miraklShopId, final String kycCustomValuesRequiredVerificationBusinessStakeholder, final HyperwalletUser.VerificationStatus verificationStatus) {
    if (StringUtils.nonEmptyString(kycCustomValuesRequiredVerificationBusinessStakeholder)) {
        final MiraklUpdateShop updateShop = new MiraklUpdateShop();
        final List<MiraklRequestAdditionalFieldValue> additionalFieldValues = Optional.of(kycCustomValuesRequiredVerificationBusinessStakeholder).stream().map(kycCustomValueRequiredVerification -> new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(kycCustomValueRequiredVerification, Boolean.toString(HyperwalletUser.VerificationStatus.REQUIRED.equals(verificationStatus)))).collect(Collectors.toList());
        updateShop.setShopId(Long.valueOf(miraklShopId));
        updateShop.setAdditionalFieldValues(additionalFieldValues);
        log.info("Updating KYC proof of identity flag in Mirakl for business Stakeholder for shopId [{}]", miraklShopId);
        final MiraklUpdateShopsRequest miraklUpdateShopsRequest = new MiraklUpdateShopsRequest(List.of(updateShop));
        miraklMarketplacePlatformOperatorApiClient.updateShops(miraklUpdateShopsRequest);
        log.info("Proof of identity flag updated for business Stakeholder for shopId [{}]", miraklShopId);
    }
}
Also used : KYCConstants(com.paypal.kyc.model.KYCConstants) KYCBusinessStakeholderStatusNotificationBodyModel(com.paypal.kyc.model.KYCBusinessStakeholderStatusNotificationBodyModel) HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) Collectors(java.util.stream.Collectors) CollectionUtils(org.apache.commons.collections4.CollectionUtils) KYCHyperwalletApiConfig(com.paypal.kyc.infrastructure.configuration.KYCHyperwalletApiConfig) Objects(java.util.Objects) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) HyperwalletSDKService(com.paypal.kyc.service.HyperwalletSDKService) MiraklBusinessStakeholderDocumentsExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentsExtractService) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) Service(org.springframework.stereotype.Service) Optional(java.util.Optional) StringUtils(com.mchange.v2.lang.StringUtils) MiraklMarketplacePlatformOperatorApiClient(com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient) 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)16 MiraklRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)16 Test (org.junit.jupiter.api.Test)12 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)9 MiraklSimpleRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue)6 MiraklException (com.mirakl.client.core.exception.MiraklException)3 MiraklMarketplacePlatformOperatorApiClient (com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient)3 KYCUserDocumentFlagsNotificationBodyModel (com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel)3 MiraklBusinessStakeholderDocumentsExtractService (com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentsExtractService)3 Collectors (java.util.stream.Collectors)3 Slf4j (lombok.extern.slf4j.Slf4j)3 DisplayName (org.junit.jupiter.api.DisplayName)3 Service (org.springframework.stereotype.Service)3 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)2 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)2 MiraklLoggingErrorsUtil (com.paypal.infrastructure.util.MiraklLoggingErrorsUtil)2 KYCConstants (com.paypal.kyc.model.KYCConstants)2 List (java.util.List)2 CollectionUtils (org.apache.commons.collections4.CollectionUtils)2 StringUtils (com.mchange.v2.lang.StringUtils)1