Skip to content
Snippets Groups Projects
Commit 139da86c authored by Martin Stähr's avatar Martin Stähr
Browse files

refactor: communication interface and add missing functions

parent 94262250
No related branches found
No related tags found
No related merge requests found
package unipotsdam.gf.interfaces; package unipotsdam.gf.interfaces;
import unipotsdam.gf.core.management.user.User;
import unipotsdam.gf.modules.communication.model.Message;
import unipotsdam.gf.modules.communication.model.chat.ChatMessage; import unipotsdam.gf.modules.communication.model.chat.ChatMessage;
import unipotsdam.gf.modules.communication.model.chat.ChatRoom; 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; import java.util.List;
...@@ -23,25 +22,27 @@ public interface ICommunication { ...@@ -23,25 +22,27 @@ public interface ICommunication {
List<ChatMessage> getChatHistory(String roomId); List<ChatMessage> getChatHistory(String roomId);
boolean sendMessageToChat(Message message);
/** /**
* endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/create/ * endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/create/
* creates chatroom * creates chatroom
* *
* @param name chat room name * @param name chat room name
* @param userIds member of chat by id; can be empty * @param studentIdentifierList member of chat by id
* @return chat room id * @return chat room id
*/ */
String createChatRoom(String name, List<String> userIds); String createChatRoom(String name, List<User> studentIdentifierList);
/** /**
* endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/invite/ * endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/invite/
* *
* @param roomId chat room the user should be add to * @param roomId chat room the user should be add to
* @param userId userID to add * @param user information about user
* @return if user was added successfully * @return if user was added successfully
*/ */
boolean addUserToChatRoom(String roomId, String userId); boolean addUserToChatRoom(String roomId, User user);
/** /**
* endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/settopic/ * endpoint: https://rocket.chat/docs/developer-guides/rest-api/groups/settopic/
...@@ -65,17 +66,17 @@ public interface ICommunication { ...@@ -65,17 +66,17 @@ public interface ICommunication {
/** /**
* api: https://rocket.chat/docs/developer-guides/rest-api/authentication/login/ * api: https://rocket.chat/docs/developer-guides/rest-api/authentication/login/
* *
* @param userCredentials username and password * @param user username and password
* @return information about user, especially authtoken for later use of endpoints * @return information about user, especially authtoken for later use of endpoints
*/ */
User loginUser(UserCredentials userCredentials); boolean loginUser(User user);
/** /**
* registers new user to rocket chat * registers new user to rocket chat
* *
* @param userRegistrationInformation registers user to rocket.chat * @param user registers user to rocket.chat
* @return user id * @return user id
*/ */
String registerUser(UserRegistrationInformation userRegistrationInformation); boolean registerUser(User user);
} }
package unipotsdam.gf.modules.communication.model;
public class Message {
private String roomIdOrChannel;
private String message;
public Message() {}
public Message(String roomIdOrChannel, String message) {
this.roomIdOrChannel = roomIdOrChannel;
this.message = message;
}
public String getRoomIdOrChannel() {
return roomIdOrChannel;
}
public void setRoomIdOrChannel(String roomIdOrChannel) {
this.roomIdOrChannel = roomIdOrChannel;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String toString() {
return "Message{" +
"roomIdOrChannel='" + roomIdOrChannel + '\'' +
", message='" + message + '\'' +
'}';
}
}
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