Преглед на файлове

Merge 8492ca235ecb795c800d3bd9d36c64182316753b into bd1fca498ef63809a3a7a9e8867a8c20219bafbb

carolynnmarie преди 6 години
родител
ревизия
f1a2f540d8
No account linked to committer's email

+ 6
- 6
Client/Client.iml Целия файл

@@ -1,18 +1,18 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3
-  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
3
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
4 4
     <output url="file://$MODULE_DIR$/target/classes" />
5 5
     <output-test url="file://$MODULE_DIR$/target/test-classes" />
6 6
     <content url="file://$MODULE_DIR$">
7 7
       <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8
-      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
9
-      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
10 8
       <excludeFolder url="file://$MODULE_DIR$/target" />
11 9
     </content>
12 10
     <orderEntry type="inheritedJdk" />
13 11
     <orderEntry type="sourceFolder" forTests="false" />
14
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.6" level="project" />
15
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
16
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.6" level="project" />
12
+    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.4" level="project" />
13
+    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.4" level="project" />
14
+    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
15
+    <orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.10.0" level="project" />
16
+    <orderEntry type="library" name="Maven: com.squareup.okio:okio:1.14.0" level="project" />
17 17
   </component>
18 18
 </module>

+ 21
- 2
Client/pom.xml Целия файл

@@ -10,6 +10,25 @@
10 10
     <modelVersion>4.0.0</modelVersion>
11 11
 
12 12
     <artifactId>Client</artifactId>
13
-
14
-
13
+    <properties>
14
+        <maven.compiler.source>1.8</maven.compiler.source>
15
+        <maven.compiler.target>1.8</maven.compiler.target>
16
+    </properties>
17
+    <dependencies>
18
+        <dependency>
19
+            <groupId>com.fasterxml.jackson.core</groupId>
20
+            <artifactId>jackson-core</artifactId>
21
+            <version>2.9.4</version>
22
+        </dependency>
23
+        <dependency>
24
+            <groupId>com.fasterxml.jackson.core</groupId>
25
+            <artifactId>jackson-databind</artifactId>
26
+            <version>2.9.4</version>
27
+        </dependency>
28
+        <dependency>
29
+            <groupId>com.squareup.okhttp3</groupId>
30
+            <artifactId>okhttp</artifactId>
31
+            <version>3.10.0</version>
32
+        </dependency>
33
+    </dependencies>
15 34
 </project>

+ 49
- 0
Client/src/main/java/Id.java Целия файл

@@ -0,0 +1,49 @@
1
+
2
+
3
+public class Id {
4
+
5
+    private String userid;
6
+    private String name;
7
+    private String github;
8
+
9
+    public Id(){
10
+    }
11
+
12
+    public Id(String userid, String name, String github){
13
+        this.userid = userid;
14
+        this.name = name;
15
+        this.github = github;
16
+    }
17
+
18
+
19
+    public void setId(String id) {
20
+        this.userid = id;
21
+    }
22
+
23
+    public String getuserid() {
24
+        return userid;
25
+    }
26
+
27
+    public void setName(String name) {
28
+        this.name = name;
29
+    }
30
+
31
+    public String getName() {
32
+        return name;
33
+    }
34
+
35
+    public void setGithub(String github) {
36
+        this.github = github;
37
+    }
38
+
39
+    public String getGithub() {
40
+        return github;
41
+    }
42
+
43
+    @Override
44
+    public String toString(){
45
+        return "userid: " + getuserid() + ", name: " + getName() + ", github: " + getGithub();
46
+    }
47
+
48
+}
49
+

+ 31
- 0
Client/src/main/java/IdController.java Целия файл

@@ -0,0 +1,31 @@
1
+import com.fasterxml.jackson.databind.ObjectMapper;
2
+
3
+import java.io.IOException;
4
+import java.util.ArrayList;
5
+
6
+public class IdController implements IdInterface {
7
+    ObjectMapper objectMapper = new ObjectMapper();
8
+    YouAreEll youAreEll = new YouAreEll();
9
+
10
+    @Override
11
+    public String get_ids(ArrayList<String> list) throws com.fasterxml.jackson.core.JsonProcessingException {
12
+        Id id = new Id("-","","");
13
+        String payload = objectMapper.writeValueAsString(id);
14
+        return youAreEll.makeURLCall("/ids", "GET", payload);
15
+    }
16
+
17
+    @Override
18
+    public String saveId(ArrayList<String> list) throws com.fasterxml.jackson.core.JsonProcessingException {
19
+        String name = list.get(1);
20
+        String github = list.get(2);
21
+        Id id = new Id("-", name, github);
22
+        String payload = objectMapper.writeValueAsString(id);
23
+       return youAreEll.makeURLCall("/ids", "POST", payload);
24
+    }
25
+
26
+
27
+}
28
+//    String me = list.get(1);
29
+//    Message message = new Message("-", me,"","");
30
+//    String payload = objectMapper.writeValueAsString(message);
31
+//        return youAreEll.makeURLCall("/messages", "GET", payload);

