use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.
the class MiraklBankAccountExtractServiceImpl method updateBankAccountToken.
/**
* {@inheritDoc}
*/
@Override
public void updateBankAccountToken(final SellerModel sellerModel, final HyperwalletBankAccount hyperwalletBankAccount) {
final MiraklUpdateShop miraklUpdateShop = new MiraklUpdateShop();
final String shopId = sellerModel.getClientUserId();
miraklUpdateShop.setShopId(Long.valueOf(shopId));
final MiraklSimpleRequestAdditionalFieldValue userTokenCustomField = new MiraklSimpleRequestAdditionalFieldValue();
userTokenCustomField.setCode(HYPERWALLET_BANK_ACCOUNT_TOKEN);
userTokenCustomField.setValue(hyperwalletBankAccount.getToken());
miraklUpdateShop.setAdditionalFieldValues(List.of(userTokenCustomField));
final MiraklUpdateShopsRequest request = new MiraklUpdateShopsRequest(List.of(miraklUpdateShop));
log.info("Updating bank account token for shop [{}]", shopId);
try {
miraklOperatorClient.updateShops(request);
log.info("Bank account token updated for shop [{}]", shopId);
} catch (final MiraklApiException ex) {
log.error("Something went wrong updating information of shop [{}]", shopId);
sellerMailNotificationUtil.sendPlainTextEmail("Issue detected updating bank token in Mirakl", String.format(ERROR_MESSAGE_PREFIX + "Something went wrong updating bank token of shop [%s]%n%s", shopId, MiraklLoggingErrorsUtil.stringify(ex)));
}
}
use of com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest 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.request.shop.MiraklUpdateShopsRequest 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.request.shop.MiraklUpdateShopsRequest 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.request.shop.MiraklUpdateShopsRequest in project mirakl-hyperwallet-connector by paypal.
the class AbstractKYCUserStatusNotificationStrategy method createUpdateShopRequest.
private MiraklUpdateShopsRequest createUpdateShopRequest(final KYCUserStatusNotificationBodyModel kycUserStatusNotificationBodyModel, final MiraklShopKycStatus status) {
final String shopId = kycUserStatusNotificationBodyModel.getClientUserId();
final MiraklUpdateShop miraklUpdateShop = new MiraklUpdateShop();
miraklUpdateShop.setShopId(Long.valueOf(shopId));
// @formatter:off
miraklUpdateShop.setKyc(new MiraklShopKyc(status, kycRejectionReasonService.getRejectionReasonDescriptions(kycUserStatusNotificationBodyModel.getReasonsType())));
if (isKycAutomated()) {
final List<MiraklRequestAdditionalFieldValue> additionalFieldValues = new ArrayList<>();
if (HyperwalletUser.VerificationStatus.REQUIRED.equals(kycUserStatusNotificationBodyModel.getVerificationStatus())) {
final MiraklSimpleRequestAdditionalFieldValue kycVerificationStatusCustomField = new MiraklSimpleRequestAdditionalFieldValue();
kycVerificationStatusCustomField.setCode(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD);
kycVerificationStatusCustomField.setValue(Boolean.TRUE.toString());
additionalFieldValues.add(kycVerificationStatusCustomField);
}
if (HyperwalletUser.LetterOfAuthorizationStatus.REQUIRED.equals(kycUserStatusNotificationBodyModel.getLetterOfAuthorizationStatus())) {
final MiraklSimpleRequestAdditionalFieldValue kycLetterOfAuthorizationStatusCustomField = new MiraklSimpleRequestAdditionalFieldValue();
kycLetterOfAuthorizationStatusCustomField.setCode(HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD);
kycLetterOfAuthorizationStatusCustomField.setValue(Boolean.TRUE.toString());
additionalFieldValues.add(kycLetterOfAuthorizationStatusCustomField);
}
if (!CollectionUtils.isEmpty(additionalFieldValues)) {
miraklUpdateShop.setAdditionalFieldValues(additionalFieldValues);
}
}
return new MiraklUpdateShopsRequest(List.of(miraklUpdateShop));
}
Aggregations