Skip to content

Commit 548fe2d

Browse files
committed
merge
2 parents ffa9627 + f651f63 commit 548fe2d

File tree

5 files changed

+31
-24
lines changed

5 files changed

+31
-24
lines changed

README.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
# zulip-java-rest
22
A thin and easy to use Java library to access the [Zulip API](https://zulipchat.com/api/).
3-
This library covers every API call of the Zulip API except for real-time events but is in it's core really simple.
3+
This library covers every API call of the Zulip REST API except for real-time events. It is aimed at being as simple as possible.
44
# How to use
55
## Setup and usage
6+
7+
### JAR
8+
Simply build this project with `mvn package` and you can use the .jar in your classpath.
9+
610
### Maven
7-
Just add the following dependency to your pom.xml or the JAR of this repository to your projects build path.
11+
Just add the following dependency to your pom.xml.
812

913
```xml
1014
<dependency>
11-
<groupId>io.taliox</groupId>
12-
<artifactId>zulip-java-rest</artifactId>
13-
<version>0.0.1-SNAPSHOT</version>
15+
<groupId>io.taliox</groupId>
16+
<artifactId>zulip-java-rest</artifactId>
17+
<version>0.0.2</version>
1418
</dependency>
1519
```
1620
### Where do I get the API key for authentication?
17-
You can either use a bot or a user account to communicate with the API. To find out the needed token please see the official [Zulip documentation](https://zulipchat.com/api/api-keys).
21+
You can either use a bot or a user account to communicate with the API. To find out the needed token or how to create a bot please see the official [Zulip documentation](https://zulipchat.com/api/api-keys).
1822

1923
### At first Create the ZulipRestExecutor to communicate with the Zulip API
2024
The core of this library is the `ZulipRestExecutor` it is responsible for performing HTTP calls.
@@ -27,14 +31,14 @@ To change credentials after instantiating the ZulipRestExecutor it is recommende
2731

2832
### How to use the ZulipRestExecutor?
2933
To perform an API call you should use the `executeCall(ZulipRestAPICall call)` method of the newly created object.
30-
All API calls are packed inside the library as instantiatable objects which be executed by the `ZulipRestExecutor`.
31-
The naming convention of all call objects is like the following: `HTTP request mehtod + object of action`.
34+
All API calls are packed inside the library as instantiatable objects which can be executed by the `ZulipRestExecutor`.
35+
The naming convention of all call objects is like the following: `HTTP request method + object of action`.
3236

3337
So for instance if we want to send a message to someone on our Zulip server we need to create a `PostMessage` object to pass it into our executeCall method.
3438

3539
```java
36-
PostMessage postMessage = new PostMessage("anotheruser@zulip.com", "Hello world");
37-
String response = executor.executeCall(ZulipRestAPICall call)
40+
PostMessage postMessage = new PostMessage("anotheruser@zulip.com", "hello world");
41+
String response = executor.executeCall(postMessage)
3842
```
3943

4044
executeCall always returns the answer from the Zulip server for instance whether the call was successful or not.
@@ -64,13 +68,13 @@ String response = executor.executeCall(getAllStreams);
6468

6569
### Send a message to a single person
6670
```java
67-
PostMessage postMessage = new PostMessage("anotheruser@zulip.com", "Hello world");
71+
PostMessage postMessage = new PostMessage("anotheruser@zulip.com", "hello world");
6872
String response = executor.executeCall(postMessage);
6973
```
7074

7175
### Send a message to a stream
7276
```java
73-
PostMessage postMessage = new PostMessage("Streamname", "topicname", "Hello world");
77+
PostMessage postMessage = new PostMessage("streamname", "topicname", "hello world");
7478
String response = executor.executeCall(postMessage);
7579
```
7680

@@ -82,16 +86,17 @@ String response = executor.executeCall(createUser);
8286

8387
### Create a new stream
8488
```java
85-
PostCreateStream createStream = new PostCreateStream("[{\"description\":\"This is new\",\"name\":\"A new Stream\"}]");
89+
PostCreateStream createStream = new PostCreateStream("[{\"description\":\"This is a new stream\",\"name\":\"A new Stream\"}]");
8690
createStream.setInvite_only(true);
8791
createStream.setAnnounce(true);
8892
```
93+
8994
After instantiating the object to be executed you always can set optional parameters.
9095
In this case for example whether the newly created stream is supposed be invite only.
9196
This works the same for all objects.
9297

9398
### Delete a message
94-
```
99+
```java
95100
DeleteMessage deleteMessage = new DeleteMessage("54");
96101
String response = executor.executeCall(deleteMessage);
97102
```
@@ -104,14 +109,15 @@ patchMessage.setType(UpdateMessageTypes.change_later);
104109
String response = executor.executeCall(patchMessage);
105110
```
106111

107-
Please always refer to [official Zulip API documentation](https://zulipchat.com/api/) in case you are not sure what structure the parameters of an call object need to be.
108-
A full list of API calls, return types and parameters to perform calls can be found there.
112+
Please always refer to the [official Zulip API documentation](https://zulipchat.com/api/) in case you are not sure what structure the parameters of an call object need to be.
113+
A full list of API calls, return types and parameters to perform calls can be found over there.
109114

110115
We are working on more examples and tests within the library so you can try it out right of the box.
111116

112117
## Contributing
113-
Thanks for your interest! Do not hesitate to open an issue if you have a question, feedback or found something that`s not supposed to be working like it should.
114-
Pull requests for improvements of the library are also highly appriciated.
118+
Thanks for your interest! Do not hesitate to open an issue if you have a question, feedback or found something that is not working like it should.
119+
120+
Pull requests for improvements of the library or it's documentation are also highly appreciated.
115121

116122
## Licenses
117123
This library and its content is released under the [MIT License](https://choosealicense.com/licenses/mit/).

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>io.taliox</groupId>
66
<artifactId>zulip-java-rest</artifactId>
7-
<version>0.0.3-SNAPSHOT</version>
7+
<version>1.0.0-SNAPSHOT</version>
88
<inceptionYear>2019</inceptionYear>
99

1010
<parent>

src/main/java/io/taliox/zulip/ZulipRestExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ public ZulipRestExecutor(String userName, String password, String serverURL) {
3737
public String executeCall(ZulipRestAPICall call) {
3838
return call.execute(this);
3939
}
40-
41-
}
40+
41+
}

src/main/java/io/taliox/zulip/calls/ZulipRestAPICall.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ protected String performRequest(HashMap<String, String> parameters, HttpRequestB
138138
"Bad request. The server could not process your request sucessfully: " + builder.toString());
139139
}
140140

141+
base.releaseConnection();
142+
141143
} catch (ClientProtocolException e) {
142144
e.printStackTrace();
143145
} catch (IOException e) {
@@ -254,4 +256,4 @@ protected void setParameters(HashMap<String, String> parameters) {
254256
this.parameters = parameters;
255257
}
256258

257-
}
259+
}

src/main/java/io/taliox/zulip/calls/users/GetProfile.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ public GetProfile() {
2828
* @see io.taliox.zulip.calls.Callable#execute()
2929
*/
3030
public String execute(ZulipRestExecutor executor) {
31-
setHttpController(executor.httpController);
3231
setHttpController(executor.httpController);
3332
HttpGet get = new HttpGet(this.httpController.getServer() + getZulipAPIUrl());
3433
return performRequest(getParameters(), get);
3534
}
3635

37-
}
36+
}

0 commit comments

Comments
 (0)