use of com.mirakl.client.mmp.domain.shop.MiraklShop in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderDocumentsExtractServiceImpl method extractBusinessStakeholderDocuments.
/**
* {@inheritDoc}
*/
@Override
public List<KYCDocumentBusinessStakeHolderInfoModel> extractBusinessStakeholderDocuments(final Date delta) {
final MiraklGetShopsRequest miraklGetShopsRequest = miraklGetShopsRequestConverter.convert(delta);
log.info("Retrieving modified shops since [{}]", delta);
final MiraklShops shops = miraklOperatorClient.getShops(miraklGetShopsRequest);
// @formatter:off
log.info("Retrieved modified shops since [{}]: [{}]", delta, Stream.ofNullable(shops.getShops()).flatMap(Collection::stream).map(MiraklShop::getId).collect(Collectors.joining(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR)));
// @formatter:on
// @formatter:off
final List<KYCDocumentBusinessStakeHolderInfoModel> kycBusinessStakeHolderInfoModelList = Stream.ofNullable(shops.getShops()).flatMap(Collection::stream).map(this::populateBusinessStakeholderForMiraklShop).flatMap(Collection::stream).collect(Collectors.toList());
// @formatter:on
// @formatter:off
final Map<String, List<KYCDocumentBusinessStakeHolderInfoModel>> shopsWithBusinessStakeholderVerificationRequired = kycBusinessStakeHolderInfoModelList.stream().filter(kycDocStk -> kycDocStk.isRequiresKYC() || kycDocStk.isRequiresLetterOfAuthorization()).collect(Collectors.groupingBy(KYCDocumentInfoModel::getClientUserId));
if (!CollectionUtils.isEmpty(shopsWithBusinessStakeholderVerificationRequired)) {
// @formatter:off
log.info("Shops with KYC business stakeholder verification required: [{}]", String.join(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR, shopsWithBusinessStakeholderVerificationRequired.keySet()));
// @formatter:on
}
skipShopsWithNonBusinessStakeholderSelectedDocuments(shopsWithBusinessStakeholderVerificationRequired);
final List<KYCDocumentBusinessStakeHolderInfoModel> shopsWithBusinessSelectedVerificationDocuments = shopsWithBusinessStakeholderVerificationRequired.values().stream().filter(bstkList -> bstkList.stream().allMatch(KYCDocumentBusinessStakeHolderInfoModel::hasSelectedDocumentsControlFieldsInBusinessStakeholder)).flatMap(Collection::stream).collect(Collectors.toList());
// @formatter:off
return shopsWithBusinessSelectedVerificationDocuments.stream().filter(kycBusinessStakeHolderInfoModel -> !ObjectUtils.isEmpty(kycBusinessStakeHolderInfoModel.getUserToken())).map(miraklBusinessStakeholderDocumentDownloadExtractService::getBusinessStakeholderDocumentsSelectedBySeller).collect(Collectors.toList());
// @formatter:on
}
use of com.mirakl.client.mmp.domain.shop.MiraklShop 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.domain.shop.MiraklShop 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.domain.shop.MiraklShop in project mirakl-hyperwallet-connector by paypal.
the class MiraklShopToKYCDocumentBusinessStakeholderInfoModelConverterTest method createMiraklShop.
private MiraklShop createMiraklShop() {
final List<MiraklAdditionalFieldValue> additionalValues = List.of(new MiraklAdditionalFieldValue.MiraklBooleanAdditionalFieldValue(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_STAKEHOLDER_FIELD, Boolean.TRUE.toString()), new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN), new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(HYPERWALLET_BUSINESS_STAKEHOLDER_PROOF_OF_IDENTITY_COUNTRY_ISOCODE_FIELD, COUNTRY_ISO_CODE), new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(HYPERWALLET_BUSINESS_STAKEHOLDER_TOKEN_FIELD, BUSINESS_STAKEHOLDER_TOKEN), new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(HYPERWALLET_BUSINESS_STAKEHOLDER_PROOF_IDENTITY_TYPE_FIELD, GOVERNMENT_ID_DOC), new MiraklAdditionalFieldValue.MiraklBooleanAdditionalFieldValue(HW_STAKEHOLDER_BUSINESS_CONTACT_1, Boolean.TRUE.toString()), new MiraklAdditionalFieldValue.MiraklBooleanAdditionalFieldValue(HW_KYC_REQ_PROOF_AUTHORIZATION, Boolean.TRUE.toString()));
MiraklShop miraklShop = new MiraklShop();
miraklShop.setId(SHOP_ID);
miraklShop.setAdditionalFieldValues(additionalValues);
return miraklShop;
}
use of com.mirakl.client.mmp.domain.shop.MiraklShop in project mirakl-hyperwallet-connector by paypal.
the class MiraklShopToKYCDocumentBusinessStakeholderInfoModelConverterTest method convert_shouldConvertFromMiraklShopToKYCDocumentBusinessStakeHolderInfoModel.
@Test
void convert_shouldConvertFromMiraklShopToKYCDocumentBusinessStakeHolderInfoModel() {
final MiraklShop miraklShopStub = createMiraklShop();
final KYCDocumentBusinessStakeHolderInfoModel result = testObj.convert(miraklShopStub, BUSINESS_STAKEHOLDER_NUMBER);
assertThat(result.getClientUserId()).isEqualTo(SHOP_ID);
assertThat(result.getUserToken()).isEqualTo(USER_TOKEN);
assertThat(result.getCountryIsoCode()).isEqualTo(COUNTRY_ISO_CODE);
assertThat(result.getToken()).isEqualTo(BUSINESS_STAKEHOLDER_TOKEN);
assertThat(result.isRequiresKYC()).isTrue();
assertThat(result.getBusinessStakeholderMiraklNumber()).isEqualTo(BUSINESS_STAKEHOLDER_NUMBER);
assertThat(result.getProofOfIdentity()).isEqualTo(KYCProofOfIdentityEnum.GOVERNMENT_ID);
assertThat(result.isContact()).isTrue();
assertThat(result.isRequiresLetterOfAuthorization()).isTrue();
}
Aggregations