Skip to content
This repository was archived by the owner on Oct 9, 2018. It is now read-only.

Commit 5a91f6c

Browse files
author
Maksym Novozhylov
committed
Merge branch 'v0.1.11'
Conflicts: example-android/app/libs/java-odesk.jar
2 parents 7dc3f71 + 28a7929 commit 5a91f6c

File tree

10 files changed

+333
-3
lines changed

10 files changed

+333
-3
lines changed

CHANGES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Release History
22

3+
## 0.1.11
4+
* Added new Milestone API - Get Active Milestone for specific Contract
5+
* Added new Milestone API - Get all Submissions for specific Milestone
6+
* Added new Milestone API - Create a new Milestone
7+
* Added new Milestone API - Edit the Milestone
8+
* Added new Milestone API - Approve the Milestone
9+
* Added new Milestone API - Activate the Milestone
10+
* Added new Milestone API - Delete the Milestone
11+
* Added new Submission API - Submit for Approval
12+
* Added new Submission API - Approve the Submission
13+
* Added new Submission API - Reject the Submission
14+
* Fixed issue in Workdiary API
15+
316
## 0.1.10
417
* Added new call for Referenced User API
518

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ These are the supported API resources:
3030

3131
Copyright 2014 oDesk Corporation. All Rights Reserved.
3232

33-
php-odesk is licensed under the Apache License, Version 2.0 (the "License");
33+
java-odesk is licensed under the Apache License, Version 2.0 (the "License");
3434
you may not use this file except in compliance with the License.
3535
You may obtain a copy of the License at
3636

@@ -54,4 +54,4 @@ See the `example` directory. To quickly run the example from the command line:
5454
make
5555
make run
5656

57-
Make sure you've added consumer key and secret to the `example/odesk.properties`.
57+
Make sure you've added consumer key and secret to the `example/odesk.properties`.

doc/java-odesk-javadoc.zip

5.84 KB
Binary file not shown.
2.39 KB
Binary file not shown.

lib/java-odesk.jar

