Skip to content

Commit

Permalink
Merge pull request #7 from upwork/v1.2.0
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
mnovozhylov authored Jun 14, 2016
2 parents 7ca3c7c + da50841 commit 40c694a
Show file tree
Hide file tree
Showing 11 changed files with 250 additions and 268 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## 1.2.0
* Added Messages API (new)
* Message API (V1) is now fully depricated

## 1.1.1
* Add optional parameter to support pagination in getTrayByType

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ These are the supported API resources:
* Job and Freelancer Profile
* Search Jobs and Freelancers
* Organization
* MC
* Messages
* Time and Financial Reporting
* Metadata
* Snapshot
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.
15 changes: 0 additions & 15 deletions example/src/TestApi.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import com.Upwork.api.*;
import com.Upwork.api.Routers.Organization.Users;
import com.Upwork.api.Routers.Mc;
import com.Upwork.api.Routers.Reports.Time;

import java.util.HashMap;
Expand Down Expand Up @@ -82,26 +81,12 @@ public static void main(String[] args) {
params2.put("tq", "select task where worked_on >= '2014-06-01' AND worked_on <= '2014-06-03' order by worked_on");
Time report = new Time(client);
json2 = report.getByFreelancerLimited(myId, params2);

// post a new message
/*HashMap<String, String> params2 = new HashMap<String, String>();
params2.put("recipients", "invalid");
params2.put("body", "body of the message");
Mc mc = new Mc(client);
json2 = mc.startNewThread(myId, params2);*/

// mark thread as read
HashMap<String, String> params3 = new HashMap<String, String>();
params3.put("read", "true");
Mc mc = new Mc(client);
json3 = mc.markThread(myId, "8888888", params3);
}
catch (JSONException e) {
e.printStackTrace();
}

System.out.println(json1);
System.out.println(json2);
System.out.println(json3);
}
}
Binary file modified lib/java-upwork.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>com.Upwork</groupId>
<artifactId>api</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
<packaging>jar</packaging>
<name>java-upwork</name>
<description>JAVA bindings for Upwork API</description>
Expand Down
169 changes: 0 additions & 169 deletions src/com/Upwork/api/Routers/Mc.java

This file was deleted.

157 changes: 157 additions & 0 deletions src/com/Upwork/api/Routers/Messages.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
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 = "6/6/2014",
currentRevision = 1,
lastModified = "6/6/2014",
lastModifiedBy = "Maksym Novozhylov",
reviewers = {"Yiota Tsakiri"}
)
public final class Messages {

final static String ENTRY_POINT = "api";

private OAuthClient oClient = null;

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

/**
* Retrieve rooms information
*
* @param company Company ID
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject getRooms(String company) throws JSONException {
return oClient.get("/messages/v3/" + company + "/rooms");
}

/**
* Retrieve rooms information with params
*
* @param company Company ID
* @param params Parameters
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject getRooms(String company, HashMap<String, String> params) throws JSONException {
return oClient.get("/messages/v3/" + company + "/rooms", params);
}

/**
* Get a specific room information
*
* @param company Company ID
* @param roomId Room ID
* @param params Parameters
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject getRoomDetails(String company, String roomId, HashMap<String, String> params) throws JSONException {
return oClient.get("/messages/v3/" + company + "/rooms/" + roomId, params);
}

/**
* Get a specific room by offer ID
*
* @param company Company ID
* @param offerId Offer ID
* @param params Parameters
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject getRoomByOffer(String company, String offerId, HashMap<String, String> params) throws JSONException {
return oClient.get("/messages/v3/" + company + "/rooms/offers/" + offerId, params);
}

/**
* Get a specific room by application ID
*
* @param company Company ID
* @param applicationId Application ID
* @param params Parameters
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject getRoomByApplication(String company, String applicationId, HashMap<String, String> params) throws JSONException {
return oClient.get("/messages/v3/" + company + "/rooms/appications/" + applicationId, params);
}

/**
* Get a specific room by contract ID
*
* @param company Company ID
* @param contractId Contract ID
* @param params Parameters
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject getRoomByContract(String company, String contractId, HashMap<String, String> params) throws JSONException {
return oClient.get("/messages/v3/" + company + "/rooms/contracts/" + contractId, params);
}

/**
* Create a new room
*
* @param company Company ID
* @param params Parameters
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject createRoom(String company, HashMap<String, String> params) throws JSONException {
return oClient.post("/messages/v3/" + company + "/rooms", params);
}

/**
* Send a message to a room
*
* @param company Company ID
* @param roomId Room ID
* @param params Parameters
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject sendMessageToRoom(String company, String roomId, HashMap<String, String> params) throws JSONException {
return oClient.post("/messages/v3/" + company + "/rooms/" + roomId + "/stories", params);
}

/**
* Update a room settings
*
* @param company Company ID
* @param roomId Room ID
* @param username User ID
* @param params Parameters
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject updateRoomSettings(String company, String roomId, String username, HashMap<String, String> params) throws JSONException {
return oClient.get("/messages/v3/" + company + "/rooms/" + roomId + "/users/" + username, params);
}

/**
* Update the metadata of a room
*
* @param company Company ID
* @param roomId Room ID
* @param params Parameters
* @throws JSONException If error occurred
* @return {@link JSONObject}
*/
public JSONObject updateRoomMetadata(String company, String roomId, HashMap<String, String> params) throws JSONException {
return oClient.get("/messages/v3/" + company + "/rooms/" + roomId, params);
}

}
Loading

0 comments on commit 40c694a

Please sign in to comment.