Skip to content
Snippets Groups Projects
Commit 861a25af authored by Martin Staehr's avatar Martin Staehr
Browse files

feat: adding communication interface

TODO: bump java version to 1.8 for Instant to work
parent 62a702ba
No related branches found
No related tags found
No related merge requests found
package unipotsdam.gf.interfaces;
import unipotsdam.gf.modules.communication.model.chat.ChatMessage;
import unipotsdam.gf.modules.communication.model.chat.ChatRoom;
import unipotsdam.gf.modules.communication.model.user.User;
import unipotsdam.gf.modules.communication.model.user.UserCredentials;
import unipotsdam.gf.modules.communication.model.user.UserRegistrationInformation;
import java.util.List;
/**
* Provides connection to rocket chat
*/
public interface ICommunication {
/**
* related endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/history/
* get last 20 chat messages of specific chatroom
*
* @param roomId ID of room of user
* @return List of Chat Messages
*/
List<ChatMessage> getChatHistory(String roomId);
/**
* endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/create/
* creates chatroom
*
* @param name chat room name
* @param userIds member of chat by id; can be empty
* @return chat room id
*/
String createChatRoom(String name, List<String> userIds);
/**
* endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/invite/
*
* @param roomId chat room the user should be add to
* @param userId userID to add
* @return if user was added successfully
*/
boolean addUserToChatRoom(String roomId, String userId);
/**
* endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/settopic/
*
* @param roomId chat room where topic should be set
* @param topic topic of chat room
* @return true, if topic was set correctly
*/
boolean setChatRoomTopic(String roomId, String topic);
/**
* api: https://rocket.chat/docs/developer-guides/rest-api/groups/info/
* get information about the chat room
*
* @param roomId chat room id
* @return chat room information
*/
ChatRoom getChatRoomInfo(String roomId);
/**
* api: https://rocket.chat/docs/developer-guides/rest-api/authentication/login/
*
* @param userCredentials username and password
* @return information about user, especially authtoken for later use of endpoints
*/
User loginUser(UserCredentials userCredentials);
/**
* registers new user to rocket chat
*
* @param userRegistrationInformation registers user to rocket.chat
* @return user id
*/
String registerUser(UserRegistrationInformation userRegistrationInformation);
}
package unipotsdam.gf.modules.communication.model.chat;
import java.time.Instant;
public class ChatMessage {
String id;
String message;
Instant timestamp;
String username;
public ChatMessage() {}
public ChatMessage(String id, String message, Instant timestamp, String username) {
this.id = id;
this.message = message;
this.timestamp = timestamp;
this.username = username;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Instant getTimestamp() {
return timestamp;
}
public void setTimestamp(Instant timestamp) {
this.timestamp = timestamp;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
package unipotsdam.gf.modules.communication.model.chat;
public class ChatRoom {
String id;
String name;
public ChatRoom() {}
public ChatRoom(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package unipotsdam.gf.modules.communication.model.user;
public class User {
String id;
String authToken;
public User() {}
public User(String id, String authToken) {
this.id = id;
this.authToken = authToken;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAuthToken() {
return authToken;
}
public void setAuthToken(String authToken) {
this.authToken = authToken;
}
}
package unipotsdam.gf.modules.communication.model.user;
public class UserCredentials {
String username;
String password;
public UserCredentials() {}
public UserCredentials(String username, String password) {
this.username = username;
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
package unipotsdam.gf.modules.communication.model.user;
public class UserRegistrationInformation {
private String username;
private String email;
private String pass;
private String name;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment