Search in sources :

Example 1 with MiraklRequestAdditionalFieldValue

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

the class MiraklBusinessStakeholderDocumentsExtractServiceImpl method getMiraklUpdateShopWithProofOfDocumentFields.

private MiraklUpdateShop getMiraklUpdateShopWithProofOfDocumentFields(final Map.Entry<String, List<KYCDocumentBusinessStakeHolderInfoModel>> entry) {
    final MiraklUpdateShop miraklUpdateShop = new MiraklUpdateShop();
    miraklUpdateShop.setShopId(Long.valueOf(entry.getKey()));
    // @formatter:off
    final List<MiraklRequestAdditionalFieldValue> additionalValues = entry.getValue().stream().filter(KYCDocumentBusinessStakeHolderInfoModel::isRequiresKYC).map(businessStakeholder -> new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(HYPERWALLET_PREFIX + STAKEHOLDER_PREFIX + REQUIRED_PROOF_IDENTITY + businessStakeholder.getBusinessStakeholderMiraklNumber(), Boolean.FALSE.toString().toLowerCase())).collect(Collectors.toList());
    additionalValues.addAll(entry.getValue().stream().filter(KYCDocumentBusinessStakeHolderInfoModel::isRequiresLetterOfAuthorization).map(businessStakeholder -> new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD, Boolean.FALSE.toString().toLowerCase())).collect(Collectors.toList()));
    // @formatter:on
    miraklUpdateShop.setAdditionalFieldValues(additionalValues);
    return miraklUpdateShop;
}
Also used : IntStream(java.util.stream.IntStream) 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) KYCBusinessStakeHolderConverter(com.paypal.kyc.converter.KYCBusinessStakeHolderConverter) 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) KYCConstants(com.paypal.kyc.model.KYCConstants) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) 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) AbstractMiraklShop(com.mirakl.client.mmp.domain.shop.AbstractMiraklShop) MiraklLoggingErrorsUtil(com.paypal.infrastructure.util.MiraklLoggingErrorsUtil) Collectors(java.util.stream.Collectors) MailNotificationUtil(com.paypal.infrastructure.mail.MailNotificationUtil) MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) MiraklUpdatedShopReturn(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) MiraklBusinessStakeholderDocumentsExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentsExtractService) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) MiraklShop(com.mirakl.client.mmp.domain.shop.MiraklShop) LoggingConstantsUtil(com.paypal.infrastructure.util.LoggingConstantsUtil) CollectionUtils(org.springframework.util.CollectionUtils) MiraklBusinessStakeholderDocumentDownloadExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentDownloadExtractService) KYCDocumentInfoModel(com.paypal.kyc.model.KYCDocumentInfoModel) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)

Example 2 with MiraklRequestAdditionalFieldValue

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

the class AbstractKYCUserStatusNotificationStrategy method createUpdateShopRequest.

private MiraklUpdateShopsRequest createUpdateShopRequest(final KYCUserStatusNotificationBodyModel kycUserStatusNotificationBodyModel, final MiraklShopKycStatus status) {
    final String shopId = kycUserStatusNotificationBodyModel.getClientUserId();
    final MiraklUpdateShop miraklUpdateShop = new MiraklUpdateShop();
    miraklUpdateShop.setShopId(Long.valueOf(shopId));
    // @formatter:off
    miraklUpdateShop.setKyc(new MiraklShopKyc(status, kycRejectionReasonService.getRejectionReasonDescriptions(kycUserStatusNotificationBodyModel.getReasonsType())));
    if (isKycAutomated()) {
        final List<MiraklRequestAdditionalFieldValue> additionalFieldValues = new ArrayList<>();
        if (HyperwalletUser.VerificationStatus.REQUIRED.equals(kycUserStatusNotificationBodyModel.getVerificationStatus())) {
            final MiraklSimpleRequestAdditionalFieldValue kycVerificationStatusCustomField = new MiraklSimpleRequestAdditionalFieldValue();
            kycVerificationStatusCustomField.setCode(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD);
            kycVerificationStatusCustomField.setValue(Boolean.TRUE.toString());
            additionalFieldValues.add(kycVerificationStatusCustomField);
        }
        if (HyperwalletUser.LetterOfAuthorizationStatus.REQUIRED.equals(kycUserStatusNotificationBodyModel.getLetterOfAuthorizationStatus())) {
            final MiraklSimpleRequestAdditionalFieldValue kycLetterOfAuthorizationStatusCustomField = new MiraklSimpleRequestAdditionalFieldValue();
            kycLetterOfAuthorizationStatusCustomField.setCode(HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD);
            kycLetterOfAuthorizationStatusCustomField.setValue(Boolean.TRUE.toString());
            additionalFieldValues.add(kycLetterOfAuthorizationStatusCustomField);
        }
        if (!CollectionUtils.isEmpty(additionalFieldValues)) {
            miraklUpdateShop.setAdditionalFieldValues(additionalFieldValues);
        }
    }
    return new MiraklUpdateShopsRequest(List.of(miraklUpdateShop));
}
Also used : MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklShopKyc(com.mirakl.client.mmp.domain.shop.MiraklShopKyc) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) MiraklSimpleRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue)

Example 3 with MiraklRequestAdditionalFieldValue

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

the class MiraklBusinessStakeholderExtractServiceImplTest method updateBusinessStakeholderToken_shouldUpdateValueForCustomFieldHwUserToken.

