Search in sources :

Example 11 with MiraklApiException

use of com.mirakl.client.core.exception.MiraklApiException in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellersExtractServiceImpl method updateUserToken.

/**
 * {@inheritDoc}
 */
@Override
public void updateUserToken(final HyperwalletUser hyperwalletUser) {
    final MiraklUpdateShop miraklUpdateShop = new MiraklUpdateShop();
    final String shopId = hyperwalletUser.getClientUserId();
    miraklUpdateShop.setShopId(Long.valueOf(shopId));
    final MiraklSimpleRequestAdditionalFieldValue userTokenCustomField = new MiraklSimpleRequestAdditionalFieldValue();
    userTokenCustomField.setCode(HYPERWALLET_USER_TOKEN);
    userTokenCustomField.setValue(hyperwalletUser.getToken());
    miraklUpdateShop.setAdditionalFieldValues(List.of(userTokenCustomField));
    final MiraklUpdateShopsRequest request = new MiraklUpdateShopsRequest(List.of(miraklUpdateShop));
    log.info("Updating token for shop [{}] to [{}]", shopId, hyperwalletUser.getToken());
    try {
        miraklOperatorClient.updateShops(request);
    } catch (final MiraklApiException ex) {
        log.error("Something went wrong getting information of shop [{}]", shopId);
        sellerMailNotificationUtil.sendPlainTextEmail(EMAIL_SUBJECT_MESSAGE, String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting information of shop [%s]%n%s", shopId, MiraklLoggingErrorsUtil.stringify(ex)));
    }
}
Also used : MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklApiException(com.mirakl.client.core.exception.MiraklApiException) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklSimpleRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue)

Example 12 with MiraklApiException

use of com.mirakl.client.core.exception.MiraklApiException in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellersExtractServiceImpl method retrieveMiraklShopsByShopIds.

private MiraklShops retrieveMiraklShopsByShopIds(final List<String> shopIds) {
    final MiraklGetShopsRequest request = new MiraklGetShopsRequest();
    request.setShopIds(shopIds);
    request.setPaginate(false);
    log.info("Retrieving shops with ids {}", shopIds);
    try {
        return miraklOperatorClient.getShops(request);
    } catch (final MiraklApiException ex) {
        log.error("Something went wrong getting s information with ids [{}]", shopIds);
        sellerMailNotificationUtil.sendPlainTextEmail(EMAIL_SUBJECT_MESSAGE, String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting shop information with ids [%s]%n%s", shopIds, MiraklLoggingErrorsUtil.stringify(ex)));
        return new MiraklShops();
    }
}
Also used : MiraklGetShopsRequest(com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest) MiraklApiException(com.mirakl.client.core.exception.MiraklApiException) MiraklShops(com.mirakl.client.mmp.domain.shop.MiraklShops)

Example 13 with MiraklApiException

use of com.mirakl.client.core.exception.MiraklApiException in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellersExtractServiceImpl method retrieveMiraklShopsByDate.

private MiraklShops retrieveMiraklShopsByDate(@Nullable final Date delta) {
    final MiraklGetShopsRequest request = new MiraklGetShopsRequest();
    request.setUpdatedSince(delta);
    request.setPaginate(false);
    log.info("Retrieving shops since {}", delta);
    try {
        return miraklOperatorClient.getShops(request);
    } catch (final MiraklApiException ex) {
        log.error("Something went wrong getting shop information since [{}]", delta);
        sellerMailNotificationUtil.sendPlainTextEmail(EMAIL_SUBJECT_MESSAGE, String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting shop information since [%s]%n%s", delta, MiraklLoggingErrorsUtil.stringify(ex)));
        return new MiraklShops();
    }
}
Also used : MiraklGetShopsRequest(com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest) MiraklApiException(com.mirakl.client.core.exception.MiraklApiException) MiraklShops(com.mirakl.client.mmp.domain.shop.MiraklShops)

Aggregations

MiraklApiException (com.mirakl.client.core.exception.MiraklApiException)13 MiraklErrorResponseBean (com.mirakl.client.core.error.MiraklErrorResponseBean)8 Test (org.junit.jupiter.api.Test)8 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)7 MiraklGetShopsRequest (com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest)6 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)3 MiraklShops (com.mirakl.client.mmp.domain.shop.MiraklShops)2 MiraklSimpleRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue)2 LocalDateTime (java.time.LocalDateTime)2 Date (java.util.Date)2 CreditNoteModel (com.paypal.invoices.invoicesextract.model.CreditNoteModel)1 InvoiceModel (com.paypal.invoices.invoicesextract.model.InvoiceModel)1 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)1