-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from upwork/v1.0.1
v1.0.1
- Loading branch information
Showing
6 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]>", | ||
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |