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

Commit 3318400

Browse files
committed
v1.2.0
1 parent 7ca3c7c commit 3318400

File tree

10 files changed

+234
-268
lines changed

10 files changed

+234
-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
1.73 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

1.73 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: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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+
* Retrive 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+
* Get a specific room information
43+
*
44+
* @param company Company ID
45+
* @param roomId Room ID
46+
* @param params Parameters
47+
* @throws JSONException If error occurred
48+
* @return {@link JSONObject}
49+
*/
50+
public JSONObject getRoomDetails(String company, String roomId, HashMap<String, String> params) throws JSONException {
51+
return oClient.get("/messages/v3/" + company + "/rooms/" + roomId, params);
52+
}
53+
54+
/**
55+
* Get a specific room by offer ID
56+
*
57+
* @param company Company ID
58+
* @param offerId Offer ID
59+
* @param params Parameters
60+
* @throws JSONException If error occurred
61+
* @return {@link JSONObject}
62+
*/
63+
public JSONObject getRoomByOffer(String company, String offerId, HashMap<String, String> params) throws JSONException {
64+
return oClient.get("/messages/v3/" + company + "/rooms/offers/" + offerId, params);
65+
}
66+
67+
/**
68+
* Get a specific room by application ID
69+
*
70+
* @param company Company ID
71+
* @param applicationId Application ID
72+
* @param params Parameters
73+
* @throws JSONException If error occurred
74+
* @return {@link JSONObject}
75+
*/
76+
public JSONObject getRoomByApplication(String company, String applicationId, HashMap<String, String> params) throws JSONException {
77+
return oClient.get("/messages/v3/" + company + "/rooms/appications/" + applicationId, params);
78+
}
79+
80+
/**
81+
* Get a specific room by contract ID
82+
*
83+
* @param company Company ID
84+
* @param contractId Contract ID
85+
* @param params Parameters
86+
* @throws JSONException If error occurred
87+
* @return {@link JSONObject}
88+
*/
89+
public JSONObject getRoomByContract(String company, String contractId, HashMap<String, String> params) throws JSONException {
90+
return oClient.get("/messages/v3/" + company + "/rooms/contracts/" + contractId, params);
91+
}
92+
93+
/**
94+
* Create a new room
95+
*
96+
* @param company Company ID
97+
* @param params Parameters
98+
* @throws JSONException If error occurred
99+
* @return {@link JSONObject}
100+
*/
101+
public JSONObject createRoom(String company, HashMap<String, String> params) throws JSONException {
102+
return oClient.post("/messages/v3/" + company + "/rooms", params);
103+
}
104+
105+
/**
106+
* Send a message to a room
107+
*
108+
* @param company Company ID
109+
* @param roomId Room ID
110+
* @param params Parameters
111+
* @throws JSONException If error occurred
112+
* @return {@link JSONObject}
113+
*/
114+
public JSONObject sendMessageToRoom(String company, String roomId, HashMap<String, String> params) throws JSONException {
115+
return oClient.post("/messages/v3/" + company + "/rooms/" + roomId + "/stories", params);
116+
}
117+
118+
/**
119+
* Update a room settings
120+
*
121+
* @param company Company ID
122+
* @param roomId Room ID
123+
* @param username User ID
124+
* @param params Parameters
125+
* @throws JSONException If error occurred
126+
* @return {@link JSONObject}
127+
*/
128+
public JSONObject updateRoomSettings(String company, String roomId, String username, HashMap<String, String> params) throws JSONException {
129+
return oClient.get("/messages/v3/" + company + "/rooms/" + roomId + "/users/" + username, params);
130+
}
131+
132+
/**
133+
* Update the metadata of a room
134+
*
135+
* @param company Company ID
136+
* @param roomId Room ID
137+
* @param params Parameters
138+
* @throws JSONException If error occurred
139+
* @return {@link JSONObject}
140+
*/
141+
public JSONObject updateRoomMetadata(String company, String roomId, HashMap<String, String> params) throws JSONException {
142+
return oClient.get("/messages/v3/" + company + "/rooms/" + roomId, params);
143+
}
144+
145+
}

0 commit comments

Comments
 (0)