+ 7
- 0
Client/src/main/java/IdInterface.java Целия файл

@@ -0,0 +1,7 @@
1
+import java.io.IOException;
2
+import java.util.ArrayList;
3
+
4
+public interface IdInterface {
5
+    String get_ids(ArrayList<String> list) throws IOException;
6
+    String saveId(ArrayList<String> list) throws IOException;
7
+}

+ 79
- 0
Client/src/main/java/Message.java Целия файл

@@ -0,0 +1,79 @@
1
+
2
+
3
+public class Message {
4
+
5
+    private String sequence;
6
+    private String timestamp;
7
+    private String fromid;
8
+    private String toid;
9
+    private String message;
10
+
11
+    public Message(){
12
+    }
13
+
14
+    public Message(String sequence, String fromid, String toid, String message) {
15
+        this.sequence = sequence;
16
+        this.timestamp = "2018-03-22T01:00:00.0Z";
17
+        this.fromid = fromid;
18
+        this.toid = toid;
19
+        this.message = message;
20
+    }
21
+
22
+    public Message(String fromid, String toid, String message){
23
+        this.fromid = fromid;
24
+        this.toid = toid;
25
+        this.message = message;
26
+    }
27
+
28
+    public Message(String fromid, String message){
29
+        this.fromid = fromid;
30
+        this.message = message;
31
+    }
32
+
33
+    public void setSequence(String sequence) {
34
+        this.sequence = sequence;
35
+    }
36
+
37
+    public String getSequence() {
38
+        return sequence;
39
+    }
40
+
41
+    public void setTimestamp(String timestamp) {
42
+        this.timestamp = timestamp;
43
+    }
44
+
45
+    public String getTimestamp() {
46
+        return timestamp;
47
+    }
48
+
49
+    public void setFromid(String fromid) {
50
+        this.fromid = fromid;
51
+    }
52
+
53
+    public String getFromid() {
54
+        return fromid;
55
+    }
56
+
57
+    public void setToid(String toid) {
58
+        this.toid = toid;
59
+    }
60
+
61
+    public String getToid() {
62
+        return toid;
63
+    }
64
+
65
+    public void setMessage(String message) {
66
+        this.message = message;
67
+    }
68
+
69
+    public String getMessage() {
70
+        return message;
71
+    }
72
+
73
+    @Override
74
+    public String toString(){
75
+        return "sequence: " + getSequence() + ", timestamp: " + getTimestamp()+ ", from: " + getFromid() + ", to: " + getToid() + ", message: " + getMessage();
76
+    }
77
+}
78
+
79
+

+ 74
- 0
Client/src/main/java/MessageController.java Целия файл

