Browse Source

get requests working

Anthony Jordan 6 years ago
parent
commit
7407dd5a7f

+ 10
- 3
Client/Client.iml View File

@@ -1,12 +1,10 @@
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_7">
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" />
@@ -14,5 +12,14 @@
14 12
     <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.6" level="project" />
15 13
     <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
16 14
     <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.6" level="project" />
15
+    <orderEntry type="library" name="Maven: com.mashape.unirest:unirest-java:1.4.9" level="project" />
16
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
17
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
18
+    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
19
+    <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
20
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.1" level="project" />
21
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.4" level="project" />
22
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.2" level="project" />
23
+    <orderEntry type="library" name="Maven: org.json:json:20160212" level="project" />
17 24
   </component>
18 25
 </module>

+ 12
- 0
Client/pom.xml View File

@@ -10,6 +10,18 @@
10 10
     <modelVersion>4.0.0</modelVersion>
11 11
 
12 12
     <artifactId>Client</artifactId>
13
+    <build>
14
+        <plugins>
15
+            <plugin>
16
+                <groupId>org.apache.maven.plugins</groupId>
17
+                <artifactId>maven-compiler-plugin</artifactId>
18
+                <configuration>
19
+                    <source>1.7</source>
20
+                    <target>1.7</target>
21
+                </configuration>
22
+            </plugin>
23
+        </plugins>
24
+    </build>
13 25
 
14 26
 
15 27
 </project>

+ 30
- 0
Client/src/main/java/IDs.java View File

@@ -0,0 +1,30 @@
1
+public class IDs {
2
+
3
+    private String userid;
4
+    private String name;
5
+    private String github;
6
+
7
+    public String getUserid() {
8
+        return userid;
9
+    }
10
+
11
+    public void setUserid(String userid) {
12
+        this.userid = userid;
13
+    }
14
+
15
+    public String getName() {
16
+        return name;
17
+    }
18
+
19
+    public void setName(String name) {
20
+        this.name = name;
21
+    }
22
+
23
+    public String getGithub() {
24
+        return github;
25
+    }
26
+
27
+    public void setGithub(String github) {
28
+        this.github = github;
29
+    }
30
+}

+ 48
- 0
Client/src/main/java/Messages.java View File

@@ -0,0 +1,48 @@
1
+public class Messages {
2
+
3
+    private String sequence;
4
+    private String timestamp;
5
+    private String fromid;
6
+    private String toid;
7
+    private String message;
8
+
9
+    public String getSequence() {
10
+        return sequence;
11
+    }
12
+
13
+    public void setSequence(String sequence) {
14
+        this.sequence = sequence;
15
+    }
16
+
17
+    public String getTimestamp() {
18
+        return timestamp;
19
+    }
20
+
21
+    public void setTimestamp(String timestamp) {
22
+        this.timestamp = timestamp;
23
+    }
24
+
25
+    public String getFromid() {
26
+        return fromid;
27
+    }
28
+
29
+    public void setFromid(String fromid) {
30
+        this.fromid = fromid;
31
+    }
32
+
33
+    public String getToid() {
34
+        return toid;
35
+    }
36
+
37
+    public void setToid(String toid) {
38
+        this.toid = toid;
39
+    }
40
+
41
+    public String getMessage() {
42
+        return message;
43
+    }
44
+
45
+    public void setMessage(String message) {
46
+        this.message = message;
47
+    }
48
+}

+ 27
- 2
Client/src/main/java/YouAreEll.java View File

@@ -1,3 +1,10 @@
1
+
2
+import com.fasterxml.jackson.databind.ObjectMapper;
3
+import com.mashape.unirest.http.Unirest;
4
+import com.mashape.unirest.http.exceptions.UnirestException;
5
+import java.io.IOException;
6
+import java.util.Arrays;
7
+
1 8
 public class YouAreEll {
2 9
 
3 10
     YouAreEll() {
@@ -10,7 +17,15 @@ public class YouAreEll {
10 17
     }
11 18
 
12 19
     public String get_ids() {
13
-        return MakeURLCall("/ids", "GET", "");
20
+        ObjectMapper jsonMapper = new ObjectMapper();
21
+        String jsonString = MakeURLCall("/ids", "GET", "");
22
+        try {
23
+            IDs[] iDSList = jsonMapper.readValue(jsonString, IDs[].class);
24
+            return Arrays.toString(iDSList);
25
+        } catch (IOException e) {
26
+            e.printStackTrace();
27
+        }
28
+        return null;
14 29
     }
15 30
 
16 31
     public String get_messages() {
@@ -18,6 +33,16 @@ public class YouAreEll {
18 33
     }
19 34
 
20 35
     public String MakeURLCall(String mainurl, String method, String jpayload) {
21
-        return "nada";
36
+
37
+        try {
38
+            if (method.equals("GET")) {
39
+                return Unirest.get("http://zipcode.rocks:8085" + mainurl).asString().getBody();
40
+            }
41
+        }catch (UnirestException e){
42
+            e.printStackTrace();
43
+        }
44
+            return null;
22 45
     }
46
+
47
+
23 48
 }

+ 9
- 0
YouAreEll.iml View File

@@ -11,5 +11,14 @@
11 11
     <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.6" level="project" />
12 12
     <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
13 13
     <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.6" level="project" />
14
+    <orderEntry type="library" name="Maven: com.mashape.unirest:unirest-java:1.4.9" level="project" />
15
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
16
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
17
+    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
18
+    <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
19
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.1" level="project" />
20
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.4" level="project" />
21
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.2" level="project" />
22
+    <orderEntry type="library" name="Maven: org.json:json:20160212" level="project" />
14 23
   </component>
15 24
 </module>

+ 5
- 0
pom.xml View File

@@ -18,5 +18,10 @@
18 18
             <artifactId>jackson-databind</artifactId>
19 19
             <version>2.8.6</version>
20 20
         </dependency>
21
+        <dependency>
22
+            <groupId>com.mashape.unirest</groupId>
23
+            <artifactId>unirest-java</artifactId>
24
+            <version>1.4.9</version>
25
+        </dependency>
21 26
     </dependencies>
22 27
 </project>