2.39 KB
Binary file not shown.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/**
2+
* Copyright 2014 oDesk
3+
*
4+
* Licensed under the oDesk's API Terms of Use;
5+
* you may not use this file except in compliance with the Terms.
6+
* You may obtain a copy of the Terms at
7+
*
8+
* http://developers.odesk.com/API-Terms-of-Use
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.oDesk.api.Routers.Hr;
18+
19+
import java.util.HashMap;
20+
21+
import com.oDesk.ClassPreamble;
22+
import com.oDesk.api.OAuthClient;
23+
24+
import org.json.JSONException;
25+
import org.json.JSONObject;
26+
27+
@ClassPreamble (
28+
author = "Maksym Novozhylov <mnovozhilov@odesk.com>",
29+
date = "11/17/2014",
30+
currentRevision = 1,
31+
lastModified = "11/17/2014",
32+
lastModifiedBy = "Maksym Novozhylov",
33+
reviewers = {"Yiota Tsakiri"}
34+
)
35+
public final class Milestones {
36+
37+
final static String ENTRY_POINT = "api";
38+
39+
private OAuthClient oClient = null;
40+
41+
public Milestones(OAuthClient client) {
42+
oClient = client;
43+
oClient.setEntryPoint(ENTRY_POINT);
44+
}
45+
46+
/**
47+
* Get active Milestone for the Contract
48+
*
49+
* @param contractId Contract reference
50+
* @throws JSONException If error occurred
51+
* @return {@link JSONObject}
52+
*/
53+
public JSONObject getActiveMilestone(String contractId) throws JSONException {
54+
return oClient.get("/hr/v3/fp/milestones/statuses/active/contracts/" + contractId);
55+
}
56+
57+
/**
58+
* Get all submissions for the active Milestone
59+
*
60+
* @param milestoneId Milestone ID
61+
* @throws JSONException If error occurred
62+
* @return {@link JSONObject}
63+
*/
64+
public JSONObject getSubmissions(String milestoneId) throws JSONException {
65+
return oClient.get("/hr/v3/fp/milestones/" + milestoneId + "/submissions");
66+
}
67+
68+
/**
69+
* Create a new Milestone
70+
*
71+
* @param params Parameters
72+
* @throws JSONException If error occurred
73+
* @return {@link JSONObject}
74+
*/
75+
public JSONObject create(HashMap<String, String> params) throws JSONException {
76+
return oClient.post("/hr/v3/fp/milestones", params);
77+
}
78+
79+
/**
80+
* Edit an existing Milestone
81+
*
82+
* @param milestoneId Milestone ID
83+
* @param params Parameters
84+
* @throws JSONException If error occurred
85+
* @return {@link JSONObject}
86+
*/
87+
public JSONObject edit(String milestoneId, HashMap<String, String> params) throws JSONException {
88+
return oClient.put("/hr/v3/fp/milestones/" + milestoneId, params);
89+
}
90+
91+
/**
92+
* Activate an existing Milestone
93+
*
94+
* @param milestoneId Milestone ID
95+
* @param params Parameters
96+
* @throws JSONException If error occurred
97+
* @return {@link JSONObject}
98+
*/
99+
public JSONObject activate(String milestoneId, HashMap<String, String> params) throws JSONException {
100+
return oClient.put("/hr/v3/fp/milestones/" + milestoneId + "/activate", params);
101+
}
102+
103+
/**
104+
* Approve an existing Milestone
105+
*
106+
* @param milestoneId Milestone ID
107+
* @param params Parameters
108+
* @throws JSONException If error occurred
109+
* @return {@link JSONObject}
110+
*/
111+
public JSONObject approve(String milestoneId, HashMap<String, String> params) throws JSONException {
112+
return oClient.put("/hr/v3/fp/milestones/" + milestoneId + "/approve", params);
113+
}
114+
115+
/**
116+
* Delete an existing Milestone
117+
*
118+
* @param milestoneId Milestone ID
119+
* @throws JSONException If error occurred
120+
* @return {@link JSONObject}
121+
*/
122+
public JSONObject delete(String milestoneId) throws JSONException {
123+
return oClient.delete("/hr/v3/fp/milestones/" + milestoneId);
124+
}
125+
126+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Copyright 2014 oDesk
3+
*
4+
* Licensed under the oDesk's API Terms of Use;
5+
* you may not use this file except in compliance with the Terms.
6+
* You may obtain a copy of the Terms at
7+
*
8+
* http://developers.odesk.com/API-Terms-of-Use
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.oDesk.api.Routers.Hr;
18+
19+
import java.util.HashMap;
20+
21+
import com.oDesk.ClassPreamble;
22+
import com.oDesk.api.OAuthClient;
23+
24+
import org.json.JSONException;
25+
import org.json.JSONObject;
26+
27+
@ClassPreamble (
28+
author = "Maksym Novozhylov <mnovozhilov@odesk.com>",
29+
date = "11/17/2014",
30+
currentRevision = 1,
31+
lastModified = "11/17/2014",
32+
lastModifiedBy = "Maksym Novozhylov",
33+
reviewers = {"Yiota Tsakiri"}
34+
)
35+
public final class Submissions {
36+
37+
final static String ENTRY_POINT = "api";
38+
39+
private OAuthClient oClient = null;
40+
41+
public Submissions(OAuthClient client) {
42+
oClient = client;
43+
oClient.setEntryPoint(ENTRY_POINT);
44+
}
45+
46+
/**
47+
* Freelancer submits work for the client to approve
48+
*
49+
* @param params Parameters
50+
* @throws JSONException If error occurred
51+
* @return {@link JSONObject}
52+
*/
53+
public JSONObject requestApproval(HashMap<String, String> params) throws JSONException {
54+
return oClient.post("/hr/v3/fp/submissions", params);
55+
}
56+
57+
/**
58+
* Approve an existing Submission
59+
*
60+
* @param submissionId Submission ID
61+
* @param params Parameters
62+
* @throws JSONException If error occurred
63+
* @return {@link JSONObject}
64+
*/
65+
public JSONObject approve(String submissionId, HashMap<String, String> params) throws JSONException {
66+
return oClient.put("/hr/v3/fp/submissions/" + submissionId + "/approve", params);
67+
}
68+
69+
/**
70+
* Reject an existing Submission
71+
*
72+
* @param submissionId Submission ID
73+
* @param params Parameters
74+
* @throws JSONException If error occurred
75+
* @return {@link JSONObject}
76+
*/
77+
public JSONObject reject(String submissionId, HashMap<String, String> params) throws JSONException {
78+
return oClient.put("/hr/v3/fp/submissions/" + submissionId + "/reject", params);
79+
}
80+
81+
}

