예제 #1
0
 private NewsBlurResponse markAllAsRead() {
   ValueMultimap values = new ValueMultimap();
   values.put(APIConstants.PARAMETER_DAYS, "0");
   APIResponse response = post(APIConstants.URL_MARK_ALL_AS_READ, values, false);
   // TODO: these calls use a different return format than others: the errors field is an array,
   // not an object
   // return response.getResponse(gson, NewsBlurResponse.class);
   NewsBlurResponse nbr = new NewsBlurResponse();
   if (response.isError()) nbr.message = "err";
   return nbr;
 }
예제 #2
0
  public NewsBlurResponse markFeedsAsRead(FeedSet fs, Long includeOlder, Long includeNewer) {
    ValueMultimap values = new ValueMultimap();

    if (fs.getSingleFeed() != null) {
      values.put(APIConstants.PARAMETER_FEEDID, fs.getSingleFeed());
    } else if (fs.getMultipleFeeds() != null) {
      for (String feedId : fs.getMultipleFeeds()) values.put(APIConstants.PARAMETER_FEEDID, feedId);
    } else if (fs.getSingleSocialFeed() != null) {
      values.put(
          APIConstants.PARAMETER_FEEDID,
          APIConstants.VALUE_PREFIX_SOCIAL + fs.getSingleSocialFeed().getKey());
    } else if (fs.getMultipleSocialFeeds() != null) {
      for (Map.Entry<String, String> entry : fs.getMultipleSocialFeeds().entrySet()) {
        values.put(
            APIConstants.PARAMETER_FEEDID, APIConstants.VALUE_PREFIX_SOCIAL + entry.getKey());
      }
    } else if (fs.isAllNormal()) {
      // all stories uses a special API call
      return markAllAsRead();
    } else if (fs.isAllSocial()) {
      values.put(APIConstants.PARAMETER_FEEDID, APIConstants.VALUE_ALLSOCIAL);
    } else {
      throw new IllegalStateException("Asked to get stories for FeedSet of unknown type.");
    }

    if (includeOlder != null) {
      // the app uses  milliseconds but the API wants seconds
      long cut = includeOlder.longValue();
      values.put(APIConstants.PARAMETER_CUTOFF_TIME, Long.toString(cut / 1000L));
      values.put(APIConstants.PARAMETER_DIRECTION, APIConstants.VALUE_OLDER);
    }
    if (includeNewer != null) {
      // the app uses  milliseconds but the API wants seconds
      long cut = includeNewer.longValue();
      values.put(APIConstants.PARAMETER_CUTOFF_TIME, Long.toString(cut / 1000L));
      values.put(APIConstants.PARAMETER_DIRECTION, APIConstants.VALUE_NEWER);
    }

    APIResponse response = post(APIConstants.URL_MARK_FEED_AS_READ, values, false);
    // TODO: these calls use a different return format than others: the errors field is an array,
    // not an object
    // return response.getResponse(gson, NewsBlurResponse.class);
    NewsBlurResponse nbr = new NewsBlurResponse();
    if (response.isError()) nbr.message = "err";
    return nbr;
  }