Search in sources :

Example 26 with MiraklUpdateShopsRequest

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

Example 27 with MiraklUpdateShopsRequest

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

the class MiraklSellersExtractServiceImplCustomFieldsTest method updateUserToken_shouldUpdateValueForCustomFieldHwUserToken.

@DisplayName("Should Update Value for Custom Field 'hw-user-token'")
@Test
void updateUserToken_shouldUpdateValueForCustomFieldHwUserToken() {
    when(hyperwalletUserMock.getToken()).thenReturn(TOKEN_VALUE);
    when(hyperwalletUserMock.getClientUserId()).thenReturn("12345");
    testObj.updateUserToken(hyperwalletUserMock);
    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-user-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 28 with MiraklUpdateShopsRequest

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

the class MiraklSellersExtractServiceImpl method updateUserToken.

/**
 * {@inheritDoc}
 */
@Override
public void updateUserToken(final HyperwalletUser hyperwalletUser) {
    final MiraklUpdateShop miraklUpdateShop = new MiraklUpdateShop();
    final String shopId = hyperwalletUser.getClientUserId();
    miraklUpdateShop.setShopId(Long.valueOf(shopId));
    final MiraklSimpleRequestAdditionalFieldValue userTokenCustomField = new MiraklSimpleRequestAdditionalFieldValue();
    userTokenCustomField.setCode(HYPERWALLET_USER_TOKEN);
    userTokenCustomField.setValue(hyperwalletUser.getToken());
    miraklUpdateShop.setAdditionalFieldValues(List.of(userTokenCustomField));
    final MiraklUpdateShopsRequest request = new MiraklUpdateShopsRequest(List.of(miraklUpdateShop));
    log.info("Updating token for shop [{}] to [{}]", shopId, hyperwalletUser.getToken());
    try {
        miraklOperatorClient.updateShops(request);
    } catch (final MiraklApiException ex) {
        log.error("Something went wrong getting information of shop [{}]", shopId);
        sellerMailNotificationUtil.sendPlainTextEmail(EMAIL_SUBJECT_MESSAGE, String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting information of shop [%s]%n%s", shopId, 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) MiraklSimpleRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue)

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