Commit eaad53aa authored by Abzal Kultayev's avatar Abzal Kultayev

Добавлены методы для смены пароля и отправки уведомления

parent e480a340
package kz.arta.synergy.api.pojo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* Created by: Abzal Kultayev
* Date: 25.11.16
* Time: 16:00
*/
public class NotificationSend implements Serializable {
private String header;
private String message;
private List<String> users = new ArrayList<>();
private List<String> groups = new ArrayList<>();
private List<String> emails = new ArrayList<>();
private List<String> logins = new ArrayList<>();
public NotificationSend() {}
public String getHeader() {
return header;
}
public void setHeader(String header) {
this.header = header;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public List<String> getUsers() {
return users;
}
public void setUsers(List<String> users) {
this.users = users;
}
public List<String> getGroups() {
return groups;
}
public void setGroups(List<String> groups) {
this.groups = groups;
}
public List<String> getEmails() {
return emails;
}
public void setEmails(List<String> emails) {
this.emails = emails;
}
public List<String> getLogins() {
return logins;
}
public void setLogins(List<String> logins) {
this.logins = logins;
}
}
package kz.arta.synergy.api.services;
import kz.arta.synergy.api.JsonUtils;
import kz.arta.synergy.api.Query;
import kz.arta.synergy.api.QueryContext;
import kz.arta.synergy.api.RestHttpQuery;
import kz.arta.synergy.api.pojo.NotificationSend;
import java.io.IOException;
import java.util.Arrays;
/**
* Created by: Abzal Kultayev
* Date: 25.11.16
* Time: 15:55
*
* Сервис для отправления нотификации
*/
public class NotificationService {
private final RestHttpQuery restHttpQuery;
private NotificationService(QueryContext context) {
this.restHttpQuery = new RestHttpQuery(context);
}
public static NotificationService newInstance(QueryContext queryContext) {
return new NotificationService(queryContext);
}
public String sendNotification(String header, String body, String... userIDs) throws IOException {
NotificationSend notification = new NotificationSend();
notification.setHeader(header);
notification.setMessage(body);
notification.setUsers(Arrays.asList(userIDs));
return sendNotification(notification);
}
public String sendNotification(NotificationSend notification) throws IOException {
Query query = Query.newInstance()
.methodPost()
.header("Content-Type", "application/json; charset=utf-8")
.url("/rest/api/notifications/send")
.body(JsonUtils.toJson(notification));
return restHttpQuery.doQuery(query);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment