001package com.box.sdk; 002 003import com.eclipsesource.json.JsonObject; 004 005/** 006 * Utility class to retrieve list of recent items. 007 * 008 * @see <a href="http://google.com">https://developer.box.com/reference#get-recent-items</a> 009 */ 010public final class BoxRecents { 011 012 /** 013 * Recents URL Template. 014 */ 015 public static final URLTemplate RECENTS_URL_TEMPLATE = new URLTemplate("recent_items"); 016 017 //Constructor is not allowed 018 private BoxRecents() { 019 } 020 021 /** 022 * Used to retrieve all collaborations associated with the item. 023 * 024 * @param api BoxAPIConnection from the associated file. 025 * @param limit limit of items to be retrieved. Default is 100. Maximum is 1000 026 * @param fields the optional fields to retrieve. 027 * @return An iterable of BoxCollaboration.Info instances associated with the item. 028 * @see <a href="http://google.com">https://developer.box.com/reference#get-recent-items</a> 029 */ 030 public static BoxResourceIterable<BoxRecentItem> getRecentItems(final BoxAPIConnection api, 031 int limit, String... fields) { 032 QueryStringBuilder builder = new QueryStringBuilder(); 033 if (fields.length > 0) { 034 builder.appendParam("fields", fields); 035 } 036 return new BoxResourceIterable<BoxRecentItem>( 037 api, RECENTS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString()), 038 limit) { 039 040 @Override 041 protected BoxRecentItem factory(JsonObject jsonObject) { 042 return new BoxRecentItem(jsonObject, api); 043 } 044 }; 045 } 046}