@DisplayName("Should Update Value for Custom Field 'hw-user-token'")
@Test
void updateBusinessStakeholderToken_shouldUpdateValueForCustomFieldHwUserToken() {
    when(sellerModelMock.getBusinessStakeHolderDetails()).thenReturn(List.of(businessStakeHolderModelMock));
    when(sellerModelMock.getClientUserId()).thenReturn("12345");
    when(businessStakeHolderModelMock.getToken()).thenReturn(BUSINESS_STAKE_HOLDER_TOKEN);
    when(businessStakeHolderModelMock.getStkId()).thenReturn(1);
    testObj.updateBusinessStakeholderToken(sellerModelMock.getClientUserId(), sellerModelMock.getBusinessStakeHolderDetails());
    verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopsRequestCaptor.capture());
    final MiraklUpdateShopsRequest miraklUpdateShopsRequest = miraklUpdateShopsRequestCaptor.getValue();
    assertThat(miraklUpdateShopsRequest.getShops()).hasSize(1);
    final MiraklUpdateShop shopToUpdate = miraklUpdateShopsRequest.getShops().get(0);
    assertThat(shopToUpdate).hasFieldOrPropertyWithValue("shopId", 12345L);
    assertThat(shopToUpdate.getAdditionalFieldValues()).hasSize(1);
    final MiraklRequestAdditionalFieldValue additionalFieldValue = shopToUpdate.getAdditionalFieldValues().get(0);
    assertThat(additionalFieldValue).isInstanceOf(MiraklSimpleRequestAdditionalFieldValue.class);
    final MiraklSimpleRequestAdditionalFieldValue castedAdditionalFieldValue = (MiraklSimpleRequestAdditionalFieldValue) additionalFieldValue;
    assertThat(castedAdditionalFieldValue.getCode()).isEqualTo("hw-stakeholder-token-1");
    assertThat(castedAdditionalFieldValue.getValue()).isEqualTo(BUSINESS_STAKE_HOLDER_TOKEN);
}
Also used : 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) MiraklSimpleRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with MiraklRequestAdditionalFieldValue

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

the class MiraklBankAccountExtractServiceImplTest method updateBankAccountToken_shouldUpdateValueForCustomFieldHwBankAccountToken.

@DisplayName("Should Update Value for Custom Field 'hw-bankaccount-token'")
@Test
void updateBankAccountToken_shouldUpdateValueForCustomFieldHwBankAccountToken() {
    when(hyperwalletBankAccount.getToken()).thenReturn(TOKEN_VALUE);
    when(sellerModelMock.getClientUserId()).thenReturn("12345");
    testObj.updateBankAccountToken(sellerModelMock, hyperwalletBankAccount);
    verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopsRequestCaptor.capture());
    final MiraklUpdateShopsRequest miraklUpdateShopsRequest = miraklUpdateShopsRequestCaptor.getValue();
    assertThat(miraklUpdateShopsRequest.getShops()).hasSize(1);
    final MiraklUpdateShop shopToUpdate = miraklUpdateShopsRequest.getShops().get(0);
    assertThat(shopToUpdate).hasFieldOrPropertyWithValue("shopId", 12345L);
    assertThat(shopToUpdate.getAdditionalFieldValues()).hasSize(1);
    final MiraklRequestAdditionalFieldValue additionalFieldValue = shopToUpdate.getAdditionalFieldValues().get(0);
    assertThat(additionalFieldValue).isInstanceOf(MiraklSimpleRequestAdditionalFieldValue.class);
    final MiraklSimpleRequestAdditionalFieldValue castedAdditionalFieldValue = (MiraklSimpleRequestAdditionalFieldValue) additionalFieldValue;
    assertThat(castedAdditionalFieldValue.getCode()).isEqualTo("hw-bankaccount-token");
    assertThat(castedAdditionalFieldValue.getValue()).isEqualTo(TOKEN_VALUE);
}
Also used : 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) MiraklSimpleRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with MiraklRequestAdditionalFieldValue

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

the class AbstractKYCUserStatusExecutorNotificationStrategyTest method updateShop_shouldCallMiraklApiWithValuesProvidedModifyingKYCVerificationStatus.

@Test
void updateShop_shouldCallMiraklApiWithValuesProvidedModifyingKYCVerificationStatus() {
    when(testObj.isKycAutomated()).thenReturn(true);
    when(kycUserStatusNotificationBodyModelMock.getClientUserId()).thenReturn(SHOP_ID);
    when(kycUserStatusNotificationBodyModelMock.getVerificationStatus()).thenReturn(HyperwalletUser.VerificationStatus.REQUIRED);
    when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(any(MiraklUpdateShopsRequest.class))).thenReturn(miraklUpdatedShopResponseMock);
    when(testObj.expectedKycMiraklStatus(kycUserStatusNotificationBodyModelMock)).thenReturn(MiraklShopKycStatus.REFUSED);
    testObj.updateShop(kycUserStatusNotificationBodyModelMock);
    verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopMockArgumentCaptor.capture());
    final MiraklUpdateShopsRequest request = miraklUpdateShopMockArgumentCaptor.getValue();
    assertThat(request.getShops()).hasSize(1);
    assertThat(request.getShops().get(0).getShopId()).isEqualTo(Long.valueOf(SHOP_ID));
    assertThat(request.getShops().get(0).getKyc().getStatus()).isEqualTo(MiraklShopKycStatus.REFUSED);
    final MiraklRequestAdditionalFieldValue additionalFieldValue = request.getShops().get(0).getAdditionalFieldValues().get(0);
    final MiraklSimpleRequestAdditionalFieldValue castedAdditionalFieldValue = (MiraklSimpleRequestAdditionalFieldValue) additionalFieldValue;
    assertThat(castedAdditionalFieldValue.getCode()).isEqualTo(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD);
    assertThat(castedAdditionalFieldValue.getValue()).isEqualTo("true");
}
Also used : MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) MiraklSimpleRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue) Test(org.junit.jupiter.api.Test)

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