Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.

Commit 40c694a

Browse files
authored
Merge pull request #7 from upwork/v1.2.0
v1.2.0
2 parents 7ca3c7c + da50841 commit 40c694a

File tree

11 files changed

+250
-268
lines changed

11 files changed

+250
-268
lines changed

CHANGES.md

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

3+
## 1.2.0
4+
* Added Messages API (new)
5+
* Message API (V1) is now fully depricated
6+
37
## 1.1.1
48
* Add optional parameter to support pagination in getTrayByType
59

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ These are the supported API resources:
1919
* Job and Freelancer Profile
2020
* Search Jobs and Freelancers
2121
* Organization
22-
* MC
22+
* Messages
2323
* Time and Financial Reporting
2424
* Metadata
2525
* Snapshot

doc/java-upwork-javadoc.zip

-241 Bytes
Binary file not shown.
-6.05 KB
Binary file not shown.

example/src/TestApi.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import com.Upwork.api.*;
22
import com.Upwork.api.Routers.Organization.Users;
3-
import com.Upwork.api.Routers.Mc;
43
import com.Upwork.api.Routers.Reports.Time;
54

65
import java.util.HashMap;
@@ -82,26 +81,12 @@ public static void main(String[] args) {
8281
params2.put("tq", "select task where worked_on >= '2014-06-01' AND worked_on <= '2014-06-03' order by worked_on");
8382
Time report = new Time(client);
8483
json2 = report.getByFreelancerLimited(myId, params2);
85-
86-
// post a new message
87-
/*HashMap<String, String> params2 = new HashMap<String, String>();
88-
params2.put("recipients", "invalid");
89-
params2.put("body", "body of the message");
90-
Mc mc = new Mc(client);
91-
json2 = mc.startNewThread(myId, params2);*/
92-
93-
// mark thread as read
94-
HashMap<String, String> params3 = new HashMap<String, String>();
95-
params3.put("read", "true");
96-
Mc mc = new Mc(client);
97-
json3 = mc.markThread(myId, "8888888", params3);
9884
}
9985
catch (JSONException e) {
10086
e.printStackTrace();
10187
}
10288

10389
System.out.println(json1);
10490
System.out.println(json2);
105-
System.out.println(json3);
10691
}
10792
}

lib/java-upwork.jar

-6.05 KB
Binary file not shown.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>com.Upwork</groupId>
55
<artifactId>api</artifactId>
6-
<version>1.1.0</version>
6+
<version>1.2.0</version>
77
<packaging>jar</packaging>
88
<name>java-upwork</name>
99
<description>JAVA bindings for Upwork API</description>

src/com/Upwork/api/Routers/Mc.java

