Skip to content

Commit

Permalink
Merge pull request #1 from upwork/v1.0.1
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
mnovozhylov committed Jul 17, 2015
2 parents 6045e85 + 53d7032 commit f910c75
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release History

## 1.0.1
* Added new Workdays API - Get Workdays by Comppany
* Added new Workdays API - Get Workdays by Contract

## 1.0.0
* welcome to Upwork!

## 0.1.14
* Added new Snapshot API - Get Snapshot by Contract
* Added new Snapshot API - Update Snapshot memo by Contract
Expand Down
Binary file modified doc/java-upwork-javadoc.zip
Binary file not shown.
Binary file modified example-android/app/libs/java-upwork.jar
Binary file not shown.
Binary file modified lib/java-upwork.jar
Binary file not shown.
74 changes: 74 additions & 0 deletions src/com/Upwork/api/Routers/Workdays.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Copyright 2015 Upwork
*
* Licensed under the Upwork'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
*
* https://developers.upwork.com/api-tos.html
*
* 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.Upwork.api.Routers;

import java.util.HashMap;

import com.Upwork.ClassPreamble;
import com.Upwork.api.OAuthClient;

import org.json.JSONException;
import org.json.JSONObject;

@ClassPreamble (
author = "Maksym Novozhylov <mnovozhilov@upwork.com>",
date = "14/7/2015",
currentRevision = 1,
lastModified = "14/7/2015",
lastModifiedBy = "Maksym Novozhylov",
reviewers = {"Yiota Tsakiri"}
)
public final class Workdays {

final static String ENTRY_POINT = "api";

private OAuthClient oClient = null;

public Workdays(OAuthClient client) {
oClient = client;
oClient.setEntryPoint(ENTRY_POINT);
}

/**
* Get Workdays by Company
*
* @param company Company ID
* @param fromDate Start date
* @param tillDate End date
* @param params (Optional) Parameters
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject getByCompany(String company, String fromDate, String tillDate, HashMap<String, String> params) throws JSONException {
return oClient.get("/team/v2/workdays/companies/" + company + "/" + fromDate + "," + tillDate, params);
}

/**
* Get Workdays by Contract
*
* @param contract Contract ID
* @param fromDate Start date
* @param tillDate End date
* @param params (Optional) Parameters
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject getByContract(String contract, String fromDate, String tillDate, HashMap<String, String> params) throws JSONException {
return oClient.get("/team/v2/workdays/contracts/" + contract + "/" + fromDate + "," + tillDate, params);
}

}
34 changes: 34 additions & 0 deletions test/com/Upwork/api/Routers/WorkdaysTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.Upwork.api.Routers;

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.Upwork.api.Routers.Helper;
import com.Upwork.api.Routers.Workdays;

@RunWith(PowerMockRunner.class)
@PrepareForTest({
Workdiary.class
})
public class WorkdaysTest extends Helper {
@Test public void getByCompany() throws Exception {
Workdays workdays = new Workdays(client);
JSONObject json = workdays.getByCompany("company", "20140101", "20140131", new HashMap<String, String>());

assertTrue(json instanceof JSONObject);
}

@Test public void getByContract() throws Exception {
Workdays workdays = new Workdays(client);
JSONObject json = workdays.getByContract("company", "20140101", "20140131", new HashMap<String, String>());

assertTrue(json instanceof JSONObject);
}
}

0 comments on commit f910c75

Please sign in to comment.