use of com.mirakl.client.mmp.domain.shop.MiraklShop in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderDocumentsExtractServiceImplTest method getKYCCustomValuesRequiredVerificationBusinessStakeholders_whenShopHasNoCustomValues_shouldReturnEmptyList.
@Test
void getKYCCustomValuesRequiredVerificationBusinessStakeholders_whenShopHasNoCustomValues_shouldReturnEmptyList() {
final MiraklShop miraklShopStub = new MiraklShop();
miraklShopStub.setId(SHOP_ID);
when(miraklMarketplacePlatformOperatorApiClientMock.getShops(Mockito.any(MiraklGetShopsRequest.class))).thenReturn(miraklShopsMock);
when(miraklShopsMock.getShops()).thenReturn(List.of(miraklShopStub));
final List<String> businessStakeholderToken = List.of(BUSINESS_STAKEHOLDER_TOKEN);
final List<String> result = testObj.getKYCCustomValuesRequiredVerificationBusinessStakeholders(SHOP_ID, businessStakeholderToken);
assertThat(result).isEmpty();
}
use of com.mirakl.client.mmp.domain.shop.MiraklShop in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderDocumentsExtractServiceImplTest method getKYCCustomValuesRequiredVerificationBusinessStakeholders_shouldReturnListOfCode.
@Test
void getKYCCustomValuesRequiredVerificationBusinessStakeholders_shouldReturnListOfCode() {
final MiraklShop miraklShopStub = new MiraklShop();
miraklShopStub.setId(SHOP_ID);
miraklShopStub.setAdditionalFieldValues(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(BUSINESS_STAKEHOLDER_CODE, BUSINESS_STAKEHOLDER_TOKEN)));
when(miraklMarketplacePlatformOperatorApiClientMock.getShops(Mockito.any(MiraklGetShopsRequest.class))).thenReturn(miraklShopsMock);
when(miraklShopsMock.getShops()).thenReturn(List.of(miraklShopStub));
final List<String> businessStakeholderToken = List.of(BUSINESS_STAKEHOLDER_TOKEN);
final List<String> result = testObj.getKYCCustomValuesRequiredVerificationBusinessStakeholders(SHOP_ID, businessStakeholderToken);
assertThat(result).containsExactly(BUSINESS_STAKEHOLDER_PROOF_IDENTITY_CODE);
}
use of com.mirakl.client.mmp.domain.shop.MiraklShop 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();
}
use of com.mirakl.client.mmp.domain.shop.MiraklShop in project mirakl-hyperwallet-connector by paypal.
the class MiraklSellerDocumentsExtractServiceImpl method extractMiraklShop.
protected 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();
}
use of com.mirakl.client.mmp.domain.shop.MiraklShop in project mirakl-hyperwallet-connector by paypal.
the class MiraklSellerDocumentsExtractServiceImpl method extractProofOfIdentityAndBusinessSellerDocuments.
/**
* {@inheritDoc}
*/
@Override
public List<KYCDocumentSellerInfoModel> extractProofOfIdentityAndBusinessSellerDocuments(final Date delta) {
final MiraklGetShopsRequest miraklGetShopsRequest = miraklGetShopsRequestConverter.convert(delta);
log.info("Retrieving modified shops for proof of identity/business sellers documents 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<KYCDocumentSellerInfoModel> kycDocumentInfoList = Stream.ofNullable(shops.getShops()).flatMap(Collection::stream).map(miraklShopKYCDocumentInfoModelConverter::convert).collect(Collectors.toList());
// @formatter:on
// @formatter:off
final Map<Boolean, List<KYCDocumentSellerInfoModel>> documentGroups = kycDocumentInfoList.stream().collect(Collectors.groupingBy(KYCDocumentSellerInfoModel::isRequiresKYC));
// @formatter:on
final Collection<KYCDocumentSellerInfoModel> docsFromShopsWithVerificationRequired = CollectionUtils.emptyIfNull(documentGroups.get(true));
final Collection<KYCDocumentSellerInfoModel> docsFromShopsWithoutVerificationRequired = CollectionUtils.emptyIfNull(documentGroups.get(false));
if (!CollectionUtils.isEmpty(docsFromShopsWithVerificationRequired)) {
// @formatter:off
log.info("Shops with KYC seller verification required: [{}]", docsFromShopsWithVerificationRequired.stream().map(KYCDocumentSellerInfoModel::getClientUserId).collect(Collectors.joining(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR)));
// @formatter:on
}
if (!CollectionUtils.isEmpty(docsFromShopsWithoutVerificationRequired)) {
// @formatter:off
log.info("Shops without KYC seller verification required: [{}]", docsFromShopsWithoutVerificationRequired.stream().map(KYCDocumentSellerInfoModel::getClientUserId).collect(Collectors.joining(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR)));
// @formatter:on
}
skipShopsWithNonSelectedDocuments(docsFromShopsWithVerificationRequired);
// @formatter:off
final List<KYCDocumentSellerInfoModel> shopsWithSelectedVerificationDocuments = docsFromShopsWithVerificationRequired.stream().filter(KYCDocumentSellerInfoModel::hasSelectedDocumentControlFields).collect(Collectors.toList());
// @formatter:off
return shopsWithSelectedVerificationDocuments.stream().filter(kycDocumentInfoModel -> !ObjectUtils.isEmpty(kycDocumentInfoModel.getUserToken())).map(miraklSellerDocumentDownloadExtractService::getDocumentsSelectedBySeller).collect(Collectors.toList());
// @formatter:on
}
Aggregations