diff --git a/CHANGES.md b/CHANGES.md index 04f80dd..2da4227 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Release History +## 0.1.8 +* Added new API - Suspend Contract +* Added new API - Resume Contract +* Un/archive Activities start supporting a list of codes +* Added new method client.getAuthorizationUrl(oauthCallback), supported in mobile applications + ## 0.1.7 * Added new API - Get brief profile summary * Added new API - Update bulk of activities diff --git a/doc/java-odesk-javadoc.zip b/doc/java-odesk-javadoc.zip index bc129e8..02a7e36 100644 Binary files a/doc/java-odesk-javadoc.zip and b/doc/java-odesk-javadoc.zip differ diff --git a/example-android/app/src/main/java/com/odesk/example_odeskapi/MyActivity.java b/example-android/app/src/main/java/com/odesk/example_odeskapi/MyActivity.java index 040e18d..7b1509a 100644 --- a/example-android/app/src/main/java/com/odesk/example_odeskapi/MyActivity.java +++ b/example-android/app/src/main/java/com/odesk/example_odeskapi/MyActivity.java @@ -159,6 +159,9 @@ class ODeskAuthorizeTask extends AsyncTask { @Override protected String doInBackground(Void... params) { String authzUrl = client.getAuthorizationUrl(); + // if your api key type is 'mobile', possibly you want to use + // oauth_callback in your application, then use + //String authzUrl = client.getAuthorizationUrl("x-app://your_callback"); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authzUrl))); diff --git a/lib/java-odesk.jar b/lib/java-odesk.jar index 35607cb..65ca4ab 100644 Binary files a/lib/java-odesk.jar and b/lib/java-odesk.jar differ diff --git a/src/com/oDesk/api/OAuthClient.java b/src/com/oDesk/api/OAuthClient.java index 4fbf423..fc28051 100644 --- a/src/com/oDesk/api/OAuthClient.java +++ b/src/com/oDesk/api/OAuthClient.java @@ -100,22 +100,23 @@ public OAuthClient(Config properties) { mOAuthConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret); } + /** + * Get authorization URL, and use provided callback + * + * @param oauthCallback URL, i.e. oauth_callback used in mobile applications + * @return URL for authorizing application + * */ + public String getAuthorizationUrl(String oauthCallback) { + return _getAuthorizationUrl(oauthCallback); + } + /** * Get authorization URL * * @return URL for authorizing application * */ public String getAuthorizationUrl() { - String url = null; - - try { - url = mOAuthProvider.retrieveRequestToken(mOAuthConsumer, ""); - } - catch (OAuthException e) { - e.printStackTrace(); - } - - return url; + return _getAuthorizationUrl(""); } /** @@ -246,6 +247,25 @@ public JSONObject delete(String url, HashMap params) throws JSON return sendPostRequest(url, METHOD_DELETE, params); } + /** + * Get authorization URL, use provided callback URL + * + * @param oauthCallback URL, i.e. oauth_callback + * @return URL for authorizing application + * */ + private String _getAuthorizationUrl(String oauthCallback) { + String url = null; + + try { + url = mOAuthProvider.retrieveRequestToken(mOAuthConsumer, oauthCallback); + } + catch (OAuthException e) { + e.printStackTrace(); + } + + return url; + } + /** * Send signed GET OAuth request * diff --git a/src/com/oDesk/api/Routers/Activities/Team.java b/src/com/oDesk/api/Routers/Activities/Team.java index 646207c..a4f5bd2 100644 --- a/src/com/oDesk/api/Routers/Activities/Team.java +++ b/src/com/oDesk/api/Routers/Activities/Team.java @@ -117,7 +117,7 @@ public JSONObject updateActivity(String company, String team, String code, HashM * * @param company Company ID * @param team Team ID - * @param code Specific code + * @param code Specific code(s) * @throws JSONException If error occurred * @return {@link JSONObject} */ @@ -130,7 +130,7 @@ public JSONObject archiveActivity(String company, String team, String code) thro * * @param company Company ID * @param team Team ID - * @param code Specific code + * @param code Specific code(s) * @throws JSONException If error occurred * @return {@link JSONObject} */ diff --git a/src/com/oDesk/api/Routers/Hr/Contracts.java b/src/com/oDesk/api/Routers/Hr/Contracts.java index 399f077..0affa4b 100644 --- a/src/com/oDesk/api/Routers/Hr/Contracts.java +++ b/src/com/oDesk/api/Routers/Hr/Contracts.java @@ -28,7 +28,7 @@ author = "Maksym Novozhylov ", date = "6/4/2014", currentRevision = 1, - lastModified = "6/4/2014", + lastModified = "19/9/2014", lastModifiedBy = "Maksym Novozhylov", reviewers = {"Yiota Tsakiri"} ) @@ -43,6 +43,30 @@ public Contracts(OAuthClient client) { oClient.setEntryPoint(ENTRY_POINT); } + /** + * Suspend Contract + * + * @param reference Contract reference + * @param params Parameters + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject suspendContract(String reference, HashMap params) throws JSONException { + return oClient.put("/hr/v2/contracts/" + reference + "/suspend", params); + } + + /** + * Restart Contract + * + * @param reference Contract reference + * @param params Parameters + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject restartContract(String reference, HashMap params) throws JSONException { + return oClient.put("/hr/v2/contracts/" + reference + "/restart", params); + } + /** * End Contract * diff --git a/test/com/oDesk/api/Routers/Hr/ContractsTest.java b/test/com/oDesk/api/Routers/Hr/ContractsTest.java index db55b17..125f573 100644 --- a/test/com/oDesk/api/Routers/Hr/ContractsTest.java +++ b/test/com/oDesk/api/Routers/Hr/ContractsTest.java @@ -18,6 +18,20 @@ Contracts.class }) public class ContractsTest extends Helper { + @Test public void suspendContract() throws Exception { + Contracts contracts = new Contracts(client); + JSONObject json = contracts.suspendContract("1234", new HashMap()); + + assertTrue(json instanceof JSONObject); + } + + @Test public void restartContract() throws Exception { + Contracts contracts = new Contracts(client); + JSONObject json = contracts.restartContract("1234", new HashMap()); + + assertTrue(json instanceof JSONObject); + } + @Test public void endContract() throws Exception { Contracts contracts = new Contracts(client); JSONObject json = contracts.endContract("1234", new HashMap());