use of com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderDocumentsExtractServiceImpl method miraklUpdateKYCShopCall.
private Optional<MiraklUpdatedShops> miraklUpdateKYCShopCall(final Map<String, List<KYCDocumentBusinessStakeHolderInfoModel>> shopsToUpdate) {
if (CollectionUtils.isEmpty(shopsToUpdate)) {
return Optional.empty();
}
final List<MiraklUpdateShop> miraklShopsToUpdate = shopsToUpdate.entrySet().stream().map(this::getMiraklUpdateShopWithProofOfDocumentFields).collect(Collectors.toList());
final MiraklUpdateShopsRequest miraklUpdateShopRequest = new MiraklUpdateShopsRequest(miraklShopsToUpdate);
try {
final MiraklUpdatedShops miraklUpdatedShops = miraklOperatorClient.updateShops(miraklUpdateShopRequest);
// @formatter:on
log.info("Setting required KYC and letter of authorisation flag for shops with ids [{}] to false", miraklUpdatedShops.getShopReturns().stream().map(MiraklUpdatedShopReturn::getShopUpdated).map(MiraklShop::getId).collect(Collectors.joining(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR)));
return Optional.of(miraklUpdatedShops);
// @formatter:off
} catch (final MiraklException e) {
log.error("Something went wrong when removing flag to retrieve documents for shops [{}]", String.join(",", shopsToUpdate.keySet()));
kycMailNotificationUtil.sendPlainTextEmail("Issue setting push document flags to false in Mirakl", String.format("Something went wrong setting push document flag to false in Mirakl for shop Id [%s]%n%s", String.join(",", shopsToUpdate.keySet()), MiraklLoggingErrorsUtil.stringify(e)));
}
return Optional.empty();
}
use of com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops in project mirakl-hyperwallet-connector by paypal.
the class MiraklSellerDocumentsExtractServiceImpl method miraklUpdateShopCall.
private Optional<MiraklUpdatedShops> miraklUpdateShopCall(final List<String> shopIdList) {
if (CollectionUtils.isEmpty(shopIdList)) {
return Optional.empty();
}
final List<MiraklUpdateShop> shopsToUpdate = shopIdList.stream().map(Long::valueOf).map(shopId -> {
final MiraklUpdateShop miraklUpdateShop = new MiraklUpdateShop();
miraklUpdateShop.setShopId(shopId);
miraklUpdateShop.setAdditionalFieldValues(List.of(new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(KYCConstants.HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD, Boolean.FALSE.toString().toLowerCase())));
return miraklUpdateShop;
}).collect(Collectors.toList());
final MiraklUpdateShopsRequest miraklUpdateShopRequest = new MiraklUpdateShopsRequest(shopsToUpdate);
try {
final MiraklUpdatedShops miraklUpdatedShops = miraklOperatorClient.updateShops(miraklUpdateShopRequest);
// @formatter:on
log.info("Setting required KYC flag for shops with ids [{}] to false", miraklUpdatedShops.getShopReturns().stream().map(MiraklUpdatedShopReturn::getShopUpdated).map(MiraklShop::getId).collect(Collectors.joining(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR)));
return Optional.of(miraklUpdatedShops);
// @formatter:off
} catch (final MiraklException e) {
log.error("Something went wrong when removing flag to retrieve documents for shops [{}]", String.join(",", shopIdList));
kycMailNotificationUtil.sendPlainTextEmail("Issue setting push document flags to false in Mirakl", String.format("Something went wrong setting push document flag to false in Mirakl for shop Id [%s]%n%s", String.join(",", shopIdList), MiraklLoggingErrorsUtil.stringify(e)));
}
return Optional.empty();
}
use of com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops in project mirakl-hyperwallet-connector by paypal.
the class AbstractKYCUserStatusNotificationStrategy method updateShop.
protected void updateShop(final KYCUserStatusNotificationBodyModel kycUserStatusNotificationBodyModel) {
final MiraklShopKycStatus status = expectedKycMiraklStatus(kycUserStatusNotificationBodyModel);
if (Objects.nonNull(status)) {
final String shopId = kycUserStatusNotificationBodyModel.getClientUserId();
final MiraklUpdateShopsRequest request = createUpdateShopRequest(kycUserStatusNotificationBodyModel, status);
log.info("Updating KYC status for shop [{}]", shopId);
try {
final MiraklUpdatedShops response = miraklOperatorClient.updateShops(request);
if (response == null) {
log.error("No response was received for update request for shop [{}]", shopId);
} else {
final List<MiraklUpdatedShopReturn> shopReturns = response.getShopReturns();
shopReturns.forEach(this::logShopUpdates);
}
deleteInvalidDocuments(kycUserStatusNotificationBodyModel);
} catch (final MiraklException ex) {
final String errorMessage = String.format(MSG_ERROR_DETECTED, shopId, MiraklLoggingErrorsUtil.stringify(ex));
log.error(errorMessage);
mailNotificationUtil.sendPlainTextEmail(MAIL_SUBJECT, ERROR_MESSAGE_PREFIX + errorMessage);
// Rethrow exception to handle it in AbstractNotificationListener
throw ex;
}
}
}
use of com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderDocumentsExtractServiceImplTest method setBusinessStakeholderFlagKYCToPushBusinessStakeholderDocumentsToFalse_whenNoShopsAreNeededForUpdate_shouldDoNothing.
@Test
void setBusinessStakeholderFlagKYCToPushBusinessStakeholderDocumentsToFalse_whenNoShopsAreNeededForUpdate_shouldDoNothing() {
// @formatter:off
final KYCDocumentBusinessStakeHolderInfoModel kycUserOneBstOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId("2000").businessStakeholderMiraklNumber(1).sentToHyperwallet(Boolean.FALSE).build();
// @formatter:on
final Optional<MiraklUpdatedShops> result = testObj.setBusinessStakeholderFlagKYCToPushBusinessStakeholderDocumentsToFalse(Collections.singletonList(kycUserOneBstOne));
assertThat(result).isEmpty();
verifyNoInteractions(miraklMarketplacePlatformOperatorApiClientMock);
}
use of com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderDocumentsExtractServiceImplTest method setBusinessStakeholderFlagToPushBusinessStakeholderDocumentsToFalse_shouldCallMiraklWithTheClientUsersIdPassedAsParam.
@Test
void setBusinessStakeholderFlagToPushBusinessStakeholderDocumentsToFalse_shouldCallMiraklWithTheClientUsersIdPassedAsParam() {
// @formatter:off
final KYCDocumentBusinessStakeHolderInfoModel kycUserOneBstOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId("2000").businessStakeholderMiraklNumber(1).requiresKYC(Boolean.TRUE).sentToHyperwallet(Boolean.TRUE).build();
// @formatter:on
// @formatter:off
final KYCDocumentBusinessStakeHolderInfoModel kycUserTwoBstOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId("2001").businessStakeholderMiraklNumber(1).requiresKYC(Boolean.TRUE).sentToHyperwallet(Boolean.TRUE).build();
// @formatter:on
// @formatter:off
final KYCDocumentBusinessStakeHolderInfoModel kycUserThreeBstOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId("2002").businessStakeholderMiraklNumber(1).requiresKYC(Boolean.TRUE).sentToHyperwallet(Boolean.TRUE).requiresLetterOfAuthorization(Boolean.TRUE).build();
// @formatter:on
final List<KYCDocumentBusinessStakeHolderInfoModel> successfullyPushedDocumentsList = List.of(kycUserOneBstOne, kycUserThreeBstOne, kycUserTwoBstOne);
when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(any(MiraklUpdateShopsRequest.class))).thenReturn(miraklUpdateShopsMock);
final Optional<MiraklUpdatedShops> result = testObj.setBusinessStakeholderFlagKYCToPushBusinessStakeholderDocumentsToFalse(successfullyPushedDocumentsList);
verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopArgumentCaptor.capture());
final MiraklUpdateShopsRequest miraklUpdateShopRequest = miraklUpdateShopArgumentCaptor.getValue();
final List<Long> updatedSellerIdList = miraklUpdateShopRequest.getShops().stream().map(MiraklUpdateShop::getShopId).collect(Collectors.toList());
assertThat(updatedSellerIdList).containsExactlyInAnyOrder(2000L, 2001L, 2002L);
assertThat(getUpdatedFlagValuesForShop(miraklUpdateShopRequest, 2000L)).containsExactlyEntriesOf(Map.of(BUSINESS_STAKEHOLDER_PROOF_IDENTITY_CODE, "false"));
assertThat(getUpdatedFlagValuesForShop(miraklUpdateShopRequest, 2001L)).containsExactlyEntriesOf(Map.of(BUSINESS_STAKEHOLDER_PROOF_IDENTITY_CODE, "false"));
assertThat(getUpdatedFlagValuesForShop(miraklUpdateShopRequest, 2002L)).containsAllEntriesOf(Map.of(BUSINESS_STAKEHOLDER_PROOF_IDENTITY_CODE, "false", BUSINESS_STAKEHOLDER_PROOF_AUTH_CODE, "false"));
assertThat(result).hasValue(miraklUpdateShopsMock);
}
Aggregations