Lines changed: 0 additions & 169 deletions
This file was deleted.
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
package com.Upwork.api.Routers;
2+
3+
import java.util.HashMap;
4+
5+
import com.Upwork.ClassPreamble;
6+
import com.Upwork.api.OAuthClient;
7+
8+
import org.json.JSONException;
9+
import org.json.JSONObject;
10+
11+
@ClassPreamble (
12+
author = "Maksym Novozhylov <[email protected]>",
13+
date = "6/6/2014",
14+
currentRevision = 1,
15+
lastModified = "6/6/2014",
16+
lastModifiedBy = "Maksym Novozhylov",
17+
reviewers = {"Yiota Tsakiri"}
18+
)
19+
public final class Messages {
20+
21+
final static String ENTRY_POINT = "api";
22+
23+
private OAuthClient oClient = null;
24+
25+
public Messages(OAuthClient client) {
26+
oClient = client;
27+
oClient.setEntryPoint(ENTRY_POINT);
28+
}
29+
30+
/**
31+
* Retrieve rooms information
32+
*
33+
* @param company Company ID
34+
* @throws JSONException If error occurred
35+
* @return {@link JSONObject}
36+
*/
37+
public JSONObject getRooms(String company) throws JSONException {
38+
return oClient.get("/messages/v3/" + company + "/rooms");
39+
}
40+
41+
/**
42+
* Retrieve rooms information with params
43+
*
44+
* @param company Company ID
45+
* @param params Parameters
46+
* @throws JSONException If error occurred
47+
* @return {@link JSONObject}
48+
*/
49+
public JSONObject getRooms(String company, HashMap<String, String> params) throws JSONException {
50+
return oClient.get("/messages/v3/" + company + "/rooms", params);
51+
}
52+
53+
/**
54+
* Get a specific room information
55+
*
56+
* @param company Company ID
57+
* @param roomId Room ID
58+
* @param params Parameters
59+
* @throws JSONException If error occurred
60+
* @return {@link JSONObject}
61+
*/
62+
public JSONObject getRoomDetails(String company, String roomId, HashMap<String, String> params) throws JSONException {
63+
return oClient.get("/messages/v3/" + company + "/rooms/" + roomId, params);
64+
}
65+
66+
/**
67+
* Get a specific room by offer ID
68+
*
69+
* @param company Company ID
70+
* @param offerId Offer ID
71+
* @param params Parameters
72+
* @throws JSONException If error occurred
73+
* @return {@link JSONObject}
74+
*/
75+
public JSONObject getRoomByOffer(String company, String offerId, HashMap<String, String> params) throws JSONException {
76+
return oClient.get("/messages/v3/" + company + "/rooms/offers/" + offerId, params);
77+
}
78+
79+
/**
80+
* Get a specific room by application ID
81+
*
82+
* @param company Company ID
83+
* @param applicationId Application ID
84+
* @param params Parameters
85+
* @throws JSONException If error occurred
86+
* @return {@link JSONObject}
87+
*/
88+
public JSONObject getRoomByApplication(String company, String applicationId, HashMap<String, String> params) throws JSONException {
89+
return oClient.get("/messages/v3/" + company + "/rooms/appications/" + applicationId, params);
90+
}
91+
92+
/**
93+
* Get a specific room by contract ID
94+
*
95+
* @param company Company ID
96+
* @param contractId Contract ID
97+
* @param params Parameters
98+
* @throws JSONException If error occurred
99+
* @return {@link JSONObject}
100+
*/
101+
public JSONObject getRoomByContract(String company, String contractId, HashMap<String, String> params) throws JSONException {
102+
return oClient.get("/messages/v3/" + company + "/rooms/contracts/" + contractId, params);
103+
}
104+
105+
/**
106+
* Create a new room
107+
*
108+
* @param company Company ID
109+
* @param params Parameters
110+
* @throws JSONException If error occurred
111+
* @return {@link JSONObject}
112+
*/
113+
public JSONObject createRoom(String company, HashMap<String, String> params) throws JSONException {
114+
return oClient.post("/messages/v3/" + company + "/rooms", params);
115+
}
116+
117+
/**
118+
* Send a message to a room
119+
*
120+
* @param company Company ID
121+
* @param roomId Room ID
122+
* @param params Parameters
123+
* @throws JSONException If error occurred
124+
* @return {@link JSONObject}
125+
*/
126+
public JSONObject sendMessageToRoom(String company, String roomId, HashMap<String, String> params) throws JSONException {
127+
return oClient.post("/messages/v3/" + company + "/rooms/" + roomId + "/stories", params);
128+
}
129+
130+
/**
131+
* Update a room settings
132+
*
133+
* @param company Company ID
134+
* @param roomId Room ID
135+
* @param username User ID
136+
* @param params Parameters
137+
* @throws JSONException If error occurred
138+
* @return {@link JSONObject}
139+
*/
140+
public JSONObject updateRoomSettings(String company, String roomId, String username, HashMap<String, String> params) throws JSONException {
141+
return oClient.get("/messages/v3/" + company + "/rooms/" + roomId + "/users/" + username, params);
142+
}
143+
144+
/**
145+
* Update the metadata of a room
146+
*
147+
* @param company Company ID
148+
* @param roomId Room ID
149+
* @param params Parameters
150+
* @throws JSONException If error occurred
151+
* @return {@link JSONObject}
152+
*/
153+
public JSONObject updateRoomMetadata(String company, String roomId, HashMap<String, String> params) throws JSONException {
154+
return oClient.get("/messages/v3/" + company + "/rooms/" + roomId, params);
155+
}
156+
157+
}

0 commit comments

Comments
 (0)