@@ -0,0 +1,74 @@
1
+import com.fasterxml.jackson.databind.ObjectMapper;
2
+import com.fasterxml.jackson.core.JsonProcessingException;
3
+
4
+import java.io.IOException;
5
+import java.util.ArrayList;
6
+
7
+public class MessageController implements MessageInterface {
8
+
9
+    private YouAreEll youAreEll = new YouAreEll();
10
+    private ObjectMapper objectMapper = new ObjectMapper();
11
+
12
+
13
+    @Override
14
+    public String get_messages(ArrayList<String> list) throws JsonProcessingException {
15
+        String payload = "";
16
+        Message message = new Message("-", "","","");
17
+        try {
18
+            payload = objectMapper.writeValueAsString(message);
19
+        } catch(JsonProcessingException e){
20
+            e.printStackTrace();
21
+        }
22
+        return youAreEll.makeURLCall("/messages", "GET", payload);
23
+    }
24
+
25
+    @Override
26
+    public String get_from_friend(ArrayList<String> list) throws JsonProcessingException  {
27
+//         /ids/:mygithubid/from/:friendgithubid
28
+        return null;
29
+    }
30
+
31
+    @Override
32
+    public String get_my_messages(ArrayList<String> list) {
33
+       String payload = "";
34
+        String me = list.get(1);
35
+        Message message = new Message("-", me, "", "");
36
+        String url = "/ids/:" + me + "/messages";
37
+        try {
38
+            payload = objectMapper.writeValueAsString(message);
39
+        } catch(JsonProcessingException e){
40
+            e.printStackTrace();
41
+        }
42
+        return youAreEll.makeURLCall(url, "GET", payload);
43
+    }
44
+
45
+    @Override
46
+    public String post_world(ArrayList<String> list){
47
+        String payload = "";
48
+        String mess = list.get(1);
49
+        String me = list.get(2);
50
+        Message message = new Message("-", me, "", mess);
51
+        String url = "/ids/:" + me + "/messages";
52
+        try {
53
+            payload = objectMapper.writeValueAsString(message);
54
+        } catch (com.fasterxml.jackson.core.JsonProcessingException e){
55
+            e.printStackTrace();
56
+        }
57
+        return youAreEll.makeURLCall(url, "POST", payload);
58
+    }
59
+
60
+    @Override
61
+    public String post_friend(ArrayList<String> list) {
62
+        String mess = list.get(1);
63
+        String me = list.get(2);
64
+        String friend = list.get(3);
65
+        String payload = "";
66
+        Message message = new Message("-", me, friend, mess);
67
+        try {
68
+            payload = objectMapper.writeValueAsString(message);
69
+        } catch(JsonProcessingException e){
70
+            e.printStackTrace();
71
+        }
72
+        return youAreEll.makeURLCall("/messages","POST", payload);
73
+    }
74
+}

+ 12
- 0
Client/src/main/java/MessageInterface.java Целия файл

@@ -0,0 +1,12 @@
1
+import java.io.IOException;
2
+import java.util.ArrayList;
3
+
4
+public interface MessageInterface {
5
+
6
+    String get_messages(ArrayList<String> list)throws IOException;
7
+    String get_from_friend(ArrayList<String> list)throws IOException;
8
+    String get_my_messages(ArrayList<String> list)throws IOException;
9
+    String post_world(ArrayList<String> list)throws IOException;
10
+    String post_friend(ArrayList<String> list)throws IOException;
11
+
12
+}

+ 147
- 53
Client/src/main/java/SimpleShell.java Целия файл

@@ -3,15 +3,51 @@ import java.io.IOException;
3 3
 import java.io.InputStream;
4 4
 import java.io.InputStreamReader;
5 5
 import java.util.ArrayList;
6
+import java.util.LinkedHashMap;
6 7
 import java.util.List;
8
+import java.util.Map;
9
+
10
+import com.fasterxml.jackson.core.type.TypeReference;
11
+import com.fasterxml.jackson.databind.ObjectMapper;
7 12
 
