use of com.mirakl.client.core.exception.MiraklApiException 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.core.exception.MiraklApiException in project mirakl-hyperwallet-connector by paypal.
the class MiraklInvoicesExtractServiceImplTest method extractAccountingDocument_whenMiraklExceptionIsThrown_shouldSendEmailNotification.
@Test
void extractAccountingDocument_whenMiraklExceptionIsThrown_shouldSendEmailNotification() {
final LocalDateTime now = LocalDateTime.now();
TimeMachine.useFixedClockAt(now);
final Date nowAsDate = DateUtil.convertToDate(now, ZoneId.systemDefault());
final InvoiceModel invoiceOne = InvoiceModel.builder().shopId(SHOP_ID_ONE).destinationToken(TOKEN_1).hyperwalletProgram(HYPERWALLET_PROGRAM).build();
final List<InvoiceModel> invoiceList = List.of(invoiceOne);
doReturn(invoiceList).when(testObj).getAccountingDocuments(nowAsDate);
final MiraklApiException miraklApiException = new MiraklApiException(new MiraklErrorResponseBean(1, "Something went wrong"));
doThrow(miraklApiException).when(miraklMarketplacePlatformOperatorApiClientMock).getShops(any(MiraklGetShopsRequest.class));
testObj.extractAccountingDocument(nowAsDate);
verify(mailNotificationUtilMock).sendPlainTextEmail("Issue detected getting shops in Mirakl", String.format("Something went wrong getting information of " + "shops" + " [2000]%n%s", MiraklLoggingErrorsUtil.stringify(miraklApiException)));
}
use of com.mirakl.client.core.exception.MiraklApiException in project mirakl-hyperwallet-connector by paypal.
the class MiraklSellersExtractServiceImplCustomFieldsTest method updateUserToken_shouldSendEmailNotification_whenMiraklExceptionIsThrown.
@Test
void updateUserToken_shouldSendEmailNotification_whenMiraklExceptionIsThrown() {
when(hyperwalletUserMock.getToken()).thenReturn(TOKEN_VALUE);
when(hyperwalletUserMock.getClientUserId()).thenReturn("12345");
final MiraklApiException miraklApiException = new MiraklApiException(new MiraklErrorResponseBean(1, "Something went wrong"));
doThrow(miraklApiException).when(miraklMarketplacePlatformOperatorApiClientMock).updateShops(any(MiraklUpdateShopsRequest.class));
testObj.updateUserToken(hyperwalletUserMock);
verify(mailNotificationUtilMock).sendPlainTextEmail(eq("Issue detected getting shop information in Mirakl"), eq(String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting information of shop [12345]%n%s", MiraklLoggingErrorsUtil.stringify(miraklApiException))));
}
use of com.mirakl.client.core.exception.MiraklApiException in project mirakl-hyperwallet-connector by paypal.
the class MiraklSellersExtractServiceImplTest method extractSellers_shouldSendEmailNotification_whenMiraklExceptionIsThrownAndShopIdsAreReceived.
@Test
void extractSellers_shouldSendEmailNotification_whenMiraklExceptionIsThrownAndShopIdsAreReceived() {
final MiraklApiException miraklApiException = new MiraklApiException(new MiraklErrorResponseBean(1, "Something went wrong"));
doThrow(miraklApiException).when(miraklMarketplacePlatformOperatorApiClientMock).getShops(any(MiraklGetShopsRequest.class));
testObj.extractSellers(List.of(INDIVIDUAL_SHOP, PROFESSIONAL_SHOP_ID));
verify(mailNotificationUtilMock).sendPlainTextEmail("Issue detected getting shop information in Mirakl", String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting shop information with ids [[individualShop, professionalShop]]%n%s", MiraklLoggingErrorsUtil.stringify(miraklApiException)));
}
use of com.mirakl.client.core.exception.MiraklApiException in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderExtractServiceImpl method updateBusinessStakeholderToken.
@Override
public void updateBusinessStakeholderToken(final String clientUserId, final List<BusinessStakeHolderModel> businessStakeHolderModels) {
if (CollectionUtils.isEmpty(businessStakeHolderModels)) {
log.info("No data for business stakeholders on store [{}]", clientUserId);
return;
}
final MiraklUpdateShop miraklUpdateShop = createMiraklUpdateFieldRequestForStakeholders(clientUserId, businessStakeHolderModels);
final MiraklUpdateShopsRequest request = new MiraklUpdateShopsRequest(List.of(miraklUpdateShop));
try {
miraklOperatorClient.updateShops(request);
} catch (final MiraklApiException ex) {
log.error("Something went wrong getting information of shop [{}]", clientUserId);
sellerMailNotificationUtil.sendPlainTextEmail(EMAIL_SUBJECT_MESSAGE, String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting information of shop [%s]%n%s", clientUserId, MiraklLoggingErrorsUtil.stringify(ex)));
}
}
Aggregations