Search in sources :

Example 6 with MiraklUpdateShopsRequest

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

the class BusinessKYCUserLOAStatusNotificationStrategy method updateMiraklLOAStatus.

protected void updateMiraklLOAStatus(final String miraklShopId, final HyperwalletUser.LetterOfAuthorizationStatus letterOfAuthorizationStatus) {
    final MiraklUpdateShop updateShop = new MiraklUpdateShop();
    final String isLetterOfAuthorizationRequired = Boolean.toString(isLetterOfAuthorizationRequired(letterOfAuthorizationStatus));
    final MiraklSimpleRequestAdditionalFieldValue miraklSimpleRequestAdditionalFieldValue = new MiraklSimpleRequestAdditionalFieldValue(KYCConstants.HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD, isLetterOfAuthorizationRequired);
    updateShop.setShopId(Long.valueOf(miraklShopId));
    updateShop.setAdditionalFieldValues(List.of(miraklSimpleRequestAdditionalFieldValue));
    log.info("Updating KYC Letter of authorization flag in Mirakl for business Stakeholder for shopId [{}]", miraklShopId);
    final MiraklUpdateShopsRequest miraklUpdateShopsRequest = new MiraklUpdateShopsRequest(List.of(updateShop));
    miraklMarketplacePlatformOperatorApiClient.updateShops(miraklUpdateShopsRequest);
    log.info("Letter of authorization flag updated to '{}', for business Stakeholder in shopId [{}]", isLetterOfAuthorizationRequired, miraklShopId);
}
Also used : MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklSimpleRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue)

Example 7 with MiraklUpdateShopsRequest

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

the class AbstractUserDocumentFlagsStrategy method fillMiraklProofIdentityOrBusinessFlagStatus.

protected void fillMiraklProofIdentityOrBusinessFlagStatus(final KYCUserDocumentFlagsNotificationBodyModel source) {
    final MiraklUpdateShop updateShop = new MiraklUpdateShop();
    final MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue additionalValue = new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(KYCConstants.HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD, Boolean.TRUE.toString());
    updateShop.setShopId(Long.valueOf(source.getClientUserId()));
    updateShop.setAdditionalFieldValues(List.of(additionalValue));
    try {
        log.info("Updating KYC proof of identity flag in Mirakl for shopId [{}]", source.getClientUserId());
        final MiraklUpdateShopsRequest miraklUpdateShopsRequest = new MiraklUpdateShopsRequest(List.of(updateShop));
        miraklMarketplacePlatformOperatorApiClient.updateShops(miraklUpdateShopsRequest);
        log.info("Proof of identity flag updated for shopId [{}]", source.getClientUserId());
    } catch (final MiraklException ex) {
        log.error("Something went wrong updating KYC information of shop [{}]. Details [{}]", source.getClientUserId(), ex.getMessage());
        mailNotificationUtil.sendPlainTextEmail("Issue detected updating KYC information in Mirakl", String.format(EMAIL_BODY_PREFIX + "Something went wrong updating KYC information of shop [%s]%n%s", source.getClientUserId(), MiraklLoggingErrorsUtil.stringify(ex)));
        // Rethrow exception to handle it in AbstractNotificationListener
        throw ex;
    }
}
Also used : 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 8 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest 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 9 with MiraklUpdateShopsRequest

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

the class MiraklBusinessStakeholderExtractServiceImpl method updateBusinessStakeholderToken.

@Override
public void updateBusinessStakeholderToken(final String clientUserId, final List<BusinessStakeHolderModel> businessStakeHolderModels) {
    if (CollectionUtils.isEmpty(businessStakeHolderModels)) {
        log.info("No data for business stakeholders on store [{}]", clientUserId);
        return;
    }
    final MiraklUpdateShop miraklUpdateShop = createMiraklUpdateFieldRequestForStakeholders(clientUserId, businessStakeHolderModels);
    final MiraklUpdateShopsRequest request = new MiraklUpdateShopsRequest(List.of(miraklUpdateShop));
    try {
        miraklOperatorClient.updateShops(request);
    } catch (final MiraklApiException ex) {
        log.error("Something went wrong getting information of shop [{}]", clientUserId);
        sellerMailNotificationUtil.sendPlainTextEmail(EMAIL_SUBJECT_MESSAGE, String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting information of shop [%s]%n%s", clientUserId, MiraklLoggingErrorsUtil.stringify(ex)));
    }
}
Also used : MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklApiException(com.mirakl.client.core.exception.MiraklApiException) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)

Example 10 with MiraklUpdateShopsRequest

use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest 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)

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