8 13
 public class SimpleShell {
9 14
 
10 15
 
11
-    public static void prettyPrint(String output) {
12
-        // yep, make an effort to format things nicely, eh?
13
-        System.out.println(output);
16
+    public static void prettyPrintId(String output) {
17
+        ObjectMapper objectMapper = new ObjectMapper();
18
+        String result = "";
19
+        Id[] users = null;
20
+        try {
21
+             users= objectMapper.readValue(output, Id[].class);
22
+        } catch (IOException e) {
23
+            e.printStackTrace();
24
+        }
25
+        for(Id user: users){
26
+            result += "name: " + user.getName() + ", github: " + user.getGithub() + "\n";
27
+        }
28
+        System.out.println(result);
14 29
     }
30
+
31
+    public static void prettyPrintMessage(String output){
32
+        ObjectMapper objectMapper = new ObjectMapper();
33
+        String result = "";
34
+        Message[] messages = null;
35
+        try {
36
+            messages = objectMapper.readValue(output, Message[].class);
37
+        } catch (IOException e) {
38
+            e.printStackTrace();
39
+        }
40
+        for(Message mess: messages){
41
+            if(mess.getToid().equals("")) {
42
+                result += "from: " + mess.getFromid() + ", message: " + mess.getMessage() + "\n";
43
+            }
44
+            if(!mess.getToid().equals("")) {
45
+                result += "from: " + mess.getFromid() + ", to: " + mess.getToid() + ", message: " + mess.getMessage() + "\n";
46
+            }
47
+        }
48
+        System.out.println(result);
49
+    }
50
+    
15 51
     public static void main(String[] args) throws java.io.IOException {
16 52
 
17 53
         YouAreEll webber = new YouAreEll();
@@ -19,86 +55,144 @@ public class SimpleShell {
19 55
         BufferedReader console = new BufferedReader
20 56
                 (new InputStreamReader(System.in));
21 57
 
22
-        ProcessBuilder pb = new ProcessBuilder();
23
-        List<String> history = new ArrayList<String>();
58
+        ProcessBuilder processBuilder = new ProcessBuilder();
59
+        List<String> userInputHistory = new ArrayList<>();
24 60
         int index = 0;
61
+
25 62
         //we break out with <ctrl c>
26 63
         while (true) {
27
-            //read what the user enters
28
-            System.out.println("cmd? ");
64
+            System.out.println("To receive all registered github ids, register a new id, or change the associated name, type 'ids'.\n" +
65
+                    "To get messages, type 'messages'. \nTo send a message, type 'send'.\n" +
66
+                    "To receive a history of previous commands, type 'history'.\n" +
67
+                    "To exit, type exit. ");
29 68
             commandLine = console.readLine();
30
-
31
-            //input parsed into array of strings(command and arguments)
32
-            String[] commands = commandLine.split(" ");
33
-            List<String> list = new ArrayList<String>();
34
-
35
-            //if the user entered a return, just loop again
36
-            if (commandLine.equals(""))
37
-                continue;
69
+            if (commandLine.equals("")) continue;
38 70
             if (commandLine.equals("exit")) {
39
-                System.out.println("bye!");
71
+                System.out.println("Goodbye");
40 72
                 break;
41 73
             }
42 74
 
43
-            //loop through to see if parsing worked
44
-            for (int i = 0; i < commands.length; i++) {
45
-                //System.out.println(commands[i]); //***check to see if parsing/split worked***
46
-                list.add(commands[i]);
47
-
48
-            }
49
-            System.out.print(list); //***check to see if list was added correctly***
50
-            history.addAll(list);
51 75
             try {
52
-                //display history of shell with index
53
-                if (list.get(list.size() - 1).equals("history")) {
54
-                    for (String s : history)
55
-                        System.out.println((index++) + " " + s);
56
-                    continue;
76
+                String specificCommand = "";
77
+                ArrayList<String> commandList = new ArrayList<>();
78
+                commandList.add(commandLine);
79
+                MessageController mesCont = new MessageController();
80
+                IdController idCont = new IdController();
81
+
82
+                if (commandLine.equalsIgnoreCase("ids")) {
83
+                    String results = "";
84
+                    System.out.println("To retrieve all registered github ids, press enter\n" +
85
+                            "To register a new id or change the name associated, type your name");
86
+                    specificCommand = console.readLine();
87
+                    if(specificCommand.equals("")) {
88
+                        results = idCont.get_ids(commandList);
89
+                    } else {
90
+                        commandList.add(specificCommand);
91
+                        System.out.println("Please enter your github id");
92
+                        specificCommand = console.readLine();
93
+                        commandList.add(specificCommand);
94
+                        results = idCont.saveId(commandList);
95
+                    }
96
+                    SimpleShell.prettyPrintId(results);
97
+                    System.out.println("To enter another command, press enter.  To exit, type exit.");
98
+                    commandLine = console.readLine();
99
+                    if (commandLine.equals("")) continue;
100
+                    if (commandLine.equals("exit")) {
101
+                        System.out.println("Goodbye");
102
+                        break;
103
+                    }
57 104
                 }
58 105
 
59
-                // Specific Commands.
106
+                if (commandLine.equals("messages")) {
107
+                    String results = "";
108
+                    System.out.println("To retrieve the last 20 messages posted on the timeline, press enter\n" +
109
+                            "To retrieve the last twenty messages sent to you enter your github id");
110
+                    specificCommand = console.readLine();
111
+                    if(specificCommand.equals("\n") || specificCommand.equals("")) {
112
+                        results = mesCont.get_messages(commandList);
113
+                    } else {
114
+                        commandList.add(specificCommand);
115
+                        results = mesCont.get_my_messages(commandList);
116
+                    }
117
+                    SimpleShell.prettyPrintMessage(results);
118
+                    System.out.println("To enter another command, press enter.  To exit, type exit.");
119
+                    commandLine = console.readLine();
120
+                    if (commandLine.equals("")) continue;
121
+                    if (commandLine.equals("exit")) {
122
+                        System.out.println("Goodbye");
123
+                        break;
124
+                    }
125
+                }
60 126
 
61
-                // ids
62
-                if (list.contains("ids")) {
63
-                    String results = webber.get_ids();
64
-                    SimpleShell.prettyPrint(results);
65
-                    continue;
127
+
128
+                if(commandLine.equalsIgnoreCase("send")){
129
+                    String results = "";
130
+                    System.out.println("Please enter your message");
131
+                    specificCommand = console.readLine();
132
+                    if(!specificCommand.equals("")) {
133
+                        commandList.add(specificCommand);
134
+                    }
135
+                    System.out.println(("Enter your github id"));
136
+                    specificCommand = console.readLine();
137
+                    if(!specificCommand.equals("")) {
138
+                        commandList.add(specificCommand);
139
+                        results = mesCont.post_world(commandList);
140
+                    }
141
+                    System.out.println(("If you wish to send your message to another github user, enter their github id." +
142
+                            "If you wish to send a general message to the timeline, press enter"));
143
+                    if (specificCommand.equals("")) {
144
+                        results = mesCont.post_world(commandList);
145
+                    }
146
+                    if(!specificCommand.equals("")) {
147
+                        commandList.add(specificCommand);
148
+                        results = mesCont.post_friend(commandList);
149
+                    }
150
+                    SimpleShell.prettyPrintMessage(results);
151
+                    System.out.println("To enter another command, press enter.  To exit, type exit.");
152
+                    commandLine = console.readLine();
153
+                    if (commandLine.equals("")) continue;
154
+                    if (commandLine.equals("exit")) {
155
+                        System.out.println("Goodbye");
156
+                        break;
157
+                    }
66 158
                 }
67 159
 
68
-                // messages
69
-                if (list.contains("messages")) {
70
-                    String results = webber.get_messages();
71
-                    SimpleShell.prettyPrint(results);
160
+
161
+                //print history, moved it here so full commands will be in history
162
+                userInputHistory.addAll(commandList);
163
+                if (commandLine.equalsIgnoreCase("history")) {
164
+                    for (String s : userInputHistory)
165
+                        System.out.println((index++) + " " + s);
72 166
                     continue;
73 167
                 }
74
-                // you need to add a bunch more.
75 168
 
76
-                //!! command returns the last command in history
77
-                if (list.get(list.size() - 1).equals("!!")) {
78
-                    pb.command(history.get(history.size() - 2));
79 169
 
80
-                }//!<integer value i> command
81
-                else if (list.get(list.size() - 1).charAt(0) == '!') {
82
-                    int b = Character.getNumericValue(list.get(list.size() - 1).charAt(1));
83
-                    if (b <= history.size())//check if integer entered isn't bigger than history size
84
-                        pb.command(history.get(b));
170
+                //the !! command returns the last command in userInputHistory
171
+                if (commandList.get(commandList.size() - 1).equals("!!")) {
172
+                    processBuilder.command(userInputHistory.get(userInputHistory.size() - 2));
173
+                }
174
+                // !<integer value i> command
175
+                else if (commandList.get(commandList.size() - 1).charAt(0) == '!') {
176
+                    int b = Character.getNumericValue(commandList.get(commandList.size() - 1).charAt(1));
177
+                    if (b <= userInputHistory.size())
178
+                        processBuilder.command(userInputHistory.get(b));
85 179
                 } else {
86
-                    pb.command(list);
180
+                    processBuilder.command(commandList);
87 181
                 }
88 182
 
89 183
                 // wait, wait, what curiousness is this?
90
-                Process process = pb.start();
184
+                Process process = processBuilder.start();
91 185
 
92 186
                 //obtain the input stream
93 187
                 InputStream is = process.getInputStream();
94 188
                 InputStreamReader isr = new InputStreamReader(is);
95
-                BufferedReader br = new BufferedReader(isr);
189
+                BufferedReader reader = new BufferedReader(isr);
96 190
 
97 191
                 //read output of the process
98 192
                 String line;
99
-                while ((line = br.readLine()) != null)
193
+                while ((line = reader.readLine()) != null)
100 194
                     System.out.println(line);
101
-                br.close();
195
+                reader.close();
102 196
 
103 197
 
104 198
             }

+ 42
- 11
Client/src/main/java/YouAreEll.java Целия файл

@@ -1,23 +1,54 @@
1
+import com.fasterxml.jackson.core.JsonProcessingException;
2
+import com.fasterxml.jackson.databind.*;
3
+import okhttp3.*;
4
+import com.fasterxml.jackson.databind.ObjectMapper;
5
+
6
+
7
+import java.io.IOException;
8
+
9
+
10
+
1 11
 public class YouAreEll {
12
+    private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
2 13
 
3 14
     YouAreEll() {
4 15
     }
5 16
 
6 17
     public static void main(String[] args) {
7 18
         YouAreEll urlhandler = new YouAreEll();
8
-        System.out.println(urlhandler.MakeURLCall("/ids", "GET", ""));
9
-        System.out.println(urlhandler.MakeURLCall("/messages", "GET", ""));
19
+        ObjectMapper objectMapper = new ObjectMapper();
20
+        String payload = "";
21
+        Id id = new Id("-", "Carolynn", "me");
22
+        try {
23
+            payload = objectMapper.writeValueAsString(id);
24
+            urlhandler.makeURLCall("/ids", "POST", payload);
25
+        } catch (JsonProcessingException e) {
26
+            e.printStackTrace();
27
+        }
28
+//        System.out.println(urlhandler.makeURLCall("/ids", "POST", payload));
29
+//        System.out.println(urlhandler.makeURLCall("/messages", "GET", ""));
10 30
     }
11 31
 
12
-    public String get_ids() {
13
-        return MakeURLCall("/ids", "GET", "");
14
-    }
15 32
 
16
-    public String get_messages() {
17
-        return MakeURLCall("/messages", "GET", "");
18
-    }
33
+    public String makeURLCall(String mainurl, String method, String jpayload) {
34
+        OkHttpClient okHttpClient = new OkHttpClient();
35
+        String fullUrl = "http://zipcode.rocks:8085" + mainurl;
36
+        Request request = null;
37
+        if (method.equalsIgnoreCase("get")) {
38
+            request = new Request.Builder().url(fullUrl).build();
39
+        }
40
+        if (method.equalsIgnoreCase("post")) {
41
+            RequestBody requestBody = RequestBody.create(JSON, jpayload);
42
+            request = new Request.Builder().url(fullUrl).post(requestBody).build();
43
+        }
19 44
 
20
-    public String MakeURLCall(String mainurl, String method, String jpayload) {
21
-        return "nada";
45
+        if (request != null) {
46
+            try (Response response = okHttpClient.newCall(request).execute()) {
47
+                return response.body().string();
48
+            } catch (IOException e) {
49
+                e.printStackTrace();
50
+            }
51
+        }
52
+        return "" + method;
22 53
     }
23
-}
54
+}

+ 3
- 3
YouAreEll.iml Целия файл

@@ -8,8 +8,8 @@
8 8
     </content>
9 9
     <orderEntry type="inheritedJdk" />
10 10
     <orderEntry type="sourceFolder" forTests="false" />
11
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.6" level="project" />
12
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
13
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.6" level="project" />
11
+    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.4" level="project" />
12
+    <orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.10.0" level="project" />
13
+    <orderEntry type="library" name="Maven: com.squareup.okio:okio:1.14.0" level="project" />
14 14
   </component>
15 15
 </module>

+ 13
- 2
pom.xml Целия файл

@@ -13,10 +13,21 @@
13 13
     </modules>
14 14
 
15 15
     <dependencies>
16
+
16 17
         <dependency>
17 18
             <groupId>com.fasterxml.jackson.core</groupId>
18
-            <artifactId>jackson-databind</artifactId>
19
-            <version>2.8.6</version>
19
+            <artifactId>jackson-core</artifactId>
20
+            <version>2.9.4</version>
21
+        </dependency>
22
+        <dependency>
23
+            <groupId>com.squareup.okhttp3</groupId>
24
+            <artifactId>okhttp</artifactId>
25
+            <version>3.10.0</version>
20 26
         </dependency>
27
+        <!--<dependency>-->
28
+            <!--<groupId>org.apache.httpcomponents</groupId>-->
29
+            <!--<artifactId>httpclient</artifactId>-->
30
+            <!--<version>4.5.5</version>-->
31
+        <!--</dependency>-->
21 32
     </dependencies>
22 33
 </project>