-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
770737d
commit 3836d07
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
at_client/src/main/java/org/atsign/client/api/impl/notification/NotificationParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.atsign.client.api.impl.notification; | ||
|
||
import java.util.UUID; | ||
|
||
import org.atsign.common.AtSign; | ||
import org.atsign.common.KeyBuilders; | ||
import org.atsign.common.NotificationEnums; | ||
import org.atsign.common.Keys.AtKey; | ||
import org.atsign.common.Keys.SharedKey; | ||
import org.atsign.common.NotificationEnums.Operation; | ||
|
||
|
||
public class NotificationParams { | ||
|
||
private String id; | ||
private AtKey atKey; | ||
private String value; // nullable (optional) | ||
private NotificationEnums.Operation operation; | ||
private NotificationEnums.MessageType messageType; | ||
private NotificationEnums.Priority priority; | ||
private NotificationEnums.Strategy strategy; | ||
// private Integer latestN = 1; | ||
// private String notifier = SYSTEM; | ||
|
||
/** | ||
* | ||
* @param atKey AtKey object which contains the sharedBy and sharedWith atSign. | ||
* @param value nullable (optional) | ||
* @return NotificationParams object | ||
*/ | ||
public static NotificationParams forUpdate(AtKey atKey, String value) { | ||
NotificationParams params = new NotificationParams(); | ||
params.id = UUID.randomUUID().toString(); | ||
params.atKey = atKey; | ||
params.value = value; | ||
params.operation = Operation.UPDATE; | ||
params.messageType = NotificationEnums.MessageType.KEY; | ||
params.priority = NotificationEnums.Priority.LOW; | ||
params.strategy = NotificationEnums.Strategy.ALL; | ||
return params; | ||
} | ||
|
||
public static NotificationParams forDelete(AtKey atKey) { | ||
NotificationParams params = new NotificationParams(); | ||
params.id = UUID.randomUUID().toString(); | ||
params.atKey = atKey; | ||
params.operation = Operation.DELETE; | ||
params.messageType = NotificationEnums.MessageType.KEY; | ||
params.priority = NotificationEnums.Priority.LOW; | ||
params.strategy = NotificationEnums.Strategy.ALL; | ||
return params; | ||
} | ||
|
||
public static NotificationParams forText(String text, String whomToNotify, Boolean shouldEncrypt) { | ||
|
||
SharedKey sharedKey = new KeyBuilders.SharedKeyBuilder( | ||
new AtSign(""), new AtSign(whomToNotify)).build(); | ||
sharedKey.metadata.isEncrypted = shouldEncrypt; | ||
|
||
|
||
NotificationParams params = new NotificationParams(); | ||
params.id = UUID.randomUUID().toString(); | ||
params.atKey = sharedKey; | ||
params.operation = Operation.UPDATE; | ||
params.messageType = NotificationEnums.MessageType.TEXT; | ||
params.priority = NotificationEnums.Priority.LOW; | ||
params.strategy = NotificationEnums.Strategy.ALL; | ||
return params; | ||
} | ||
|
||
} |