use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.
the class KYCBusinessStakeholderNotificationServiceImplTest method exceptionAndExpectedMessage.
private static Stream<Arguments> exceptionAndExpectedMessage() {
final HyperwalletException hyperwalletException = new HyperwalletException(MSG_EXCEPTION);
final MiraklException miraklException = new MiraklException(MSG_EXCEPTION);
return Stream.of(Arguments.of(new RuntimeException(MSG_EXCEPTION), MSG_EXCEPTION), Arguments.of(hyperwalletException, HyperwalletLoggingErrorsUtil.stringify(hyperwalletException)), Arguments.of(miraklException, MiraklLoggingErrorsUtil.stringify(miraklException)));
}
use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.
the class KYCUserDocumentFlagProofIdentityBusinessStakeHolderStrategyTest method execute_whenAPICallThrowsException_shouldLog_andSendMailNotifyingError_andThrowException.
@Test
void execute_whenAPICallThrowsException_shouldLog_andSendMailNotifyingError_andThrowException() {
// @formatter:off
final KYCUserDocumentFlagsNotificationBodyModel kycUserDocumentFlagsNotificationBodyModel = KYCUserDocumentFlagsNotificationBodyModel.builder().hyperwalletProgram(HYPERWALLET_PROGRAM).userToken(USER_TOKEN).clientUserId(SHOP_ID).profileType(HyperwalletUser.ProfileType.BUSINESS).businessStakeholderVerificationStatus(HyperwalletUser.BusinessStakeholderVerificationStatus.REQUIRED).build();
// @formatter:on
when(hyperwalletBusinessStakeholderExtractServiceMock.getKYCRequiredVerificationBusinessStakeHolders(HYPERWALLET_PROGRAM, USER_TOKEN)).thenReturn(List.of(BUSINESS_STAKE_HOLDER_TOKEN));
when(miraklBusinessStakeholderDocumentsExtractServiceMock.getKYCCustomValuesRequiredVerificationBusinessStakeholders(SHOP_ID, List.of(BUSINESS_STAKE_HOLDER_TOKEN))).thenReturn(List.of(HW_STAKEHOLDER_PROOF_IDENTITY_TYPE_1));
final MiraklException miraklException = new MiraklException("An error has occurred");
when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(any())).thenThrow(miraklException);
final Throwable throwable = catchThrowable(() -> testObj.execute(kycUserDocumentFlagsNotificationBodyModel));
assertThat(throwable).isEqualTo(miraklException);
assertThat(LOG_TRACKER_STUB.contains(String.format(MSG_ERROR, SHOP_ID, miraklException.getMessage()))).isTrue();
verify(mailNotificationUtilMock).sendPlainTextEmail("Issue detected updating KYC business stakeholder information in Mirakl", String.format(EMAIL_BODY_PREFIX + "Something went wrong updating KYC business stakeholder information for shop [%s]%n%s", SHOP_ID, MiraklLoggingErrorsUtil.stringify(miraklException)));
}
use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImpl method populateMiraklShopBusinessStakeholderDocuments.
protected KYCDocumentBusinessStakeHolderInfoModel populateMiraklShopBusinessStakeholderDocuments(final KYCDocumentBusinessStakeHolderInfoModel kycBusinessStakeHolderInfoModel) {
final MiraklGetShopDocumentsRequest getShopBusinessStakeholderDocumentsRequest = new MiraklGetShopDocumentsRequest(List.of(kycBusinessStakeHolderInfoModel.getClientUserId()));
try {
log.info("Retrieving business stakeholder documents for seller with id [{}]", kycBusinessStakeHolderInfoModel.getClientUserId());
final List<MiraklShopDocument> shopDocuments = miraklMarketplacePlatformOperatorApiClient.getShopDocuments(getShopBusinessStakeholderDocumentsRequest);
// @formatter:off
log.info("Business stakeholder documents available for seller with id [{}]: [{}]", kycBusinessStakeHolderInfoModel.getClientUserId(), shopDocuments.stream().map(miraklDocument -> "Id:" + miraklDocument.getId() + " ,fileName:" + miraklDocument.getFileName() + " ,typeCode:" + miraklDocument.getTypeCode()).collect(Collectors.joining(" | ")));
// @formatter:on
return kycBusinessStakeHolderInfoModel.toBuilder().miraklShopDocuments(shopDocuments).build();
} catch (final MiraklException e) {
log.error("Something went wrong trying to receive business stakeholder documents from Mirakl for seller with id [{}]", kycBusinessStakeHolderInfoModel.getClientUserId());
kycMailNotificationUtil.sendPlainTextEmail("Issue detected getting business stakeholder documents from Mirakl", String.format("Something went wrong getting documents from Mirakl for shop Id [%s]%n%s", String.join(",", kycBusinessStakeHolderInfoModel.getClientUserId()), MiraklLoggingErrorsUtil.stringify(e)));
}
return kycBusinessStakeHolderInfoModel.toBuilder().build();
}
use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.
the class MiraklSellerDocumentDownloadExtractServiceImpl method populateMiraklShopDocuments.
/**
* {@inheritDoc}
*/
@Override
public KYCDocumentSellerInfoModel populateMiraklShopDocuments(final KYCDocumentSellerInfoModel kycDocumentSellerInfoModel) {
final MiraklGetShopDocumentsRequest getShopDocumentsRequest = new MiraklGetShopDocumentsRequest(List.of(kycDocumentSellerInfoModel.getClientUserId()));
try {
log.info("Retrieving documents for seller with id [{}]", kycDocumentSellerInfoModel.getClientUserId());
final List<MiraklShopDocument> shopDocuments = miraklMarketplacePlatformOperatorApiClient.getShopDocuments(getShopDocumentsRequest);
log.info("Documents retrieved for seller with id [{}]: [{}]", kycDocumentSellerInfoModel.getClientUserId(), shopDocuments.stream().map(MiraklShopDocument::getId).collect(Collectors.joining(",")));
return kycDocumentSellerInfoModel.toBuilder().miraklShopDocuments(shopDocuments).build();
} catch (final MiraklException e) {
log.error("Something went wrong trying to receive documents from Mirakl for seller with id [{}]", kycDocumentSellerInfoModel.getClientUserId());
kycMailNotificationUtil.sendPlainTextEmail("Issue detected getting documents from Mirakl", String.format("Something went wrong getting documents from Mirakl for shop Id [%s]%n%s", String.join(",", kycDocumentSellerInfoModel.getClientUserId()), MiraklLoggingErrorsUtil.stringify(e)));
}
return kycDocumentSellerInfoModel.toBuilder().build();
}
use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.
the class KYCUserDocumentFlagProofIdentityBusinessStakeHolderStrategy method fillMiraklProofIdentityOrBusinessFlagStatus.
protected void fillMiraklProofIdentityOrBusinessFlagStatus(final KYCUserDocumentFlagsNotificationBodyModel source, final List<String> kycCustomValuesRequiredVerificationBusinessStakeholders) {
if (CollectionUtils.isNotEmpty(kycCustomValuesRequiredVerificationBusinessStakeholders)) {
final MiraklUpdateShop updateShop = new MiraklUpdateShop();
final List<MiraklRequestAdditionalFieldValue> additionalFieldValues = kycCustomValuesRequiredVerificationBusinessStakeholders.stream().map(kycCustomValueRequiredVerification -> new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(kycCustomValueRequiredVerification, Boolean.TRUE.toString())).collect(Collectors.toList());
updateShop.setShopId(Long.valueOf(source.getClientUserId()));
updateShop.setAdditionalFieldValues(additionalFieldValues);
try {
log.info("Updating KYC proof of identity flag in Mirakl for business Stakeholder for shopId [{}]", source.getClientUserId());
final MiraklUpdateShopsRequest miraklUpdateShopsRequest = new MiraklUpdateShopsRequest(List.of(updateShop));
miraklMarketplacePlatformOperatorApiClient.updateShops(miraklUpdateShopsRequest);
log.info("Proof of identity flag updated for business Stakeholder for shopId [{}]", source.getClientUserId());
} catch (final MiraklException ex) {
log.error("Something went wrong updating KYC business stakeholder information of shop [{}]. Details [{}]", source.getClientUserId(), ex.getMessage());
mailNotificationUtil.sendPlainTextEmail("Issue detected updating KYC business stakeholder information in Mirakl", String.format(EMAIL_BODY_PREFIX + "Something went wrong updating KYC business stakeholder information for shop [%s]%n%s", source.getClientUserId(), MiraklLoggingErrorsUtil.stringify(ex)));
// Rethrow exception to handle it in AbstractNotificationListener
throw ex;
}
}
}
Aggregations