com.simpy.api.rest.client
Class Simpy

java.lang.Object
  extended bycom.simpy.api.rest.client.Simpy

public class Simpy
extends java.lang.Object

Simpy is a class for accessing the Simpy REST API.

Since:
1.0
Version:
$Id: Simpy.java,v 1.21 2007/04/20 14:41:28 czarneckid Exp $
Author:
David Czarnecki

Constructor Summary
Simpy(java.lang.String username, java.lang.String password)
          Create an object to interact with Simpy
 
Method Summary
 int deleteLink(java.lang.String href)
          Deletes the given link and returns a status reponse indicating either success or failure.
 int deleteNote(java.lang.String noteId)
          Deletes the given Note and returns a status reponse indicating either success or failure.
 java.util.List getAllLinks(java.lang.String q, java.lang.String date, java.lang.String afterDate, java.lang.String beforeDate)
          Depending on your input parameters, this call returns all links that were added on or between given dates, or links matching a given query.
 java.util.List getAllNotes(java.lang.String q)
          Returns all your Notes in the reverse chronological order by add date (i.e.
 int getHttpResult()
          Return the HTTP status code of the last operation
 java.util.List getLinks(java.lang.String q, java.lang.String date, java.lang.String afterDate, java.lang.String beforeDate)
          Same as getAllLinks() except that it returns the ten most relevant links (depending on the given parameters).
 java.util.List getLinks(java.lang.String q, java.lang.String date, java.lang.String afterDate, java.lang.String beforeDate, int limit)
          Depending on your input parameters, this methdod returns links added on or between given dates, or links matching a given query.
 java.util.List getNotes(java.lang.String q)
          Fetches the ten most recently addded Notes from the simpy, or the ten most relevant Notes, according to the specified search String.
 java.util.List getNotes(java.lang.String q, int limit)
          Returns all your Notes in the reverse chronological order by add date (i.e.
 java.util.List getTags()
          Return a list of Tag objects
 Topic getTopic(int topicId)
          Returns the meta-data for a given Topic.
 java.util.List getTopics()
          Returns the list of your Topics, their meta-data, including the number of new links added each Topic since your last login.
 Watchlist getWatchlist(int watchlistId)
          Retrieve a Watchlist for the given watchlist id
 java.util.List getWatchlists()
          This API call returns the list of your Watchlists, their meta-data, including the number of new links added to each Watchlist since your last login.
 int mergeTags(java.lang.String fromTag1, java.lang.String fromTag2, java.lang.String toTag)
          This API call merges two tags into a new tag.
 int removeTag(java.lang.String tag)
          This API call removes the given tag.
 int renameTag(java.lang.String fromTag, java.lang.String toTag)
          This API call renames the given tag.
 int saveLink(java.lang.String title, java.lang.String href, int accessType, java.lang.String tags, java.lang.String nickname, java.lang.String note)
          Saves the given link and returns a status reponse indicating either success or failure.
 int saveNote(java.lang.String title, java.lang.String tags, java.lang.String description)
          Saves a new Note and returns a status reponse indicating either success or failure.
 int splitTag(java.lang.String tag, java.lang.String toTag1, java.lang.String toTag2)
          This API call splits a single tag into two separate tags.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Simpy

public Simpy(java.lang.String username,
             java.lang.String password)
Create an object to interact with Simpy

Parameters:
username - Username
password - Password
Method Detail

getHttpResult

public int getHttpResult()
Return the HTTP status code of the last operation

Returns:
HTTP status code

getTags

public java.util.List getTags()
Return a list of Tag objects

Returns:
List of Tag objects

getAllLinks

public java.util.List getAllLinks(java.lang.String q,
                                  java.lang.String date,
                                  java.lang.String afterDate,
                                  java.lang.String beforeDate)
Depending on your input parameters, this call returns all links that were added on or between given dates, or links matching a given query.

Parameters:
q - A query string that forces the API call to return only the matching links.
date - This parameter should not be used in combination with the afterDate and beforeDate parameters. It limits the links returned to links added on the given date.
afterDate - This parameter should be used in combination with the beforeDate parameter. It limits the links returned to links added after the given date, excluding the date specified.
beforeDate - This parameter should be used in combination with the afterDate parameter. It limits the links returned to links added before the given date, excluding the date specified.
Returns:
Returns all links, links added on or between given dates, or links matching a given query.

getLinks

public java.util.List getLinks(java.lang.String q,
                               java.lang.String date,
                               java.lang.String afterDate,
                               java.lang.String beforeDate)
Same as getAllLinks() except that it returns the ten most relevant links (depending on the given parameters).

See Also:
getAllLinks(String, String, String, String)

removeTag

public int removeTag(java.lang.String tag)
This API call removes the given tag.

Parameters:
tag - Specifies the tag to remove.
Returns:
Status reponse indicating either success or failure.

renameTag

public int renameTag(java.lang.String fromTag,
                     java.lang.String toTag)
This API call renames the given tag.

Parameters:
fromTag - Specifies the tag to rename.
toTag - Specifies the new tag name.
Returns:
Status reponse indicating either success or failure.

mergeTags

public int mergeTags(java.lang.String fromTag1,
                     java.lang.String fromTag2,
                     java.lang.String toTag)
This API call merges two tags into a new tag.

Parameters:
fromTag1 - Specifies the first tag to merge.
fromTag2 - Specifies the second tag to merge.
toTag - Specifies the tag to merge the two tags into.
Returns:
Status reponse indicating either success or failure.

splitTag

public int splitTag(java.lang.String tag,
                    java.lang.String toTag1,
                    java.lang.String toTag2)
This API call splits a single tag into two separate tags.

Parameters:
tag - Specifies the tag to split.
toTag1 - Specifies the first tag to split into.
toTag2 - Specifies the second tag to split into.
Returns:
Status reponse indicating either success or failure.

getLinks

public java.util.List getLinks(java.lang.String q,
                               java.lang.String date,
                               java.lang.String afterDate,
                               java.lang.String beforeDate,
                               int limit)
Depending on your input parameters, this methdod returns links added on or between given dates, or links matching a given query. The number of links to be returned can be freely configured.

Parameters:
limit - number of links to return
Returns:
Returns

getTopics

public java.util.List getTopics()
Returns the list of your Topics, their meta-data, including the number of new links added each Topic since your last login.

Returns:
Returns the list of your Topics, their meta-data, including the number of new links added each Topic since your last login.

getTopic

public Topic getTopic(int topicId)
Returns the meta-data for a given Topic.

Parameters:
topicId - The ID of a Topic you want to retrieve. The ID must belong to your Topic.
Returns:
Returns the meta-data for a given Topic.

getAllNotes

public java.util.List getAllNotes(java.lang.String q)
Returns all your Notes in the reverse chronological order by add date (i.e. the most recently added Note first) or by relevance, if a search String is specified.

Parameters:
q - a search String that is used in the API
Returns:
a List of Note objects

getNotes

public java.util.List getNotes(java.lang.String q)
Fetches the ten most recently addded Notes from the simpy, or the ten most relevant Notes, according to the specified search String. The search String is only applied to the API call, if it's not null and not an empty String.
Use getAllNotes() if you want to fetch all Notes from the API.

Parameters:
q - a search String that is used in the API
Returns:
a List of Note objects
See Also:
getAllNotes(String)

getNotes

public java.util.List getNotes(java.lang.String q,
                               int limit)
Returns all your Notes in the reverse chronological order by add date (i.e. the most recently added Note first) or by rank, if you use this in the search mode.

Parameters:
q - A query string that forces the API call to return only the matching Notes.
limit - the number of Notes to return.
Returns:
Returns all your Notes in the reverse chronological order by add date (i.e. the most recently added Note first) or by rank, if you use this in the search mode.

saveLink

public int saveLink(java.lang.String title,
                    java.lang.String href,
                    int accessType,
                    java.lang.String tags,
                    java.lang.String nickname,
                    java.lang.String note)
Saves the given link and returns a status reponse indicating either success or failure.

Parameters:
title - The title of the page to save.
href - The URL of the page to save. It must start with 'http://'.
accessType - Use 1 to make the link public and 0 to make it private.
tags - Comma-separated list of tags.
nickname - An alternative, custom title.
note - A free-text note to go with the link.
Returns:
Status reponse indicating either success or failure.
Throws:
java.lang.IllegalArgumentException - If either title or href is null as they are required parameters

deleteLink

public int deleteLink(java.lang.String href)
Deletes the given link and returns a status reponse indicating either success or failure.

Parameters:
href - The URL of the bookmark to delete. It must start with 'http://'.
Returns:
Status reponse indicating either success or failure.
Throws:
java.lang.IllegalArgumentException - If href is null as they are required parameters

deleteNote

public int deleteNote(java.lang.String noteId)
Deletes the given Note and returns a status reponse indicating either success or failure.

Parameters:
noteId - The ID of the Note to delete.
Returns:
Status reponse indicating either success or failure.
Throws:
java.lang.IllegalArgumentException - If title is null as it is a required parameter

saveNote

public int saveNote(java.lang.String title,
                    java.lang.String tags,
                    java.lang.String description)
Saves a new Note and returns a status reponse indicating either success or failure.

Parameters:
title - The title of the Note to save.
tags - Comma-separated list of tags.
description - A free-text note.
Returns:
Status reponse indicating either success or failure.
Throws:
java.lang.IllegalArgumentException - If title is null as it is a required parameter

getWatchlists

public java.util.List getWatchlists()
This API call returns the list of your Watchlists, their meta-data, including the number of new links added to each Watchlist since your last login.

Returns:
List of Watchlist items

getWatchlist

public Watchlist getWatchlist(int watchlistId)
Retrieve a Watchlist for the given watchlist id

Parameters:
watchlistId - Watchlist to retrieve
Returns:
Watchlist for the given watchlist id or null if the watchlist could not be loaded
Since:
1.2