src/com/oDesk/api/Routers/Workdiary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Workdiary(OAuthClient client) {
5454
* @return {@link JSONObject}
5555
*/
5656
public JSONObject get(String company, String username, String date, HashMap<String, String> params) throws JSONException {
57-
return oClient.get("/team/v1/workdiaries/" + company + "/" + "username" + "/" + date, params);
57+
return oClient.get("/team/v1/workdiaries/" + company + "/" + username + "/" + date, params);
5858
}
5959

6060
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.oDesk.api.Routers.Hr;
2+
3+
import static org.junit.Assert.*;
4+
5+
import java.util.HashMap;
6+
7+
import org.json.JSONObject;
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
import org.powermock.core.classloader.annotations.PrepareForTest;
11+
import org.powermock.modules.junit4.PowerMockRunner;
12+
13+
import com.oDesk.api.Routers.Helper;
14+
import com.oDesk.api.Routers.Hr.Milestones;
15+
16+
@RunWith(PowerMockRunner.class)
17+
@PrepareForTest({
18+
Milestones.class
19+
})
20+
public class MilestonesTest extends Helper {
21+
@Test public void getActiveMilestone() throws Exception {
22+
Milestones milestones = new Milestones(client);
23+
JSONObject json = milestones.getActiveMilestone("1234");
24+
25+
assertTrue(json instanceof JSONObject);
26+
}
27+
28+
@Test public void getSubmissions() throws Exception {
29+
Milestones milestones = new Milestones(client);
30+
JSONObject json = milestones.getSubmissions("1234");
31+
32+
assertTrue(json instanceof JSONObject);
33+
}
34+
35+
@Test public void create() throws Exception {
36+
Milestones milestones = new Milestones(client);
37+
JSONObject json = milestones.create(new HashMap<String, String>());
38+
39+
assertTrue(json instanceof JSONObject);
40+
}
41+
42+
@Test public void edit() throws Exception {
43+
Milestones milestones = new Milestones(client);
44+
JSONObject json = milestones.edit("1234", new HashMap<String, String>());
45+
46+
assertTrue(json instanceof JSONObject);
47+
}
48+
49+
@Test public void activate() throws Exception {
50+
Milestones milestones = new Milestones(client);
51+
JSONObject json = milestones.activate("1234", new HashMap<String, String>());
52+
53+
assertTrue(json instanceof JSONObject);
54+
}
55+
56+
@Test public void approve() throws Exception {
57+
Milestones milestones = new Milestones(client);
58+
JSONObject json = milestones.approve("1234", new HashMap<String, String>());
59+
60+
assertTrue(json instanceof JSONObject);
61+
}
62+
63+
@Test public void delete() throws Exception {
64+
Milestones milestones = new Milestones(client);
65+
JSONObject json = milestones.delete("1234");
66+
67+
assertTrue(json instanceof JSONObject);
68+
}
69+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.oDesk.api.Routers.Hr;
2+
3+
import static org.junit.Assert.*;
4+
5+
import java.util.HashMap;
6+
7+
import org.json.JSONObject;
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
import org.powermock.core.classloader.annotations.PrepareForTest;
11+
import org.powermock.modules.junit4.PowerMockRunner;
12+
13+
import com.oDesk.api.Routers.Helper;
14+
import com.oDesk.api.Routers.Hr.Submissions;
15+
16+
@RunWith(PowerMockRunner.class)
17+
@PrepareForTest({
18+
Submissions.class
19+
})
20+
public class SubmissionsTest extends Helper {
21+
@Test public void requestApproval() throws Exception {
22+
Submissions submissions = new Submissions(client);
23+
JSONObject json = submissions.requestApproval(new HashMap<String, String>());
24+
25+
assertTrue(json instanceof JSONObject);
26+
}
27+
28+
@Test public void approve() throws Exception {
29+
Submissions submissions = new Submissions(client);
30+
JSONObject json = submissions.approve("1234", new HashMap<String, String>());
31+
32+
assertTrue(json instanceof JSONObject);
33+
}
34+
35+
@Test public void reject() throws Exception {
36+
Submissions submissions = new Submissions(client);
37+
JSONObject json = submissions.reject("1234", new HashMap<String, String>());
38+
39+
assertTrue(json instanceof JSONObject);
40+
}
41+
}

0 commit comments

Comments
 (0)