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

Commit

Permalink
Merge branch 'v0.1.11'
Browse files Browse the repository at this point in the history
Conflicts:
	example-android/app/libs/java-odesk.jar
  • Loading branch information
Maksym Novozhylov committed Dec 10, 2014
2 parents 7dc3f71 + 28a7929 commit 5a91f6c
Show file tree
Hide file tree
Showing 10 changed files with 333 additions and 3 deletions.
13 changes: 13 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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`.
Make sure you've added consumer key and secret to the `example/odesk.properties`.
Binary file modified doc/java-odesk-javadoc.zip
Binary file not shown.
Binary file modified example-android/app/libs/java-odesk.jar
Binary file not shown.
Binary file modified lib/java-odesk.jar
Binary file not shown.
126 changes: 126 additions & 0 deletions src/com/oDesk/api/Routers/Hr/Milestones.java
Original file line number Diff line number Diff line change
@@ -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 <mnovozhilov@odesk.com>",
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<String, String> 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<String, String> 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<String, String> 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<String, String> 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);
}

}
81 changes: 81 additions & 0 deletions src/com/oDesk/api/Routers/Hr/Submissions.java
Original file line number Diff line number Diff line change
@@ -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 <mnovozhilov@odesk.com>",
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<String, String> 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<String, String> 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<String, String> params) throws JSONException {
return oClient.put("/hr/v3/fp/submissions/" + submissionId + "/reject", params);
}

}
2 changes: 1 addition & 1 deletion src/com/oDesk/api/Routers/Workdiary.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Workdiary(OAuthClient client) {
* @return {@link JSONObject}
*/
public JSONObject get(String company, String username, String date, HashMap<String, String> params) throws JSONException {
return oClient.get("/team/v1/workdiaries/" + company + "/" + "username" + "/" + date, params);
return oClient.get("/team/v1/workdiaries/" + company + "/" + username + "/" + date, params);
}

}
69 changes: 69 additions & 0 deletions test/com/oDesk/api/Routers/Hr/MilestonesTest.java
Original file line number Diff line number Diff line change
@@ -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<String, String>());

assertTrue(json instanceof JSONObject);
}

@Test public void edit() throws Exception {
Milestones milestones = new Milestones(client);
JSONObject json = milestones.edit("1234", new HashMap<String, String>());

assertTrue(json instanceof JSONObject);
}

@Test public void activate() throws Exception {
Milestones milestones = new Milestones(client);
JSONObject json = milestones.activate("1234", new HashMap<String, String>());

assertTrue(json instanceof JSONObject);
}

@Test public void approve() throws Exception {
Milestones milestones = new Milestones(client);
JSONObject json = milestones.approve("1234", new HashMap<String, String>());

assertTrue(json instanceof JSONObject);
}

@Test public void delete() throws Exception {
Milestones milestones = new Milestones(client);
JSONObject json = milestones.delete("1234");

assertTrue(json instanceof JSONObject);
}
}
41 changes: 41 additions & 0 deletions test/com/oDesk/api/Routers/Hr/SubmissionsTest.java
Original file line number Diff line number Diff line change
@@ -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<String, String>());

assertTrue(json instanceof JSONObject);
}

@Test public void approve() throws Exception {
Submissions submissions = new Submissions(client);
JSONObject json = submissions.approve("1234", new HashMap<String, String>());

assertTrue(json instanceof JSONObject);
}

@Test public void reject() throws Exception {
Submissions submissions = new Submissions(client);
JSONObject json = submissions.reject("1234", new HashMap<String, String>());

assertTrue(json instanceof JSONObject);
}
}

0 comments on commit 5a91f6c

Please sign in to comment.