use of com.paypal.kyc.model.KYCDocumentSellerInfoModel 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
}
use of com.paypal.kyc.model.KYCDocumentSellerInfoModel in project mirakl-hyperwallet-connector by paypal.
the class MiraklShopToKYCDocumentSellerInfoModelConverterTest method convert_shouldConvertFromShopToKyCDocumentInfoModel.
@Test
void convert_shouldConvertFromShopToKyCDocumentInfoModel() {
final List<MiraklAdditionalFieldValue> additionalValues = List.of(new MiraklAdditionalFieldValue.MiraklBooleanAdditionalFieldValue(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD, Boolean.TRUE.toString()), new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN), new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(HYPERWALLET_KYC_IND_PROOF_OF_IDENTITY_FIELD, "GOVERNMENT_ID"), new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(HYPERWALLET_KYC_IND_PROOF_OF_ADDRESS_FIELD, "BANK_STATEMENT"), new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(HW_PROGRAM, "EUROPE"));
final MiraklShop miraklShopStub = new MiraklShop();
miraklShopStub.setProfessional(true);
miraklShopStub.setId(SHOP_ID);
miraklShopStub.setAdditionalFieldValues(additionalValues);
final KYCDocumentSellerInfoModel result = testObj.convert(miraklShopStub);
assertThat(result.getUserToken()).isEqualTo(USER_TOKEN);
assertThat(result.getClientUserId()).isEqualTo(SHOP_ID);
assertThat(result.getProofOfAddress()).isEqualTo(KYCProofOfAddressEnum.BANK_STATEMENT);
assertThat(result.getProofOfIdentity()).isEqualTo(KYCProofOfIdentityEnum.GOVERNMENT_ID);
assertThat(result.isRequiresKYC()).isTrue();
assertThat(result.isProfessional()).isTrue();
assertThat(result.getHyperwalletProgram()).isEqualTo(EUROPE_HYPERWALLET_PROGRAM);
}
Aggregations