use of com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest 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.request.shop.MiraklGetShopsRequest in project mirakl-hyperwallet-connector by paypal.
the class DateToMiraklGetShopsRequestConverterTest method convert_shouldConvertFromDateToMiraklGetShopRequestWhenDateIsNotNullAndEnsurePaginatedIsFalse.
@Test
void convert_shouldConvertFromDateToMiraklGetShopRequestWhenDateIsNotNullAndEnsurePaginatedIsFalse() {
final Date date = new Date();
final MiraklGetShopsRequest result = testObj.convert(date);
assertThat(result.getUpdatedSince()).isEqualTo(date);
assertThat(result.isPaginate()).isFalse();
}
use of com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest in project mirakl-hyperwallet-connector by paypal.
the class MiraklCreditNotesExtractServiceImplTest method createShopRequest_shouldCreateShopRequestWithGivenIds.
@Test
void createShopRequest_shouldCreateShopRequestWithGivenIds() {
final Set<String> shopIds = Set.of(SHOP_ID_ONE, SHOP_ID_TWO);
final MiraklGetShopsRequest result = testObj.createShopRequest(shopIds);
assertThat(result.getShopIds()).isEqualTo(shopIds);
assertThat(result.isPaginate()).isFalse();
}
use of com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest in project mirakl-hyperwallet-connector by paypal.
the class MiraklInvoicesExtractServiceImplTest method createShopRequest_shouldCreateShopRequestWithGivenIds.
@Test
void createShopRequest_shouldCreateShopRequestWithGivenIds() {
final Set<String> shopIds = Set.of(SHOP_ID_ONE, SHOP_ID_TWO);
final MiraklGetShopsRequest result = testObj.createShopRequest(shopIds);
assertThat(result.getShopIds()).isEqualTo(shopIds);
assertThat(result.isPaginate()).isFalse();
}
use of com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderDocumentsExtractServiceImpl method extractMiraklShop.
private Optional<MiraklShop> extractMiraklShop(final String shopId) {
final MiraklGetShopsRequest miraklGetShopsRequest = new MiraklGetShopsRequest();
miraklGetShopsRequest.setShopIds(List.of(shopId));
log.info("Retrieving shopId [{}]", shopId);
final MiraklShops shops = miraklOperatorClient.getShops(miraklGetShopsRequest);
return Optional.ofNullable(shops).orElse(new MiraklShops()).getShops().stream().filter(shop -> shopId.equals(shop.getId())).findAny();
}
Aggregations