/** * Obtains a Link object, given the id of the object. * * @param ld is the LinkDeveloperSession (which holds the access token for the user) * @param id is the identifier for an existing Link object. * @return The Link object represented by the id is returned. * @throws LinkDeveloperException */ @SuppressWarnings("unchecked") public static Link get(LinkDeveloperSession ld, String id) throws LinkDeveloperException { try { return new Link( ld, (Map<String, Object>) (ld.rest_request(API_URL + "/" + id, Method.GET).get(ITEM_KEY))); } catch (LinkDeveloperException e) { throw new LinkDeveloperException( "Cannot create " + LinkDeveloperSession.capitalize(ITEM_KEY) + " object with ID of \"" + id + "\"! " + e.getMessage(), e); } }
/** * Returns a Map of all the Link objects for the given account. The Map uses the Id of the object * as the key. The value in the Map is the Link object itself. * * @param ld is the LinkDeveloperSession (which holds the access token for the user) * @return Returns a Map of all Link objects. * @throws LinkDeveloperException */ @SuppressWarnings("unchecked") public static Map<String, Link> list(LinkDeveloperSession ld) throws LinkDeveloperException { Map<String, Link> returnList = new HashMap<String, Link>(); Map<String, Object> list = ld.rest_request(API_URL, Method.GET); for (Map<String, Object> data : (List<Map<String, Object>>) list.get(LIST_KEY)) { Link item = new Link(ld, data); returnList.put(item.getId(), item); } return returnList; }