Skip to content

Commit 3627254

Browse files
committed
feat(legacy): deprecate calls to legacy api
1 parent d8f000b commit 3627254

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+287
-613
lines changed

example/src/TestApi.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import com.Upwork.api.OAuthClient;
22
import com.Upwork.api.Routers.Graphql;
3-
import com.Upwork.api.Routers.Organization.Users;
43
import com.google.api.client.auth.oauth2.TokenResponse;
54
import org.json.JSONException;
65
import org.json.JSONObject;
@@ -54,26 +53,7 @@ public static void main(String[] args) throws Exception {
5453
// client.getTokenResponseByRefreshToken(tokenResponse.getRefreshToken(), null);
5554
// System.out.println(refreshedTokenResponse.getAccessToken());
5655

57-
JSONObject json1 = null;
58-
try {
59-
// Get info of authenticated user
60-
Users users = new Users(client);
61-
json1 = users.getMyInfo();
62-
63-
// get my uid
64-
String myId = null;
65-
try {
66-
JSONObject user = json1.getJSONObject("user");
67-
myId = user.getString("id");
68-
System.out.println(myId);
69-
} catch (JSONException e) {
70-
e.printStackTrace();
71-
}
72-
} catch (JSONException e) {
73-
e.printStackTrace();
74-
}
75-
76-
JSONObject json2 = null;
56+
JSONObject json = null;
7757
HashMap<String, String> params = new HashMap<String, String>();
7858
params.put("query", "{\n" +
7959
" user {\n" +
@@ -89,12 +69,12 @@ public static void main(String[] args) throws Exception {
8969
// client.setOrgUidHeader("1234567890"); // Organization UID (optional)
9070
// Get info of authenticated user using GraphQL query
9171
Graphql graphql = new Graphql(client);
92-
json2 = graphql.Execute(params);
72+
json = graphql.Execute(params);
9373

9474
// get my uid
9575
String myUid = null;
9676
try {
97-
JSONObject data = json2.getJSONObject("data");
77+
JSONObject data = json.getJSONObject("data");
9878
myUid = data.getJSONObject("user").getString("id");
9979
System.out.println(myUid);
10080
} catch (JSONException e) {

lib/java-upwork.jar

-8 Bytes
Binary file not shown.

pom.xml

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

55
<groupId>com.Upwork</groupId>
66
<artifactId>api</artifactId>
7-
<version>2.2.1</version>
7+
<version>2.3.0</version>
88
<packaging>jar</packaging>
99
<name>java-upwork-oauth2</name>
1010
<description>JAVA bindings for Upwork API (OAuth2)</description>

src/com/Upwork/api/Routers/Activities/Engagement.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Engagement(OAuthClient client) {
5151
* @return {@link JSONObject}
5252
*/
5353
public JSONObject getSpecific(String engagement_ref) throws JSONException {
54-
return oClient.get("/tasks/v2/tasks/contracts/" + engagement_ref);
54+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5555
}
5656

5757
/**
@@ -65,7 +65,7 @@ public JSONObject getSpecific(String engagement_ref) throws JSONException {
6565
* @return {@link JSONObject}
6666
*/
6767
public JSONObject assign(String company, String team, String engagement, HashMap<String, String> params) throws JSONException {
68-
return oClient.put("/otask/v1/tasks/companies/" + company + "/teams/" + team + "/engagements/" + engagement + "/tasks", params);
68+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
6969
}
7070

7171
/**
@@ -77,7 +77,7 @@ public JSONObject assign(String company, String team, String engagement, HashMap
7777
* @return {@link JSONObject}
7878
*/
7979
public JSONObject assignToEngagement(String engagement_ref, HashMap<String, String> params) throws JSONException {
80-
return oClient.put("/tasks/v2/tasks/contracts/" + engagement_ref, params);
80+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
8181
}
8282

8383
}

src/com/Upwork/api/Routers/Activities/Team.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private JSONObject _getByType(String company, String team, String code) throws J
5858
url = "/" + code;
5959
}
6060

61-
return oClient.get("/otask/v1/tasks/companies/" + company + "/teams/" + team + "/tasks" + url);
61+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
6262
}
6363

6464
/**
@@ -95,7 +95,7 @@ public JSONObject getSpecificList(String company, String team, String code) thro
9595
* @return {@link JSONObject}
9696
*/
9797
public JSONObject addActivity(String company, String team, HashMap<String, String> params) throws JSONException {
98-
return oClient.post("/otask/v1/tasks/companies/" + company + "/teams/" + team + "/tasks", params);
98+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
9999
}
100100

101101
/**
@@ -109,7 +109,7 @@ public JSONObject addActivity(String company, String team, HashMap<String, Strin
109109
* @return {@link JSONObject}
110110
*/
111111
public JSONObject updateActivity(String company, String team, String code, HashMap<String, String> params) throws JSONException {
112-
return oClient.put("/otask/v1/tasks/companies/" + company + "/teams/" + team + "/tasks/" + code, params);
112+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
113113
}
114114

115115
/**
@@ -122,7 +122,7 @@ public JSONObject updateActivity(String company, String team, String code, HashM
122122
* @return {@link JSONObject}
123123
*/
124124
public JSONObject archiveActivity(String company, String team, String code) throws JSONException {
125-
return oClient.put("/otask/v1/tasks/companies/" + company + "/teams/" + team + "/archive/" + code);
125+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
126126
}
127127

128128
/**
@@ -135,7 +135,7 @@ public JSONObject archiveActivity(String company, String team, String code) thro
135135
* @return {@link JSONObject}
136136
*/
137137
public JSONObject unarchiveActivity(String company, String team, String code) throws JSONException {
138-
return oClient.put("/otask/v1/tasks/companies/" + company + "/teams/" + team + "/unarchive/" + code);
138+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
139139
}
140140

141141
/**
@@ -147,7 +147,7 @@ public JSONObject unarchiveActivity(String company, String team, String code) th
147147
* @return {@link JSONObject}
148148
*/
149149
public JSONObject updateBatch(String company, HashMap<String, String> params) throws JSONException {
150-
return oClient.put("/otask/v1/tasks/companies/" + company + "/tasks/batch", params);
150+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
151151
}
152152

153153
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public Auth(OAuthClient client) {
4848
* @return {@link JSONObject}
4949
* */
5050
public JSONObject getUserInfo() throws JSONException {
51-
return oClient.get("/auth/v1/info");
51+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5252
}
5353

5454
}

src/com/Upwork/api/Routers/Freelancers/Profile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Profile(OAuthClient client) {
4949
* @return {@link JSONObject}
5050
*/
5151
public JSONObject getSpecific(String key) throws JSONException {
52-
return oClient.get("/profiles/v1/providers/" + key);
52+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5353
}
5454

5555
/**
@@ -60,6 +60,6 @@ public JSONObject getSpecific(String key) throws JSONException {
6060
* @return {@link JSONObject}
6161
*/
6262
public JSONObject getSpecificBrief(String key) throws JSONException {
63-
return oClient.get("/profiles/v1/providers/" + key + "/brief");
63+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
6464
}
6565
}

src/com/Upwork/api/Routers/Freelancers/Search.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Search(OAuthClient client) {
5151
* @return {@link JSONObject}
5252
*/
5353
public JSONObject find(HashMap<String, String> params) throws JSONException {
54-
return oClient.get("/profiles/v2/search/providers", params);
54+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5555
}
5656

5757
}

src/com/Upwork/api/Routers/Hr/Clients/Applications.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Applications(OAuthClient client) {
5050
* @return object
5151
*/
5252
public JSONObject getList(HashMap<String, String> params) throws JSONException {
53-
return oClient.get("/hr/v4/clients/applications", params);
53+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5454
}
5555

5656
/**
@@ -61,7 +61,7 @@ public JSONObject getList(HashMap<String, String> params) throws JSONException {
6161
* @return object
6262
*/
6363
public JSONObject getSpecific(String reference, HashMap<String, String> params) throws JSONException {
64-
return oClient.get("/hr/v4/clients/applications/" + reference, params);
64+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
6565
}
6666

6767
}

src/com/Upwork/api/Routers/Hr/Clients/Offers.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Offers(OAuthClient client) {
5151
* @return {@link JSONObject}
5252
*/
5353
public JSONObject getList(HashMap<String, String> params) throws JSONException {
54-
return oClient.get("/offers/v1/clients/offers", params);
54+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5555
}
5656

5757
/**
@@ -63,7 +63,7 @@ public JSONObject getList(HashMap<String, String> params) throws JSONException {
6363
* @return {@link JSONObject}
6464
*/
6565
public JSONObject getSpecific(String reference, HashMap<String, String> params) throws JSONException {
66-
return oClient.get("/offers/v1/clients/offers/" + reference, params);
66+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
6767
}
6868

6969
/**
@@ -74,7 +74,7 @@ public JSONObject getSpecific(String reference, HashMap<String, String> params)
7474
* @return {@link JSONObject}
7575
*/
7676
public JSONObject makeOffer(HashMap<String, String> params) throws JSONException {
77-
return oClient.post("/offers/v1/clients/offers", params);
77+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
7878
}
7979

8080
}

src/com/Upwork/api/Routers/Hr/Contracts.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public Contracts(OAuthClient client) {
5252
* @return {@link JSONObject}
5353
*/
5454
public JSONObject suspendContract(String reference, HashMap<String, String> params) throws JSONException {
55-
return oClient.put("/hr/v2/contracts/" + reference + "/suspend", params);
55+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5656
}
5757

5858
/**
@@ -64,7 +64,7 @@ public JSONObject suspendContract(String reference, HashMap<String, String> para
6464
* @return {@link JSONObject}
6565
*/
6666
public JSONObject restartContract(String reference, HashMap<String, String> params) throws JSONException {
67-
return oClient.put("/hr/v2/contracts/" + reference + "/restart", params);
67+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
6868
}
6969

7070
/**
@@ -76,7 +76,7 @@ public JSONObject restartContract(String reference, HashMap<String, String> para
7676
* @return {@link JSONObject}
7777
*/
7878
public JSONObject endContract(String reference, HashMap<String, String> params) throws JSONException {
79-
return oClient.delete("/hr/v2/contracts/" + reference, params);
79+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
8080
}
8181

8282
}

src/com/Upwork/api/Routers/Hr/Engagements.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Engagements(OAuthClient client) {
5151
* @return {@link JSONObject}
5252
*/
5353
public JSONObject getList(HashMap<String, String> params) throws JSONException {
54-
return oClient.get("/hr/v2/engagements", params);
54+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5555
}
5656

5757
/**
@@ -62,7 +62,7 @@ public JSONObject getList(HashMap<String, String> params) throws JSONException {
6262
* @return {@link JSONObject}
6363
*/
6464
public JSONObject getSpecific(String reference) throws JSONException {
65-
return oClient.get("/hr/v2/engagements/" + reference);
65+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
6666
}
6767

6868
}

src/com/Upwork/api/Routers/Hr/Freelancers/Applications.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Applications(OAuthClient client) {
5151
* @return {@link JSONObject}
5252
*/
5353
public JSONObject getList(HashMap<String, String> params) throws JSONException {
54-
return oClient.get("/hr/v4/contractors/applications", params);
54+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5555
}
5656

5757
/**
@@ -62,7 +62,7 @@ public JSONObject getList(HashMap<String, String> params) throws JSONException {
6262
* @return {@link JSONObject}
6363
*/
6464
public JSONObject getSpecific(String reference) throws JSONException {
65-
return oClient.get("/hr/v4/contractors/applications/" + reference);
65+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
6666
}
6767

6868
}

src/com/Upwork/api/Routers/Hr/Freelancers/Offers.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Offers(OAuthClient client) {
5151
* @return {@link JSONObject}
5252
*/
5353
public JSONObject getList(HashMap<String, String> params) throws JSONException {
54-
return oClient.get("/offers/v1/contractors/offers", params);
54+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5555
}
5656

5757
/**
@@ -62,7 +62,7 @@ public JSONObject getList(HashMap<String, String> params) throws JSONException {
6262
* @return {@link JSONObject}
6363
*/
6464
public JSONObject getSpecific(String reference) throws JSONException {
65-
return oClient.get("/offers/v1/contractors/offers/" + reference);
65+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
6666
}
6767

6868
/**
@@ -74,7 +74,7 @@ public JSONObject getSpecific(String reference) throws JSONException {
7474
* @return {@link JSONObject}
7575
*/
7676
public JSONObject actions(String reference, HashMap<String, String> params) throws JSONException {
77-
return oClient.post("/offers/v1/contractors/offers/" + reference, params);
77+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
7878
}
7979

8080
}

src/com/Upwork/api/Routers/Hr/Interviews.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public Interviews(OAuthClient client) {
5252
* @return {@link JSONObject}
5353
*/
5454
public JSONObject invite(String jobKey, HashMap<String, String> params) throws JSONException {
55-
return oClient.post("/hr/v1/jobs/" + jobKey + "/candidates", params);
55+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5656
}
5757

5858
}

src/com/Upwork/api/Routers/Hr/Jobs.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Jobs(OAuthClient client) {
5151
* @return {@link JSONObject}
5252
*/
5353
public JSONObject getList(HashMap<String, String> params) throws JSONException {
54-
return oClient.get("/hr/v2/jobs", params);
54+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
5555
}
5656

5757
/**
@@ -62,7 +62,7 @@ public JSONObject getList(HashMap<String, String> params) throws JSONException {
6262
* @return {@link JSONObject}
6363
*/
6464
public JSONObject getSpecific(String key) throws JSONException {
65-
return oClient.get("/hr/v2/jobs/" + key);
65+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
6666
}
6767

6868
/**
@@ -73,7 +73,7 @@ public JSONObject getSpecific(String key) throws JSONException {
7373
* @return {@link JSONObject}
7474
*/
7575
public JSONObject postJob(HashMap<String, String> params) throws JSONException {
76-
return oClient.post("/hr/v2/jobs", params);
76+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
7777
}
7878

7979
/**
@@ -85,7 +85,7 @@ public JSONObject postJob(HashMap<String, String> params) throws JSONException {
8585
* @return {@link JSONObject}
8686
*/
8787
public JSONObject editJob(String key, HashMap<String, String> params) throws JSONException {
88-
return oClient.put("/hr/v2/jobs/" + key, params);
88+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
8989
}
9090

9191
/**
@@ -97,7 +97,7 @@ public JSONObject editJob(String key, HashMap<String, String> params) throws JSO
9797
* @return {@link JSONObject}
9898
*/
9999
public JSONObject deleteJob(String key, HashMap<String, String> params) throws JSONException {
100-
return oClient.delete("/hr/v2/jobs/" + key, params);
100+
throw new UnsupportedOperationException("The legacy API was deprecated. Please, use GraphQL call - see example in this library.");
101101
}
102102

103103
}

0 commit comments

Comments
 (0)