diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-04-30 10:08:29 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-04-30 10:08:29 +0200 |
commit | 0c26271dcbbc8986526baeb2532bd5607635a4cc (patch) | |
tree | b33417c0da1e0e5c9c68e1aa6413fe84ac217d3d /src/io/Requester.java | |
parent | 548fc2e77a3863b0563d7c6d80a7484815eeebad (diff) | |
download | TwitterDataAnalytics-0c26271dcbbc8986526baeb2532bd5607635a4cc.tar.gz |
Move classes not related to mining to io package
Diffstat (limited to 'src/io/Requester.java')
-rw-r--r-- | src/io/Requester.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/io/Requester.java b/src/io/Requester.java new file mode 100644 index 0000000..7f09a48 --- /dev/null +++ b/src/io/Requester.java @@ -0,0 +1,44 @@ +package io; + +import java.io.IOException; +import org.json.JSONObject; + +/** + * Performs an API request. + * + * @author Peter Wu + */ +public interface Requester { + + /** + * Performs an API request for a resource, for example + * "statuses/mentions_timeline" (note, no leading slash nor ".json" suffix). + * Prefix the resource with "1/" when you really need to target the old 1.0 + * API. + * + * @param resource The REST resource. + * @return A JSON object resulting from the request. + * @throws java.io.IOException on error fetching the resource. + */ + public JSONObject getJSON(String resource) throws IOException; + + /** + * Almost equivalent to {@code getJSON(resource, true)}, except that an + * IOException is not thrown if the request reports an non-successful status + * code. + * + * @see Requester#getJSON(java.lang.String, boolean) + * @throws IOException on network errors or if the response could not be + * parsed into a valid JSONObject. + */ + public JSONObject getJSONRelax(String resource) throws IOException; + + /** + * Tests whether this instance can dispatch requests. + * + * @return true if the access tokens are valid, false otherwise. + * @throws java.io.IOException if the status cannot reliably be determined + * (e.g. network error, parsing error). + */ + public boolean isValid() throws IOException; +} |