|
@@ -5,14 +5,15 @@ import com.mashape.unirest.http.exceptions.UnirestException;
|
5
|
5
|
|
6
|
6
|
public class YouAreEll {
|
7
|
7
|
static Console console;
|
8
|
|
- static IdController idController;
|
9
|
|
- static MessageController messageController;
|
|
8
|
+ static IdOperations idController;
|
|
9
|
+ static MessageOperations messageController;
|
10
|
10
|
static String url;
|
|
11
|
+ static Message message;
|
11
|
12
|
|
12
|
13
|
YouAreEll() {
|
13
|
14
|
console = new Console();
|
14
|
|
- idController = new IdController();
|
15
|
|
- messageController = new MessageController();
|
|
15
|
+ idController = new IdOperations();
|
|
16
|
+ messageController = new MessageOperations();
|
16
|
17
|
url = "http://zipcode.rocks:8085";
|
17
|
18
|
}
|
18
|
19
|
|
|
@@ -37,6 +38,7 @@ public class YouAreEll {
|
37
|
38
|
get_messages();
|
38
|
39
|
break;
|
39
|
40
|
case "5":
|
|
41
|
+ putId();
|
40
|
42
|
break;
|
41
|
43
|
case "6":
|
42
|
44
|
System.exit(0);
|
|
@@ -69,17 +71,16 @@ public class YouAreEll {
|
69
|
71
|
}
|
70
|
72
|
}
|
71
|
73
|
|
72
|
|
- /* public void putId(Id id){
|
|
74
|
+ public static void putId(){
|
73
|
75
|
try {
|
74
|
76
|
Unirest.put(url + "/ids")
|
75
|
77
|
.header("accept", "application/json")
|
76
|
|
- .body(id.toString())
|
|
78
|
+ .body(idController.updateId())
|
77
|
79
|
.asJson();
|
78
|
80
|
} catch (UnirestException e) {
|
79
|
81
|
e.printStackTrace();
|
80
|
82
|
}
|
81
|
|
-
|
82
|
|
- }*/
|
|
83
|
+ }
|
83
|
84
|
|
84
|
85
|
public static String get_messages() {
|
85
|
86
|
try {
|
|
@@ -95,19 +96,19 @@ public class YouAreEll {
|
95
|
96
|
}
|
96
|
97
|
}
|
97
|
98
|
|
|
99
|
+ private static void messageGenerator(){
|
|
100
|
+ message = messageController.createMessage();
|
|
101
|
+ }
|
|
102
|
+
|
98
|
103
|
public static void postMessages() {
|
|
104
|
+ messageGenerator();
|
99
|
105
|
try {
|
100
|
|
- Unirest.post(url + "/ids")
|
|
106
|
+ Unirest.post(url + "/ids/" + message.getFromid() + "messages")
|
101
|
107
|
.header("accept", "application/json")
|
102
|
|
- .body(messageController.createMessage().toString())
|
|
108
|
+ .body(message.toString())
|
103
|
109
|
.asJson();
|
104
|
110
|
} catch (UnirestException e) {
|
105
|
111
|
e.printStackTrace();
|
106
|
112
|
}
|
107
|
113
|
}
|
108
|
|
-
|
109
|
|
-
|
110
|
|
- public String MakeURLCall(String mainurl, String method, String jpayload) {
|
111
|
|
- return "nada";
|
112
|
|
- }
|
113
|
114
|
}
|