Haysel Santiago 6 vuotta sitten
vanhempi
commit
7cd6ac696f

+ 5
- 5
Client/src/main/java/ID.java Näytä tiedosto

@@ -1,11 +1,14 @@
1 1
 public class ID {
2 2
 
3
-    public ID(String uderID, String name, String gitHub) {
3
+    private String name;
4
+    private String github;
5
+
6
+    public ID(String userID, String name, String github) {
4 7
         this.userID = userID;
5 8
         this.name = name;
6 9
         this.github = github;
7 10
     }
8
-    public ID(String nme, String github) {
11
+    public ID(String name, String github) {
9 12
         this.name = name;
10 13
         this.github = github;
11 14
     }
@@ -36,9 +39,6 @@ public class ID {
36 39
         this.github = github;
37 40
     }
38 41
 
39
-    private String name;
40
-    private String github;
41
-
42 42
     @Override
43 43
     public String toString() {
44 44
         return "Id{" +

+ 0
- 1
Client/src/main/java/Messages.java Näytä tiedosto

@@ -59,5 +59,4 @@ public class Messages {
59 59
     public void setMessage(String message) {
60 60
         this.message = message;
61 61
     }
62
-
63 62
 }

+ 18
- 1
Client/src/main/java/SimpleShell.java Näytä tiedosto

@@ -11,6 +11,14 @@ public class SimpleShell {
11 11
 
12 12
 
13 13
     public static void prettyPrint(String output) {
14
+        ObjectMapper objectMapper = new ObjectMapper();
15
+        try {
16
+            Object json = objectMapper.readValue(output, Object.class);
17
+            String prettyPrint = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(json);
18
+            System.out.println(prettyPrint);
19
+        } catch (IOException e) {
20
+            e.printStackTrace();
21
+        }
14 22
         // yep, make an effort to format things nicely, eh?
15 23
         System.out.println(output);
16 24
     }
@@ -21,6 +29,7 @@ public class SimpleShell {
21 29
         BufferedReader console = new BufferedReader
22 30
                 (new InputStreamReader(System.in));
23 31
 
32
+        ObjectMapper mapper = new ObjectMapper();
24 33
         ProcessBuilder pb = new ProcessBuilder();
25 34
         List<String> history = new ArrayList<String>();
26 35
         int index = 0;
@@ -61,11 +70,19 @@ public class SimpleShell {
61 70
                 // Specific Commands.
62 71
 
63 72
                 // ids
64
-                if (list.contains("ids")) {
73
+                if (list.contains("ids") && list.size() == 1) {
65 74
                     String results = webber.get_ids();
66 75
                     SimpleShell.prettyPrint(results);
67 76
                     continue;
68 77
                 }
78
+                if (list.contains("ids") && list.size() == 3){
79
+                    String name = list.get(1); //name
80
+                    String github = list.get(2);
81
+                    ID userID = new ID(name,github);
82
+                    String newUserInfo = mapper.writeValueAsString(userID);
83
+                    webber.MakeURLCall("/ids", "POST", newUserInfo);
84
+                    continue;
85
+                }
69 86
 
70 87
                 // messages
71 88
                 if (list.contains("messages")) {

+ 6
- 1
Client/src/main/java/YouAreEll.java Näytä tiedosto

@@ -1,3 +1,4 @@
1
+import com.fasterxml.jackson.databind.ObjectMapper;
1 2
 import okhttp3.*;
2 3
 
3 4
 import java.io.IOException;
@@ -35,7 +36,7 @@ public class YouAreEll {
35 36
             } catch (IOException e) {
36 37
                 e.printStackTrace();
37 38
             }
38
-        } else if (method.equals("PUT")) {
39
+        } else if (method.equals("POST")) {
39 40
             RequestBody body = RequestBody.create(JSON, jpayload);
40 41
             Request request = new Request.Builder().url(myURL).post(body).build();
41 42
 
@@ -45,6 +46,10 @@ public class YouAreEll {
45 46
                 e.printStackTrace();
46 47
             }
47 48
         }
49
+//        else if (method.equals("PUT")) {
50
+//            ObjectMapper objectMapper = new ObjectMapper();
51
+//
52
+//        }
48 53
         return "nothing";
49 54
     }
50 55
 }