|
@@ -18,60 +18,62 @@ public class YouAreEll {
|
18
|
18
|
|
19
|
19
|
}
|
20
|
20
|
|
21
|
|
- public static void main(String[] args) {
|
22
|
|
- YouAreEll urlhandler = new YouAreEll();
|
23
|
|
-// System.out.println(urlhandler.MakeURLCall("/ids", "GET", ""));
|
24
|
|
-// System.out.println(urlhandler.MakeURLCall("/messages", "GET", ""));
|
25
|
|
- }
|
26
|
|
-
|
27
|
|
- public void get_ids(){
|
|
21
|
+ public String get_ids(){
|
28
|
22
|
|
29
|
23
|
try {
|
30
|
24
|
HttpResponse<JsonNode> jsonResponse = Unirest.get(underARock + "/ids")
|
31
|
25
|
.header("accept", "application/json")
|
32
|
26
|
.asJson();
|
33
|
27
|
|
34
|
|
- SimpleShell.prettyPrint(jsonResponse.getBody());
|
|
28
|
+ return SimpleShell.prettyPrint(jsonResponse.getBody());
|
35
|
29
|
|
36
|
30
|
} catch (UnirestException e) {
|
37
|
|
- System.out.println("Error");
|
|
31
|
+ return "Error";
|
38
|
32
|
}
|
39
|
33
|
|
40
|
34
|
}
|
41
|
35
|
|
42
|
|
- public void get_messages() {
|
|
36
|
+ public String get_messages() {
|
43
|
37
|
try {
|
44
|
38
|
HttpResponse<JsonNode> jsonResponse = Unirest.get(underARock + "/messages")
|
45
|
39
|
.header("accept", "application/json")
|
46
|
40
|
.asJson();
|
47
|
41
|
|
48
|
|
- SimpleShell.prettyPrint(jsonResponse.getBody());
|
|
42
|
+ return SimpleShell.prettyPrint(jsonResponse.getBody());
|
49
|
43
|
|
50
|
44
|
} catch (UnirestException e) {
|
51
|
|
- System.out.println("Error");
|
|
45
|
+ return "Error";
|
52
|
46
|
}
|
53
|
47
|
}
|
54
|
48
|
|
55
|
|
- public String MakeURLCall(String mainurl, String method, String jpayload) throws UnirestException {
|
56
|
|
-
|
57
|
|
- String url = underARock + mainurl;
|
58
|
|
- method = method.toUpperCase();
|
59
|
|
- HttpResponse<com.mashape.unirest.http.JsonNode> jsonResponse;
|
|
49
|
+ public void postNewUser(Id id) {
|
|
50
|
+ try {
|
|
51
|
+ Unirest.post(underARock + "/ids")
|
|
52
|
+ .body(id.toJSON())
|
|
53
|
+ .asJson();
|
60
|
54
|
|
61
|
|
- if(method.equals("GET")) {
|
62
|
|
- jsonResponse = Unirest.get("http://zipcode.rocks:8085/GET").routeParam("method", url).asJson();
|
|
55
|
+ } catch (UnirestException e) {
|
|
56
|
+ System.out.println("Error");
|
63
|
57
|
}
|
64
|
58
|
|
65
|
|
- if(method.equals("POST")) {
|
66
|
|
-
|
67
|
|
- }
|
|
59
|
+ }
|
68
|
60
|
|
69
|
|
- if(method.equals("PUT")) {
|
|
61
|
+ public void putNewName(Id id) {
|
|
62
|
+ try {
|
|
63
|
+ Unirest.put(underARock + "/ids")
|
|
64
|
+ .body(id.toJSON())
|
|
65
|
+ .asJson();
|
70
|
66
|
|
|
67
|
+ } catch (UnirestException e) {
|
|
68
|
+ System.out.println("Error");
|
71
|
69
|
}
|
72
|
70
|
|
73
|
|
- return "nada";
|
|
71
|
+ }
|
74
|
72
|
|
|
73
|
+ public boolean githubIdExists(String githubId) {
|
|
74
|
+ String ids = get_ids();
|
|
75
|
+ return ids.contains(githubId);
|
75
|
76
|
}
|
76
|
77
|
|
|
78
|
+
|
77
|
79
|
}
|