protected List<SubscriptionBundle> getSubscriptionBundlesForAccount(
      final UUID accountId, final TenantContext context) throws AnalyticsRefreshException {
    final SubscriptionApi subscriptionApi = getSubscriptionApi();

    try {
      return subscriptionApi.getSubscriptionBundlesForAccountId(accountId, context);
    } catch (SubscriptionApiException e) {
      logService.log(
          LogService.LOG_WARNING, "Error retrieving bundles for account id " + accountId, e);
      throw new AnalyticsRefreshException(e);
    }
  }
  protected SubscriptionBundle getLatestSubscriptionBundleForExternalKey(
      final String bundleExternalKey, final TenantContext context)
      throws AnalyticsRefreshException {
    final SubscriptionApi subscriptionApi = getSubscriptionApi();

    try {
      final List<SubscriptionBundle> bundles =
          subscriptionApi.getSubscriptionBundlesForExternalKey(bundleExternalKey, context);
      if (bundles.size() == 0) {
        throw new AnalyticsRefreshException(
            "Unable to retrieve latest bundle for bundle external key " + bundleExternalKey);
      }
      return bundles.get(bundles.size() - 1);
    } catch (SubscriptionApiException e) {
      logService.log(
          LogService.LOG_WARNING,
          "Error retrieving bundles for bundle external key " + bundleExternalKey,
          e);
      throw new AnalyticsRefreshException(e);
    }
  }