diff --git a/CHANGES.md b/CHANGES.md index 33e7d65..2adacb6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,18 @@ # Release History +## 0.1.11 +* Added new Milestone API - Get Active Milestone for specific Contract +* Added new Milestone API - Get all Submissions for specific Milestone +* Added new Milestone API - Create a new Milestone +* Added new Milestone API - Edit the Milestone +* Added new Milestone API - Approve the Milestone +* Added new Milestone API - Activate the Milestone +* Added new Milestone API - Delete the Milestone +* Added new Submission API - Submit for Approval +* Added new Submission API - Approve the Submission +* Added new Submission API - Reject the Submission +* Fixed issue in Workdiary API + ## 0.1.10 * Added new call for Referenced User API diff --git a/README.md b/README.md index f16f909..70eedc4 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ These are the supported API resources: Copyright 2014 oDesk Corporation. All Rights Reserved. -php-odesk is licensed under the Apache License, Version 2.0 (the "License"); +java-odesk is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -54,4 +54,4 @@ See the `example` directory. To quickly run the example from the command line: make make run -Make sure you've added consumer key and secret to the `example/odesk.properties`. \ No newline at end of file +Make sure you've added consumer key and secret to the `example/odesk.properties`. diff --git a/doc/java-odesk-javadoc.zip b/doc/java-odesk-javadoc.zip index b69281a..187d688 100644 Binary files a/doc/java-odesk-javadoc.zip and b/doc/java-odesk-javadoc.zip differ diff --git a/example-android/app/libs/java-odesk.jar b/example-android/app/libs/java-odesk.jar index 7e02146..03bb942 100644 Binary files a/example-android/app/libs/java-odesk.jar and b/example-android/app/libs/java-odesk.jar differ diff --git a/lib/java-odesk.jar b/lib/java-odesk.jar index 7e02146..03bb942 100644 Binary files a/lib/java-odesk.jar and b/lib/java-odesk.jar differ diff --git a/src/com/oDesk/api/Routers/Hr/Milestones.java b/src/com/oDesk/api/Routers/Hr/Milestones.java new file mode 100644 index 0000000..80a58a8 --- /dev/null +++ b/src/com/oDesk/api/Routers/Hr/Milestones.java @@ -0,0 +1,126 @@ +/** + * Copyright 2014 oDesk + * + * Licensed under the oDesk's API Terms of Use; + * you may not use this file except in compliance with the Terms. + * You may obtain a copy of the Terms at + * + * http://developers.odesk.com/API-Terms-of-Use + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.oDesk.api.Routers.Hr; + +import java.util.HashMap; + +import com.oDesk.ClassPreamble; +import com.oDesk.api.OAuthClient; + +import org.json.JSONException; +import org.json.JSONObject; + +@ClassPreamble ( + author = "Maksym Novozhylov ", + date = "11/17/2014", + currentRevision = 1, + lastModified = "11/17/2014", + lastModifiedBy = "Maksym Novozhylov", + reviewers = {"Yiota Tsakiri"} +) +public final class Milestones { + + final static String ENTRY_POINT = "api"; + + private OAuthClient oClient = null; + + public Milestones(OAuthClient client) { + oClient = client; + oClient.setEntryPoint(ENTRY_POINT); + } + + /** + * Get active Milestone for the Contract + * + * @param contractId Contract reference + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject getActiveMilestone(String contractId) throws JSONException { + return oClient.get("/hr/v3/fp/milestones/statuses/active/contracts/" + contractId); + } + + /** + * Get all submissions for the active Milestone + * + * @param milestoneId Milestone ID + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject getSubmissions(String milestoneId) throws JSONException { + return oClient.get("/hr/v3/fp/milestones/" + milestoneId + "/submissions"); + } + + /** + * Create a new Milestone + * + * @param params Parameters + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject create(HashMap params) throws JSONException { + return oClient.post("/hr/v3/fp/milestones", params); + } + + /** + * Edit an existing Milestone + * + * @param milestoneId Milestone ID + * @param params Parameters + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject edit(String milestoneId, HashMap params) throws JSONException { + return oClient.put("/hr/v3/fp/milestones/" + milestoneId, params); + } + + /** + * Activate an existing Milestone + * + * @param milestoneId Milestone ID + * @param params Parameters + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject activate(String milestoneId, HashMap params) throws JSONException { + return oClient.put("/hr/v3/fp/milestones/" + milestoneId + "/activate", params); + } + + /** + * Approve an existing Milestone + * + * @param milestoneId Milestone ID + * @param params Parameters + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject approve(String milestoneId, HashMap params) throws JSONException { + return oClient.put("/hr/v3/fp/milestones/" + milestoneId + "/approve", params); + } + + /** + * Delete an existing Milestone + * + * @param milestoneId Milestone ID + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject delete(String milestoneId) throws JSONException { + return oClient.delete("/hr/v3/fp/milestones/" + milestoneId); + } + +} \ No newline at end of file diff --git a/src/com/oDesk/api/Routers/Hr/Submissions.java b/src/com/oDesk/api/Routers/Hr/Submissions.java new file mode 100644 index 0000000..b60e167 --- /dev/null +++ b/src/com/oDesk/api/Routers/Hr/Submissions.java @@ -0,0 +1,81 @@ +/** + * Copyright 2014 oDesk + * + * Licensed under the oDesk's API Terms of Use; + * you may not use this file except in compliance with the Terms. + * You may obtain a copy of the Terms at + * + * http://developers.odesk.com/API-Terms-of-Use + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.oDesk.api.Routers.Hr; + +import java.util.HashMap; + +import com.oDesk.ClassPreamble; +import com.oDesk.api.OAuthClient; + +import org.json.JSONException; +import org.json.JSONObject; + +@ClassPreamble ( + author = "Maksym Novozhylov ", + date = "11/17/2014", + currentRevision = 1, + lastModified = "11/17/2014", + lastModifiedBy = "Maksym Novozhylov", + reviewers = {"Yiota Tsakiri"} +) +public final class Submissions { + + final static String ENTRY_POINT = "api"; + + private OAuthClient oClient = null; + + public Submissions(OAuthClient client) { + oClient = client; + oClient.setEntryPoint(ENTRY_POINT); + } + + /** + * Freelancer submits work for the client to approve + * + * @param params Parameters + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject requestApproval(HashMap params) throws JSONException { + return oClient.post("/hr/v3/fp/submissions", params); + } + + /** + * Approve an existing Submission + * + * @param submissionId Submission ID + * @param params Parameters + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject approve(String submissionId, HashMap params) throws JSONException { + return oClient.put("/hr/v3/fp/submissions/" + submissionId + "/approve", params); + } + + /** + * Reject an existing Submission + * + * @param submissionId Submission ID + * @param params Parameters + * @throws JSONException If error occurred + * @return {@link JSONObject} + */ + public JSONObject reject(String submissionId, HashMap params) throws JSONException { + return oClient.put("/hr/v3/fp/submissions/" + submissionId + "/reject", params); + } + +} \ No newline at end of file diff --git a/src/com/oDesk/api/Routers/Workdiary.java b/src/com/oDesk/api/Routers/Workdiary.java index 8233255..1d862d1 100644 --- a/src/com/oDesk/api/Routers/Workdiary.java +++ b/src/com/oDesk/api/Routers/Workdiary.java @@ -54,7 +54,7 @@ public Workdiary(OAuthClient client) { * @return {@link JSONObject} */ public JSONObject get(String company, String username, String date, HashMap params) throws JSONException { - return oClient.get("/team/v1/workdiaries/" + company + "/" + "username" + "/" + date, params); + return oClient.get("/team/v1/workdiaries/" + company + "/" + username + "/" + date, params); } } diff --git a/test/com/oDesk/api/Routers/Hr/MilestonesTest.java b/test/com/oDesk/api/Routers/Hr/MilestonesTest.java new file mode 100644 index 0000000..9fe4e58 --- /dev/null +++ b/test/com/oDesk/api/Routers/Hr/MilestonesTest.java @@ -0,0 +1,69 @@ +package com.oDesk.api.Routers.Hr; + +import static org.junit.Assert.*; + +import java.util.HashMap; + +import org.json.JSONObject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.oDesk.api.Routers.Helper; +import com.oDesk.api.Routers.Hr.Milestones; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ + Milestones.class +}) +public class MilestonesTest extends Helper { + @Test public void getActiveMilestone() throws Exception { + Milestones milestones = new Milestones(client); + JSONObject json = milestones.getActiveMilestone("1234"); + + assertTrue(json instanceof JSONObject); + } + + @Test public void getSubmissions() throws Exception { + Milestones milestones = new Milestones(client); + JSONObject json = milestones.getSubmissions("1234"); + + assertTrue(json instanceof JSONObject); + } + + @Test public void create() throws Exception { + Milestones milestones = new Milestones(client); + JSONObject json = milestones.create(new HashMap()); + + assertTrue(json instanceof JSONObject); + } + + @Test public void edit() throws Exception { + Milestones milestones = new Milestones(client); + JSONObject json = milestones.edit("1234", new HashMap()); + + assertTrue(json instanceof JSONObject); + } + + @Test public void activate() throws Exception { + Milestones milestones = new Milestones(client); + JSONObject json = milestones.activate("1234", new HashMap()); + + assertTrue(json instanceof JSONObject); + } + + @Test public void approve() throws Exception { + Milestones milestones = new Milestones(client); + JSONObject json = milestones.approve("1234", new HashMap()); + + assertTrue(json instanceof JSONObject); + } + + @Test public void delete() throws Exception { + Milestones milestones = new Milestones(client); + JSONObject json = milestones.delete("1234"); + + assertTrue(json instanceof JSONObject); + } +} \ No newline at end of file diff --git a/test/com/oDesk/api/Routers/Hr/SubmissionsTest.java b/test/com/oDesk/api/Routers/Hr/SubmissionsTest.java new file mode 100644 index 0000000..9b7f8be --- /dev/null +++ b/test/com/oDesk/api/Routers/Hr/SubmissionsTest.java @@ -0,0 +1,41 @@ +package com.oDesk.api.Routers.Hr; + +import static org.junit.Assert.*; + +import java.util.HashMap; + +import org.json.JSONObject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.oDesk.api.Routers.Helper; +import com.oDesk.api.Routers.Hr.Submissions; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ + Submissions.class +}) +public class SubmissionsTest extends Helper { + @Test public void requestApproval() throws Exception { + Submissions submissions = new Submissions(client); + JSONObject json = submissions.requestApproval(new HashMap()); + + assertTrue(json instanceof JSONObject); + } + + @Test public void approve() throws Exception { + Submissions submissions = new Submissions(client); + JSONObject json = submissions.approve("1234", new HashMap()); + + assertTrue(json instanceof JSONObject); + } + + @Test public void reject() throws Exception { + Submissions submissions = new Submissions(client); + JSONObject json = submissions.reject("1234", new HashMap()); + + assertTrue(json instanceof JSONObject); + } +} \ No newline at end of file