diff --git a/README.md b/README.md index a9b07c4..45adb3a 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ The [Novu Java](https://novu.co) SDK provides a fluent and expressive interface ``` **Gradle users:** -```gradle +```groovy // add dependency dependencies { implementation 'co.novu:novu-java:1.6.0' @@ -88,73 +88,98 @@ public class Main { **Trigger** an event - send notification to subscribers: ```java + TriggerEventRequest event = new TriggerEventRequest(); + event.setName("name"); + + SubscriberRequest subscriberRequest = new SubscriberRequest(); + subscriberRequest.setFirstName("fName"); + subscriberRequest.setLastName("lName"); + subscriberRequest.setEmail("mail@sample.com"); + subscriberRequest.setSubscriberId("subId"); + Map payload = new HashMap<>(); payload.put("customVariables", "Hello"); - Map to = new HashMap<>(); - to.put("subscriberId", ""); - to.put("phone", "07983882186"); + event.setTo(subscriberRequest); + event.setPayload(payload); + event.setActor("actor"); + event.setTenant("tenant"); - Map event = new HashMap<>(); - event.put("name", ""); - event.put("payload", payload); - event.put("to", to); - - // Call a method to perform trigger event with 'event' map - // Example method: - triggerEvent(event); + // Call the method to perform trigger event with 'event' request + novu.triggerEvent(event); ``` **Bulk Trigger** events: ```java - List> events = new ArrayList<>(); + List events = new ArrayList<>(); + // First event - Map event1 = new HashMap<>(); - event1.put("name", ""); - event1.put("to", ""); - Map payload1 = new HashMap<>(); - payload1.put("customVariables", "Hello"); - event1.put("payload", payload1); + TriggerEventRequest event1 = new TriggerEventRequest(); + event1.setName("name"); + + SubscriberRequest subscriberRequest = new SubscriberRequest(); + subscriberRequest.setFirstName("fName"); + subscriberRequest.setLastName("lName"); + subscriberRequest.setEmail("mail@sample.com"); + subscriberRequest.setSubscriberId("subId"); + + Map payload = new HashMap<>(); + payload.put("customVariables", "Hello"); + + event1.setTo(subscriberRequest); + event1.setPayload(payload); + event1.setActor("actor"); + event1.setTenant("tenant"); events.add(event1); // Second event - Map event2 = new HashMap<>(); - event2.put("name", ""); - event2.put("to", ""); - Map payload2 = new HashMap<>(); - payload2.put("customVariables", "World"); - event2.put("payload", payload2); - events.add(event2); + TriggerEventRequest event2 = new TriggerEventRequest(); + event2.setName("name"); - // Third event - Map event3 = new HashMap<>(); - event3.put("name", ""); - event3.put("to", ""); - Map payload3 = new HashMap<>(); - payload3.put("customVariables", "Again"); - event3.put("payload", payload3); - events.add(event3); + SubscriberRequest subscriberRequest = new SubscriberRequest(); + subscriberRequest.setFirstName("fName"); + subscriberRequest.setLastName("lName"); + subscriberRequest.setEmail("mail@sample.com"); + subscriberRequest.setSubscriberId("subId"); - // Call a method to perform bulk trigger with 'events' list + Map payload = new HashMap<>(); + payload.put("customVariables", "Hello"); + + event2.setTo(subscriberRequest); + event2.setPayload(payload); + event2.setActor("actor"); + event2.setTenant("tenant"); + events.add(event2); - // Example method: - bulkTriggerEvent(events); + BulkTriggerEventRequest bulkEventRequest = new BulkTriggerEventRequest(); + bulkTriggerEventRequest.setEvents(events); + + // Call the method to perform bulk trigger with the request body + novu.bulkTriggerEvent(bulkEventRequest); ``` **Broadcast** event to all existing subscribers: ```java + TriggerEventRequest event = new TriggerEventRequest(); + event.setName("name"); + + SubscriberRequest subscriberRequest = new SubscriberRequest(); + subscriberRequest.setFirstName("fName"); + subscriberRequest.setLastName("lName"); + subscriberRequest.setEmail("mail@sample.com"); + subscriberRequest.setSubscriberId("subId"); + Map payload = new HashMap<>(); payload.put("customVariables", "Hello"); - Map event = new HashMap<>(); - event.put("name", ""); - event.put("payload", payload); - event.put("transactionId", ""); - // Call a method to perform broadcast event with 'event' map - - // Example method: - broadcastEvent(event); + event.setTo(subscriberRequest); + event.setPayload(payload); + event.setActor("actor"); + event.setTenant("tenant"); + + // Call the method to perform broadcast event with the request body + novu.broadcastEvent(event); ``` **Cancel** triggered event. Using a previously generated transactionId during the event trigger, this action will cancel any active or pending workflows: @@ -162,197 +187,174 @@ public class Main { ```java String transactionId = ""; - // Call a method to cancel event using the 'transactionId' - - // Example method: - cancelTriggeredEvent(transactionId); + // Call the method to cancel event using the 'transactionId' + novu.cancelTriggeredEvent(transactionId); ``` ### Subscribers ```java - // Create subscriber & get the details of the recently created subscriber returned. - Map subscriber = new HashMap<>(); - subscriber.put("subscriberId", "YOUR_SYSTEM_USER_ID"); - subscriber.put("email", ""); - subscriber.put("firstName", ""); - subscriber.put("lastName", ""); - subscriber.put("phone", ""); - subscriber.put("avatar", ""); - - // Call a method to create a subscriber with the 'subscriber' map + //=== Create subscriber & get the details of the recently created subscriber returned. ===// + SubscriberRequest subscriber = new SubscriberRequest(); + subscriber.setFirstName("fName"); + subscriber.setLastName("lName"); + subscriber.setEmail("email@sample.com"); - // Example method: - createSubscriber(subscriber); + // Call the method to create a subscriber with the 'subscriber' request + novu.createSubscriber(subscriber); - // Get subscriber + //=== Get subscriber ===// String subscriberId = ""; // Replace with the actual subscriber ID - // Call a method to get the subscriber using 'subscriberId' - - // Example method: - getSubscriber(subscriberId); + + // Call the method to get the subscriber using 'subscriberId' + novu.getSubscriber(subscriberId); - // Update subscriber - Map updatedFields = new HashMap<>(); - updatedFields.put("email", ""); - updatedFields.put("firstName", ""); - updatedFields.put("lastName", ""); - updatedFields.put("phone", ""); - updatedFields.put("avatar", ""); + //=== Update subscriber ===// + UpdateSubscriberRequest request = new UpdateSubscriberRequest(); + request.setFirstName("name"); + request.setLastName("lName"); + // Add other fields - // Call a method to update the subscriber with 'subscriberId' and 'updatedFields' map + // Call the method to update the subscriber with the request body and the subscriber's ID + novu.updateSubscriber(request, subscriberId); - // Example method: - updateSubscriber(subscriberId, updatedFields); - - // Delete subscriber + //=== Delete subscriber ===// String subscriberId = ""; // Replace with the actual subscriber ID - // Call a method to delete the subscriber using 'subscriberId' - - // Example method: - deleteSubscriber(subscriberId); + // Call the method to delete the subscriber using their 'subscriberId' + novu.deleteSubscriber(subscriberId); - // Update subscriber credentials + //=== Update subscriber credentials ===// String subscriberId = ""; // Replace with the actual subscriber ID - Map credentialsUpdate = new HashMap<>(); - credentialsUpdate.put("providerId", ""); - credentialsUpdate.put("credentials", ""); + UpdateSubscriberCredentialsRequest request = new UpdateSubscriberCredentialsRequest(); + request.setProviderId("pId"); + // Add other fields - // Call a method to update subscriber credentials with 'subscriberId' and 'credentialsUpdate' map + // Call the method to update subscriber credentials with the request body and the subscriber's ID + novu.updateSubscriberCredentials(request, subscriberId); - // Example method: - updateSubscriberCredentials(subscriberId, credentialsUpdate); - - // Update subscriber online status + //=== Update subscriber online status ===// String subscriberId = ""; // Replace with the actual subscriber ID - boolean isOnlineStatus = true; // Set to true or false - // Call a method to update subscriber online status with 'subscriberId' and 'isOnlineStatus' - // Example method: - updateSubscriberOnlineStatus(subscriberId, isOnlineStatus); + UpdateSubscriberOnlineStatusRequest request = new UpdateSubscriberOnlineStatusRequest(); + request.setIsOnline(true); // Set to true or false + + // Call the method to update subscriber online status with the request body and the subscriber's ID + novu.updateSubscriberOnlineStatus(request, subscriberId); - // Get subscriber preferences + //=== Get subscriber preferences ===// String subscriberId = ""; // Replace with the actual subscriber ID - // Call a method to get subscriber preferences using 'subscriberId' - - // Example method: - getSubscriberPreferences(subscriberId); + + // Call the method to get a subscriber's preferences using 'subscriberId' + novu.getSubscriberPreferences(subscriberId); - // Update subscriber preference + //=== Update subscriber preference ===// String subscriberId = ""; // Replace with the actual subscriber ID String templateId = ""; // Replace with the actual template ID - Map preferenceUpdate = new HashMap<>(); - preferenceUpdate.put("channel", ""); - preferenceUpdate.put("enabled", ""); // Set to true or false, optional + UpdateSubscriberPreferenceRequest request = new UpdateSubscriberPreferenceRequest(); + request.setEnabled(false); // Set to true or false, optional - // Call a method to update subscriber preference using 'subscriberId', 'templateId', and 'preferenceUpdate' map + // Call the method to update subscriber preferences with the request body, 'subscriberId', and 'templateId' + novu.updateSubscriberPreference(request, subscriberId, templateId); - // Example method: - updateSubscriberPreference(subscriberId, templateId, preferenceUpdate); - - // Get a notification feed for a particular subscriber + //=== Get a notification feed for a particular subscriber ===// String subscriberId = ""; // Replace with the actual subscriber ID - // Call a method to get the notification feed for subscriber using 'subscriberId' - - // Example method: - getSubscriberNotificationsFeed(subscriberId); + + // Call the method to get the notification feed for a subscriber using 'subscriberId' + novu.getSubscriberNotificationsFeed(subscriberId); - // Get the unseen notification count for subscribers feed + //=== Get the unseen notification count for subscribers feed ===// String subscriberId = ""; // Replace with the actual subscriber ID - // Call a method to get the unseen notification count for subscriber using 'subscriberId' + + // Call the method to get the unseen notification count for subscriber using 'subscriberId' + novu.getSubscriberUnseenNotificationsCount(subscriberId); - // Example method: - getSubscriberUnseenNotificationsCount(subscriberId); - - // Mark a subscriber feed message as seen + //=== Mark a subscriber feed message as seen ===// String subscriberId = ""; // Replace with the actual subscriber ID String messageId = ""; // Replace with the actual message ID - Map request = new HashMap<>(); - //request - - // Call a method to mark a subscriber's feed message as seen using 'subscriberId', 'messageId', and 'options' map + MarkSubscriberFeedAsRequest request = new MarkSubscriberFeedAsRequest(); + Mark mark = new Mark(); + mark.setRead(true); + mark.setSeen(true); + request.setMark(mark); + request.setMessageId(messageId); - // Example method: - markSubscriberMessageFeedAs(subscriberId, messageId, request); + // Call the method to mark a subscriber's feed message as seen using the request body and 'subscriberId' + novu.markSubscriberMessageFeedAs(subscriberId, messageId, request); - // Mark message action as seen + //=== Mark message action as seen ===// String subscriberId = ""; // Replace with the actual subscriber ID String messageId = ""; // Replace with the actual message ID String type = ""; // Replace with the actual action type - Map request = new HashMap<>(); - //request + MarkMessageActionAsSeenRequest request = new MarkMessageActionAsSeenRequest(); + request.setStatus("read"); - // Call a method to mark a subscriber's message action as seen using 'subscriberId', 'messageId', 'type', and 'options' map - - // Example method: - markMessageActionAsSeen(subscriberId, messageId, type, request); + // Call the method to mark a subscriber's message action as seen using the request body, 'subscriberId', 'messageId' and 'type' + novu.markMessageActionAsSeen(request, subscriberId, messageId, type); ``` ### Topics ```java - // Create a Topic - Map topic = new HashMap<>(); - topic.put("key", key); - topic.put("name", name); - - // Call a method to create a topic with 'key' and 'name' + //=== Create a Topic ===// + TopicRequest topicRequest = new TopicRequest(); + topicRequest.setKey("key"); + topicRequest.setName("name"); - // Example method: - createTopic(topic); + // Call the method to create a topic with the request body + novu.createTopic(topicRequest); - // Fetch all topics - // Call a method to get the topics list + //=== Fetch all Topics ===// + FilterTopicsRequest topicsRequest = new FilterTopicsRequest(); + topicsRequest.setPage(1); + topicsRequest.setPageSize(10); + topicsRequest.setKey("key"); + + // Call the method to get the Topics list + novu.filterTopics(topicsRequest); - // Example method: - filterTopics(); + //=== Get a Topic ===// + String topickey = ""; // Replace with the actual Topic key - // Get a topic - String topickey = "topicKey"; // Replace with the actual subscriber ID + // Call the method to get a Topic using the 'topickey' + novu.getTopic(topickey); - // Call a method to get the topic using 'topickey' - - // Example method: - getTopic(topickey); - - // Add subscribers to a topic - String topicKey = ""; + //=== Add subscribers to a Topic ===// + String topicKey = ""; // Replace with the actual Topic key List subscribers = new ArrayList<>(); - // subscribers request + subscribers.add(""); + SubscriberAdditionRequest additionRequest = new SubscriberAdditionRequest(); + additionRequest.setSubscribers(subscribers); - // Call a method to add subscribers to a topic using 'topicKey' and 'subscribers' list + // Call the method to add subscribers to a Topic using the request body and 'topicKey' + novu.addSubscribersToTopic(additionRequest, topicKey); - // Example method: - addSubscribersToTopic(topicKey, subscribers); - - // Remove subscribers from a topic + //=== Remove subscribers from a Topic ===// String topicKey = ""; // Replace with the actual topic key List subscribers = new ArrayList<>(); - // subscribers request + subscribers.add(""); - // Call a method to remove subscribers from a topic using 'topicKey' and 'subscribers' list + SubscriberAdditionRequest request = new SubscriberAdditionRequest(); + request.setSubscribers(subscribers); - // Example method: - removeSubscribersFromTopic(topicKey, subscribers); + // Call the method to remove subscribers from a Topic using the request body and 'topicKey' + novu.removeSubscribersFromTopic(request, topicKey); - // Rename a topic + //=== Rename a Topic ===// String topicKey = ""; // Replace with the actual topic key - Map topic = new HashMap<>(); - topic.put("name", name); - - // Call a method to rename a topic using 'topicKey' and 'topic' + RenameTopicRequest renameTopicRequest = new RenameTopicRequest(); + renameTopicRequest.setName("name"); - // Example method: - renameTopic(topicKey, topic); + // Call the method to rename a Topic using the request body and 'topicKey' + novu.renameTopic(renameTopicRequest, topicKey); ``` ### Changes diff --git a/config/checkstyle/checkstyle-suppressions.xml b/config/checkstyle/checkstyle-suppressions.xml index 883bbd2..8ec0892 100644 --- a/config/checkstyle/checkstyle-suppressions.xml +++ b/config/checkstyle/checkstyle-suppressions.xml @@ -7,6 +7,9 @@ - + + + + \ No newline at end of file diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 83adbc8..ee7906c 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -101,7 +101,9 @@ - + + + diff --git a/src/main/java/co/novu/common/base/Novu.java b/src/main/java/co/novu/common/base/Novu.java index ac602cf..a8a3215 100644 --- a/src/main/java/co/novu/common/base/Novu.java +++ b/src/main/java/co/novu/common/base/Novu.java @@ -126,6 +126,28 @@ import lombok.extern.slf4j.Slf4j; +/** + * Main entry point for initialising and accessing the functionalities provided in the SDK. + * This class provides two constructors. It can be constructed either by providing an API key + * (gotten from the web portal) or by providing + * an instance of {@link NovuConfig}. + * + *

+ * For example: + *


+ * // Using an API key only
+ * Novu novu = new Novu("apiKey");
+ * 
+ * + *

+ * // Using NovuConfig
+ * NovuConfig novuConfig = new NovuConfig("apiKey");
+ * Novu novu = new Novu(novuConfig);
+ * 
+ * + * @author Joseph Olugbohunmi link + * @author Mukhtar Onifade link + */ @Slf4j public final class Novu { @@ -168,10 +190,18 @@ public final class Novu { private final WorkflowOverrideHandler workflowOverrideHandler; + /** + * Primary constructor for initialising Novu. + * @param apiKey API Key gotten from Settings + */ public Novu(final String apiKey) { this(new NovuConfig(apiKey)); } + /** + * Secondary constructor for initialising Novu. + * @param config an instance of {@link NovuConfig}, used to provide configurations to the SDK. + */ public Novu(final NovuConfig config) { RestHandler restHandler = new RestHandler(config); this.novuConfig = config; @@ -195,6 +225,13 @@ public Novu(final NovuConfig config) { this.workflowOverrideHandler = new WorkflowOverrideHandler(restHandler); } + /** + * Trigger an event such as sending notification to subscribers. + * @param request an instance of {@link TriggerEventRequest} + * @return {@link TriggerEventResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public TriggerEventResponse triggerEvent(final TriggerEventRequest request) throws IOException, NovuNetworkException { try { @@ -205,6 +242,13 @@ public TriggerEventResponse triggerEvent(final TriggerEventRequest request) } } + /** + * Trigger multiple events in a single transaction. + * @param request an instance of {@link BulkTriggerEventRequest} + * @return {@link BulkTriggerEventResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BulkTriggerEventResponse bulkTriggerEvent(final BulkTriggerEventRequest request) throws IOException, NovuNetworkException { try { @@ -215,6 +259,13 @@ public BulkTriggerEventResponse bulkTriggerEvent(final BulkTriggerEventRequest r } } + /** + * Broadcast an event to all existing subscribers. + * @param request an instance of {@link TriggerEventRequest} + * @return {@link TriggerEventResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public TriggerEventResponse broadcastEvent(final TriggerEventRequest request) throws IOException, NovuNetworkException { try { @@ -225,6 +276,13 @@ public TriggerEventResponse broadcastEvent(final TriggerEventRequest request) } } + /** + * Cancel a running event. + * @param transactionId the transaction ID of the running event + * @return {@link CancelEventResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public CancelEventResponse cancelTriggeredEvent(final String transactionId) throws IOException, NovuNetworkException { try { @@ -235,6 +293,14 @@ public CancelEventResponse cancelTriggeredEvent(final String transactionId) } } + /** + * Retrieve all notifications ever sent with the API key provided. This function supports + * pagination. + * @param request an instance of {@link NotificationRequest} + * @return {@link NotificationsResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public NotificationsResponse getNotifications(final NotificationRequest request) throws IOException, NovuNetworkException { try { @@ -245,6 +311,12 @@ public NotificationsResponse getNotifications(final NotificationRequest request) } } + /** + * Retrieve the statistics of all notifications ever sent with the API key provided. + * @return {@link NotificationStatsResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public NotificationStatsResponse getNotificationsStats() throws IOException, NovuNetworkException { try { @@ -255,6 +327,12 @@ public NotificationStatsResponse getNotificationsStats() } } + /** + * Retrieve the statistics of notifications graph associated with the API key provided. + * @return {@link NotificationGraphStatsResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public NotificationGraphStatsResponse getNotificationGraphStats() throws IOException, NovuNetworkException { try { @@ -265,6 +343,13 @@ public NotificationGraphStatsResponse getNotificationGraphStats() } } + /** + * Retrieve a particular Notification. + * @param notificationId the ID of the Notification to be retrieved + * @return {@link NotificationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public NotificationResponse getNotification(final String notificationId) throws IOException, NovuNetworkException { try { @@ -275,6 +360,14 @@ public NotificationResponse getNotification(final String notificationId) } } + /** + * Retrieve all Subscribers associated with the API key provided. This function supports pagination. + * @param page the page number to be retrieved + * @param limit the number of items to be retrieved + * @return {@link BulkSubscriberResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BulkSubscriberResponse getSubscribers(final Integer page, final Integer limit) throws IOException, NovuNetworkException { try { @@ -285,6 +378,13 @@ public BulkSubscriberResponse getSubscribers(final Integer page, final Integer l } } + /** + * Create a Subscriber. + * @param request an instance of {@link SubscriberRequest} + * @return {@link CreateSubscriberResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public CreateSubscriberResponse createSubscriber(final SubscriberRequest request) throws IOException, NovuNetworkException { try { @@ -295,6 +395,13 @@ public CreateSubscriberResponse createSubscriber(final SubscriberRequest request } } + /** + * Create multiple Subscribers in a single transaction. + * @param request an instance of {@link BulkSubscriberRequest} + * @return {@link CreateBulkSubscriberResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public CreateBulkSubscriberResponse createSubscriberBulk(final BulkSubscriberRequest request) throws IOException, NovuNetworkException { try { @@ -305,6 +412,13 @@ public CreateBulkSubscriberResponse createSubscriberBulk(final BulkSubscriberReq } } + /** + * Retrieve a particular Subscriber. + * @param subscriberId the ID of the Subscriber to be retrieved + * @return {@link SingleSubscriberResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleSubscriberResponse getSubscriber(final String subscriberId) throws IOException, NovuNetworkException { try { @@ -315,6 +429,14 @@ public SingleSubscriberResponse getSubscriber(final String subscriberId) } } + /** + * Update a Subscriber. + * @param request an instance of {@link UpdateSubscriberRequest} + * @param subscriberId the ID of the Subscriber to be updated + * @return {@link SingleSubscriberResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleSubscriberResponse updateSubscriber(final UpdateSubscriberRequest request, final String subscriberId) throws IOException, NovuNetworkException { try { @@ -325,6 +447,13 @@ public SingleSubscriberResponse updateSubscriber(final UpdateSubscriberRequest r } } + /** + * Delete a Subscriber. + * @param subscriberId the ID of the Subscriber to be deleted + * @return {@link SubscriberDeleteResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SubscriberDeleteResponse deleteSubscriber(final String subscriberId) throws IOException, NovuNetworkException { try { @@ -335,6 +464,14 @@ public SubscriberDeleteResponse deleteSubscriber(final String subscriberId) } } + /** + * Update a Subscriber's credentials. + * @param request an instance of {@link UpdateSubscriberCredentialsRequest} + * @param subscriberId the ID of the Subscriber to be updated + * @return {@link SingleSubscriberResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleSubscriberResponse updateSubscriberCredentials(final UpdateSubscriberCredentialsRequest request, final String subscriberId) throws IOException, NovuNetworkException { @@ -346,6 +483,14 @@ public SingleSubscriberResponse updateSubscriberCredentials(final UpdateSubscrib } } + /** + * Delete a Subscriber's credentials. + * @param subscriberId the ID of the Subscriber to be deleted + * @param providerId the ID of the Provider linked to the Subscriber + * @return {@link DeleteCredentialsResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public DeleteCredentialsResponse deleteSubscriberCredentials(final String subscriberId, final String providerId) throws IOException, NovuNetworkException { try { @@ -356,6 +501,14 @@ public DeleteCredentialsResponse deleteSubscriberCredentials(final String subscr } } + /** + * Update a Subscriber's online status. + * @param request an instance of {@link UpdateSubscriberOnlineStatusRequest} + * @param subscriberId the ID of the Subscriber to be updated + * @return {@link SingleSubscriberResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleSubscriberResponse updateSubscriberOnlineStatus(final UpdateSubscriberOnlineStatusRequest request, final String subscriberId) throws IOException, NovuNetworkException { @@ -367,6 +520,13 @@ public SingleSubscriberResponse updateSubscriberOnlineStatus(final UpdateSubscri } } + /** + * Retrieve a Subscriber's preferences. + * @param subscriberId the ID of the Subscriber whose preference is to be retrieved + * @return {@link SubscriberPreferenceResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SubscriberPreferenceResponse getSubscriberPreferences(final String subscriberId) throws IOException, NovuNetworkException { try { @@ -377,6 +537,15 @@ public SubscriberPreferenceResponse getSubscriberPreferences(final String subscr } } + /** + * Update a Subscriber's preferences. + * @param request an instance of {@link UpdateSubscriberPreferenceRequest} + * @param subscriberId the ID of the Subscriber to be updated + * @param templateId the ID of the Template linked to the Subscriber + * @return {@link SingleSubscriberPrefResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleSubscriberPrefResponse updateSubscriberPreferences(final UpdateSubscriberPreferenceRequest request, final String subscriberId, final String templateId) throws IOException, NovuNetworkException { @@ -388,6 +557,13 @@ public SingleSubscriberPrefResponse updateSubscriberPreferences(final UpdateSubs } } + /** + * Retrieve all Notifications feed associated with a Subscriber. This function supports pagination. + * @param subscriberId the ID of the Subscriber whose Notifications feed is to be retrieved + * @return {@link SubscriberNotificationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SubscriberNotificationResponse getSubscriberNotificationsFeed(final String subscriberId) throws IOException, NovuNetworkException { try { @@ -398,6 +574,13 @@ public SubscriberNotificationResponse getSubscriberNotificationsFeed(final Strin } } + /** + * Retrieve a Subscriber's unseen Notifications count. + * @param subscriberId the ID of the Subscriber whose count is to be retrieved + * @return {@link UnseenNotificationsCountResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public UnseenNotificationsCountResponse getSubscriberUnseenNotificationsCount(final String subscriberId) throws IOException, NovuNetworkException { try { @@ -408,6 +591,14 @@ public UnseenNotificationsCountResponse getSubscriberUnseenNotificationsCount(fi } } + /** + * Update a particular Subscriber's Message feed (either read or seen). + * @param request an instance of {@link MarkSubscriberFeedAsRequest} + * @param subscriberId the ID of the Subscriber whose Message feed is to be updated + * @return {@link SubscriberNotificationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SubscriberNotificationResponse markSubscriberMessageFeedAs(final MarkSubscriberFeedAsRequest request, final String subscriberId) throws IOException, NovuNetworkException { @@ -419,6 +610,14 @@ public SubscriberNotificationResponse markSubscriberMessageFeedAs(final MarkSubs } } + /** + * Update all the Message feeds associated to a Subscriber. + * @param request an instance of {@link MarkAllMessagesRequest} + * @param subscriberId the ID of the Subscriber whose Message feeds is to be updated + * @return {@link Long} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public Long markAllSubscriberMessagesFeedAs(final MarkAllMessagesRequest request, final String subscriberId) throws IOException, NovuNetworkException { try { @@ -429,6 +628,16 @@ public Long markAllSubscriberMessagesFeedAs(final MarkAllMessagesRequest request } } + /** + * Update the action of a Message associated to a Subscriber. + * @param request an instance of {@link MarkMessageActionAsSeenRequest} + * @param subscriberId the ID of the Subscriber whose Message action is to be updated + * @param messageId the ID of the Message to be updated + * @param type the type of action to be performed + * @return {@link SubscriberNotificationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SubscriberNotificationResponse markMessageActionAsSeen(final MarkMessageActionAsSeenRequest request, final String subscriberId, final String messageId, final String type) @@ -441,6 +650,13 @@ public SubscriberNotificationResponse markMessageActionAsSeen(final MarkMessageA } } + /** + * Create a Topic. + * @param request an instance of {@link TopicRequest} + * @return {@link TopicResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public TopicResponse createTopic(final TopicRequest request) throws IOException, NovuNetworkException { try { return topicHandler.createTopic(request); @@ -450,6 +666,13 @@ public TopicResponse createTopic(final TopicRequest request) throws IOException, } } + /** + * Retrieve a list of Topics filtered by a Topic key. This function supports pagination. + * @param request an instance of {@link FilterTopicsRequest} + * @return {@link FilterTopicsResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public FilterTopicsResponse filterTopics(final FilterTopicsRequest request) throws IOException, NovuNetworkException { try { @@ -460,6 +683,14 @@ public FilterTopicsResponse filterTopics(final FilterTopicsRequest request) } } + /** + * Add a Subscriber to a Topic. + * @param request an instance of {@link SubscriberAdditionRequest} + * @param topicKey the key of the Topic which the Subscriber should be added to + * @return {@link SubscriberAdditionResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SubscriberAdditionResponse addSubscriberToTopic(final SubscriberAdditionRequest request, final String topicKey) throws IOException, NovuNetworkException { @@ -471,6 +702,14 @@ public SubscriberAdditionResponse addSubscriberToTopic(final SubscriberAdditionR } } + /** + * Check if a Subscriber belongs to a Topic. + * @param topicKey the key of the Topic to be checked + * @param externalSubscriberId the ID of the Subscriber + * @return {@link CheckTopicSubscriberResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public CheckTopicSubscriberResponse checkTopicSubscriber(final String topicKey, final String externalSubscriberId) throws IOException, NovuNetworkException { try { @@ -481,6 +720,14 @@ public CheckTopicSubscriberResponse checkTopicSubscriber(final String topicKey, } } + /** + * Remove a Subscriber from a Topic. + * @param request an instance of {@link SubscriberAdditionRequest} + * @param topicKey the key of the Topic which the Subscriber should be removed from + * @return {@link SubscriberRemovalResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SubscriberRemovalResponse removeSubscriberFromTopic(final SubscriberAdditionRequest request, final String topicKey) throws IOException, NovuNetworkException { @@ -492,6 +739,13 @@ public SubscriberRemovalResponse removeSubscriberFromTopic(final SubscriberAddit } } + /** + * Delete a Topic. + * @param topicKey the key of the Topic to be deleted + * @return {@link DeleteTopicResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public DeleteTopicResponse deleteTopic(final String topicKey) throws IOException, NovuNetworkException { try { return topicHandler.deleteTopic(topicKey); @@ -501,6 +755,13 @@ public DeleteTopicResponse deleteTopic(final String topicKey) throws IOException } } + /** + * Retrieve a Topic. + * @param topicKey the key of the Topic to be retrieved + * @return {@link TopicResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public TopicResponse getTopic(final String topicKey) throws IOException, NovuNetworkException { try { return topicHandler.getTopic(topicKey); @@ -510,6 +771,14 @@ public TopicResponse getTopic(final String topicKey) throws IOException, NovuNet } } + /** + * Rename a Topic. + * @param request an instance of {@link RenameTopicRequest} + * @param topicKey the key of the Topic to be renamed + * @return {@link TopicResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public TopicResponse renameTopic(final RenameTopicRequest request, final String topicKey) throws IOException, NovuNetworkException { try { @@ -520,6 +789,12 @@ public TopicResponse renameTopic(final RenameTopicRequest request, final String } } + /** + * Retrieve a list of Integrations associated with the API key provided. + * @return {@link BulkIntegrationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BulkIntegrationResponse getIntegrations() throws IOException, NovuNetworkException { try { return integrationsHandler.getIntegrations(); @@ -529,6 +804,13 @@ public BulkIntegrationResponse getIntegrations() throws IOException, NovuNetwork } } + /** + * Create an Integration. + * @param request an instance of {@link IntegrationRequest} + * @return {@link SingleIntegrationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleIntegrationResponse createIntegration(final IntegrationRequest request) throws IOException, NovuNetworkException { try { @@ -539,6 +821,12 @@ public SingleIntegrationResponse createIntegration(final IntegrationRequest requ } } + /** + * Retrieve a list of active Integrations associated with the API key provided. + * @return {@link BulkIntegrationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BulkIntegrationResponse getActiveIntegrations() throws IOException, NovuNetworkException { try { return integrationsHandler.getActiveIntegrations(); @@ -548,6 +836,13 @@ public BulkIntegrationResponse getActiveIntegrations() throws IOException, NovuN } } + /** + * Retrieve the status of a Provider's Webhook. + * @param providerId the ID of the Provider whose status is to be retrieved + * @return {@link ProviderWebhookStatusResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public ProviderWebhookStatusResponse getProviderWebhookStatus(final String providerId) throws IOException, NovuNetworkException { try { @@ -558,6 +853,14 @@ public ProviderWebhookStatusResponse getProviderWebhookStatus(final String provi } } + /** + * Update an Integration. + * @param integrationId the ID of the Integration to be updated + * @param request an instance of {@link IntegrationRequest} + * @return {@link SingleIntegrationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleIntegrationResponse updateIntegration(final String integrationId, final IntegrationRequest request) throws IOException, NovuNetworkException { try { @@ -568,6 +871,13 @@ public SingleIntegrationResponse updateIntegration(final String integrationId, f } } + /** + * Delete an Integration. + * @param integrationId the ID of the Integration to be deleted + * @return {@link BulkIntegrationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BulkIntegrationResponse deleteIntegration(final String integrationId) throws IOException, NovuNetworkException { try { @@ -578,6 +888,13 @@ public BulkIntegrationResponse deleteIntegration(final String integrationId) } } + /** + * Set a particular Integration as the primary Integration. + * @param integrationId the ID of the Integration to be set as primary + * @return {@link SingleIntegrationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleIntegrationResponse setIntegrationAsPrimary(final String integrationId) throws IOException, NovuNetworkException { try { @@ -588,6 +905,13 @@ public SingleIntegrationResponse setIntegrationAsPrimary(final String integratio } } + /** + * Create a Layout. + * @param request an instance of {@link LayoutRequest} + * @return {@link CreateLayoutResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public CreateLayoutResponse createLayout(final LayoutRequest request) throws IOException, NovuNetworkException { try { return layoutHandler.createLayout(request); @@ -597,6 +921,13 @@ public CreateLayoutResponse createLayout(final LayoutRequest request) throws IOE } } + /** + * Retrieve a list of Layouts. This function supports pagination. + * @param request an instance of {@link FilterLayoutRequest} + * @return {@link FilterLayoutResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public FilterLayoutResponse filterLayout(final FilterLayoutRequest request) throws IOException, NovuNetworkException { try { @@ -607,15 +938,29 @@ public FilterLayoutResponse filterLayout(final FilterLayoutRequest request) } } + /** + * Retrieve a Layout. + * @param layoutId the ID of the Layout to be retrieved + * @return {@link GetLayoutResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public GetLayoutResponse getLayout(final String layoutId) throws IOException, NovuNetworkException { try { return layoutHandler.getLayout(layoutId); } catch (Exception e) { - logException("Error getting Layouts", e); + logException("Error getting Layout", e); throw e; } } + /** + * Delete a Layout. + * @param layoutId the ID of the Layout to be deleted + * @return {@link DeleteLayoutResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public DeleteLayoutResponse deleteLayout(final String layoutId) throws IOException, NovuNetworkException { try { return layoutHandler.deleteLayout(layoutId); @@ -625,7 +970,15 @@ public DeleteLayoutResponse deleteLayout(final String layoutId) throws IOExcepti } } - public GetLayoutResponse updateIntegration(final String layoutId, final LayoutRequest request) + /** + * Update a Layout. + * @param layoutId the ID of the Layout to be updated + * @param request an instance of {@link LayoutRequest} + * @return {@link GetLayoutResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ + public GetLayoutResponse updateLayout(final String layoutId, final LayoutRequest request) throws IOException, NovuNetworkException { try { return layoutHandler.updateLayout(layoutId, request); @@ -635,6 +988,13 @@ public GetLayoutResponse updateIntegration(final String layoutId, final LayoutRe } } + /** + * Set a Layout as the default Layout. + * @param layoutId the ID of the Layout to be set as default + * @return {@link SetDefaultLayoutResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SetDefaultLayoutResponse setDefaultLayout(final String layoutId) throws IOException, NovuNetworkException { try { return layoutHandler.setDefaultLayout(layoutId); @@ -644,6 +1004,14 @@ public SetDefaultLayoutResponse setDefaultLayout(final String layoutId) throws I } } + /** + * Retrieve a list of Workflows. This function supports pagination. + * @param page the page number to be retrieved + * @param limit the number of items to be retrieved + * @return {@link BulkWorkflowResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BulkWorkflowResponse getWorkflows(final Integer page, final Integer limit) throws IOException, NovuNetworkException { try { @@ -654,6 +1022,13 @@ public BulkWorkflowResponse getWorkflows(final Integer page, final Integer limit } } + /** + * Create a Workflow. + * @param request an instance of {@link WorkflowRequest} + * @return {@link SingleWorkflowResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleWorkflowResponse createWorkflow(final WorkflowRequest request) throws IOException, NovuNetworkException { try { @@ -664,6 +1039,14 @@ public SingleWorkflowResponse createWorkflow(final WorkflowRequest request) } } + /** + * Update a Workflow. + * @param workflowId the ID of the Workflow to be updated + * @param request an instance of {@link UpdateWorkflowRequest} + * @return {@link SingleWorkflowResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleWorkflowResponse updateWorkflow(final String workflowId, final UpdateWorkflowRequest request) throws IOException, NovuNetworkException { try { @@ -674,6 +1057,13 @@ public SingleWorkflowResponse updateWorkflow(final String workflowId, final Upda } } + /** + * Delete a Workflow. + * @param workflowId the ID of the Workflow to be deleted + * @return {@link DeleteWorkflowResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public DeleteWorkflowResponse deleteWorkflow(final String workflowId) throws IOException, NovuNetworkException { try { return workflowHandler.deleteWorkflow(workflowId); @@ -683,6 +1073,13 @@ public DeleteWorkflowResponse deleteWorkflow(final String workflowId) throws IOE } } + /** + * Retrieve a Workflow. + * @param workflowId the ID of the Workflow to be retrieved + * @return {@link SingleWorkflowResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleWorkflowResponse getWorkflow(final String workflowId) throws IOException, NovuNetworkException { try { return workflowHandler.getWorkflow(workflowId); @@ -692,6 +1089,14 @@ public SingleWorkflowResponse getWorkflow(final String workflowId) throws IOExce } } + /** + * Update the status of a Workflow. + * @param workflowId the ID of the Workflow to be updated + * @param request an instance of {@link UpdateWorkflowStatusRequest} + * @return {@link SingleWorkflowResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleWorkflowResponse updateWorkflowStatus(final String workflowId, final UpdateWorkflowStatusRequest request) throws IOException, NovuNetworkException { @@ -703,6 +1108,13 @@ public SingleWorkflowResponse updateWorkflowStatus(final String workflowId, } } + /** + * Create a Workflow group. + * @param request an instance of {@link WorkflowGroupRequest} + * @return {@link WorkflowGroupResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public WorkflowGroupResponse createWorkflowGroup(final WorkflowGroupRequest request) throws IOException, NovuNetworkException { try { @@ -713,6 +1125,12 @@ public WorkflowGroupResponse createWorkflowGroup(final WorkflowGroupRequest requ } } + /** + * Retrieve a list of Workflow groups. + * @return {@link GetWorkflowGroupsResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public GetWorkflowGroupsResponse getWorkflowGroups() throws IOException, NovuNetworkException { try { return workflowGroupHandler.getWorkflowGroups(); @@ -722,6 +1140,13 @@ public GetWorkflowGroupsResponse getWorkflowGroups() throws IOException, NovuNet } } + /** + * Retrieve a Workflow group. + * @param id the ID of the Workflow group to be retrieved + * @return {@link WorkflowGroupResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public WorkflowGroupResponse getWorkflowGroup(final String id) throws IOException, NovuNetworkException { try { return workflowGroupHandler.getWorkflowGroup(id); @@ -731,6 +1156,14 @@ public WorkflowGroupResponse getWorkflowGroup(final String id) throws IOExceptio } } + /** + * Update a Workflow group. + * @param id the ID of the Workflow group to be updated + * @param request an instance of {@link WorkflowGroupRequest} + * @return {@link WorkflowGroupResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public WorkflowGroupResponse updateWorkflowGroup(final String id, final WorkflowGroupRequest request) throws IOException, NovuNetworkException { try { @@ -741,6 +1174,13 @@ public WorkflowGroupResponse updateWorkflowGroup(final String id, final Workflow } } + /** + * Delete a Workflow group. + * @param id the ID of the Workflow group to be deleted + * @return {@link DeleteWorkflowGroup} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public DeleteWorkflowGroup deleteWorkflowGroup(final String id) throws IOException, NovuNetworkException { try { return workflowGroupHandler.deleteWorkflowGroup(id); @@ -750,6 +1190,13 @@ public DeleteWorkflowGroup deleteWorkflowGroup(final String id) throws IOExcepti } } + /** + * Retrieve a list of Changes. This function supports pagination. + * @param request an instance of {@link GetChangesRequest} + * @return {@link GetChangesResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public GetChangesResponse getChanges(final GetChangesRequest request) throws IOException, NovuNetworkException { try { return changeHandler.getChanges(request); @@ -759,6 +1206,12 @@ public GetChangesResponse getChanges(final GetChangesRequest request) throws IOE } } + /** + * Retrieve the count of all available Changes. + * @return {@link ChangeCountResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public ChangeCountResponse getChangesCount() throws IOException, NovuNetworkException { try { return changeHandler.getChangesCount(); @@ -768,6 +1221,13 @@ public ChangeCountResponse getChangesCount() throws IOException, NovuNetworkExce } } + /** + * Apply a list of Changes. + * @param request an instance of {@link ApplyChangesRequest} + * @return {@link ApplyChangesResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public ApplyChangesResponse applyChanges(final ApplyChangesRequest request) throws IOException, NovuNetworkException { try { @@ -778,6 +1238,13 @@ public ApplyChangesResponse applyChanges(final ApplyChangesRequest request) } } + /** + * Apply a particular Change. + * @param changeId the ID of the Change to be applied + * @return {@link ApplyChangesResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public ApplyChangesResponse applyChange(final String changeId) throws IOException, NovuNetworkException { try { return changeHandler.applyChange(changeId); @@ -787,6 +1254,12 @@ public ApplyChangesResponse applyChange(final String changeId) throws IOExceptio } } + /** + * Retrieve the data of the current Environment. + * @return {@link SingleEnvironmentResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleEnvironmentResponse getCurrentEnvironment() throws IOException, NovuNetworkException { try { return environmentHandler.getCurrentEnvironment(); @@ -796,6 +1269,13 @@ public SingleEnvironmentResponse getCurrentEnvironment() throws IOException, Nov } } + /** + * Create an Environment. + * @param request an instance of {@link CreateEnvironmentRequest} + * @return {@link SingleEnvironmentResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleEnvironmentResponse createEnvironment(final CreateEnvironmentRequest request) throws IOException, NovuNetworkException { try { @@ -806,6 +1286,12 @@ public SingleEnvironmentResponse createEnvironment(final CreateEnvironmentReques } } + /** + * Retrieve a list of Environments. + * @return {@link BulkEnvironmentResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BulkEnvironmentResponse getEnvironments() throws IOException, NovuNetworkException { try { return environmentHandler.getEnvironments(); @@ -815,6 +1301,14 @@ public BulkEnvironmentResponse getEnvironments() throws IOException, NovuNetwork } } + /** + * Update an Environment. + * @param environmentId the ID of the Environment to be updated + * @param request an instance of {@link UpdateEnvironmentRequest} + * @return {@link SingleEnvironmentResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public SingleEnvironmentResponse updateEnvironmentById(final String environmentId, final UpdateEnvironmentRequest request) throws IOException, NovuNetworkException { @@ -826,6 +1320,12 @@ public SingleEnvironmentResponse updateEnvironmentById(final String environmentI } } + /** + * Retrieve a list of API Keys. + * @return {@link ApiKeyResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public ApiKeyResponse getApiKeys() throws IOException, NovuNetworkException { try { return environmentHandler.getApiKeys(); @@ -835,6 +1335,12 @@ public ApiKeyResponse getApiKeys() throws IOException, NovuNetworkException { } } + /** + * Regenerate API Keys. + * @return {@link ApiKeyResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public ApiKeyResponse regenerateApiKeys() throws IOException, NovuNetworkException { try { return environmentHandler.regenerateApiKeys(); @@ -844,6 +1350,12 @@ public ApiKeyResponse regenerateApiKeys() throws IOException, NovuNetworkExcepti } } + /** + * Validate the mx record setup for the inbound parse functionality. + * @return {@link ValidateMxRecordResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public ValidateMxRecordResponse validateMxRecordSetupForInboundParse() throws IOException, NovuNetworkException { try { return inboundParseHandler.validateMxRecordSetupForInboundParse(); @@ -853,6 +1365,13 @@ public ValidateMxRecordResponse validateMxRecordSetupForInboundParse() throws IO } } + /** + * Create a Feed. + * @param request an instance of {@link FeedRequest} + * @return {@link FeedResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public FeedResponse createFeed(final FeedRequest request) throws IOException, NovuNetworkException { try { return feedsHandler.createFeed(request); @@ -862,6 +1381,12 @@ public FeedResponse createFeed(final FeedRequest request) throws IOException, No } } + /** + * Retrieve a list of Feeds. + * @return {@link BulkFeedsResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BulkFeedsResponse getFeeds() throws IOException, NovuNetworkException { try { return feedsHandler.getFeeds(); @@ -871,6 +1396,13 @@ public BulkFeedsResponse getFeeds() throws IOException, NovuNetworkException { } } + /** + * Delete a Feed. + * @param feedId the ID of the Feed to be deleted + * @return {@link BulkFeedsResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BulkFeedsResponse deleteFeed(final String feedId) throws IOException, NovuNetworkException { try { return feedsHandler.deleteFeed(feedId); @@ -880,6 +1412,13 @@ public BulkFeedsResponse deleteFeed(final String feedId) throws IOException, Nov } } + /** + * Retrieve a list of Messages. This function supports pagination. + * @param request an instance of {@link MessageRequest} + * @return {@link MessageResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public MessageResponse getMessages(final MessageRequest request) throws IOException, NovuNetworkException { try { return messageHandler.getMessages(request); @@ -889,6 +1428,13 @@ public MessageResponse getMessages(final MessageRequest request) throws IOExcept } } + /** + * Delete a Message. + * @param messageId the ID of the Message to be deleted + * @return {@link DeleteMessageResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public DeleteMessageResponse deleteMessage(final String messageId) throws IOException, NovuNetworkException { try { return messageHandler.deleteMessage(messageId); @@ -898,6 +1444,14 @@ public DeleteMessageResponse deleteMessage(final String messageId) throws IOExce } } + /** + * Retrieve a list of Execution Details. + * @param notificationId the ID of a Notification + * @param subscriberId the ID of a Subscriber + * @return {@link ExecutiveDetailsResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public ExecutiveDetailsResponse getExecutionDetails(final String notificationId, final String subscriberId) throws IOException, NovuNetworkException { try { @@ -908,6 +1462,12 @@ public ExecutiveDetailsResponse getExecutionDetails(final String notificationId, } } + /** + * Retrieve a list of Blueprints grouped by Category. + * @return {@link BlueprintsByCategoryResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BlueprintsByCategoryResponse getBlueprintsByCategory() throws IOException, NovuNetworkException { try { return blueprintsHandler.getBlueprintsByCategory(); @@ -917,6 +1477,13 @@ public BlueprintsByCategoryResponse getBlueprintsByCategory() throws IOException } } + /** + * Retrieve a Blueprint. + * @param templateId the ID of a Template + * @return {@link Blueprint} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public Blueprint getBlueprint(final String templateId) throws IOException, NovuNetworkException { try { return blueprintsHandler.getBlueprint(templateId); @@ -926,6 +1493,13 @@ public Blueprint getBlueprint(final String templateId) throws IOException, NovuN } } + /** + * Retrieve a list of Tenants. This function supports pagination. + * @param request an instance of {@link GetTenantRequest} + * @return {@link BulkTenantResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BulkTenantResponse getTenants(final GetTenantRequest request) throws IOException, NovuNetworkException { try { return tenantsHandler.getTenants(request); @@ -935,6 +1509,13 @@ public BulkTenantResponse getTenants(final GetTenantRequest request) throws IOEx } } + /** + * Create a Tenant. + * @param request an instance of {@link TenantRequest} + * @return {@link TenantResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public TenantResponse createTenant(final TenantRequest request) throws IOException, NovuNetworkException { try { return tenantsHandler.createTenant(request); @@ -944,6 +1525,13 @@ public TenantResponse createTenant(final TenantRequest request) throws IOExcepti } } + /** + * Retrieve a Tenant. + * @param identifier the ID of the Tenant to be retrieved + * @return {@link TenantResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public TenantResponse getTenant(final String identifier) throws IOException, NovuNetworkException { try { return tenantsHandler.getTenant(identifier); @@ -953,6 +1541,14 @@ public TenantResponse getTenant(final String identifier) throws IOException, Nov } } + /** + * Update a Tenant. + * @param request an instance of {@link TenantRequest} + * @param identifier the ID of the Tenant to be updated + * @return {@link TenantResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public TenantResponse updateTenant(final TenantRequest request, final String identifier) throws IOException, NovuNetworkException { try { @@ -963,6 +1559,13 @@ public TenantResponse updateTenant(final TenantRequest request, final String ide } } + /** + * Delete a Tenant. + * @param identifier the ID of the Tenant to be deleted + * @return {@link DeleteTenantResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public DeleteTenantResponse deleteTenant(final String identifier) throws IOException, NovuNetworkException { try { return tenantsHandler.deleteTenant(identifier); @@ -972,6 +1575,13 @@ public DeleteTenantResponse deleteTenant(final String identifier) throws IOExcep } } + /** + * Create an Organization. + * @param request an instance of {@link CreateOrganizationRequest} + * @return {@link OrganizationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public OrganizationResponse createOrganization(final CreateOrganizationRequest request) throws IOException, NovuNetworkException { try { @@ -982,6 +1592,12 @@ public OrganizationResponse createOrganization(final CreateOrganizationRequest r } } + /** + * Retrieve a list of all Organizations. + * @return {@link FetchOrganizationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public FetchOrganizationResponse fetchAllOrganizations() throws IOException, NovuNetworkException { try { return organizationHandler.fetchAllOrganizations(); @@ -991,6 +1607,13 @@ public FetchOrganizationResponse fetchAllOrganizations() throws IOException, Nov } } + /** + * Update the name of an Organization. + * @param request an instance of {@link UpdateOrganizationNameRequest} + * @return {@link UpdateOrganizationNameResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public UpdateOrganizationNameResponse updateOrganizationName(final UpdateOrganizationNameRequest request) throws IOException, NovuNetworkException { try { @@ -1001,6 +1624,12 @@ public UpdateOrganizationNameResponse updateOrganizationName(final UpdateOrganiz } } + /** + * Retrieve the data of the current Organization. + * @return {@link OrganizationResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public OrganizationResponse fetchCurrentOrganization() throws IOException, NovuNetworkException { try { return organizationHandler.fetchCurrentOrganization(); @@ -1010,6 +1639,13 @@ public OrganizationResponse fetchCurrentOrganization() throws IOException, NovuN } } + /** + * Remove a Member from the current Organization. + * @param memberId the ID of the Member to be removed + * @return {@link MemberResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public MemberResponse removeMemberWithId(final String memberId) throws IOException, NovuNetworkException { try { return organizationHandler.removeMemberWithId(memberId); @@ -1019,6 +1655,14 @@ public MemberResponse removeMemberWithId(final String memberId) throws IOExcepti } } + /** + * Update a Member's role in the current Organization. + * @param memberId the ID of the Member to be updated + * @param request an instance of {@link UpdateMemberRoleRequest} + * @return {@link MemberResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public MemberResponse updateMemberRole(final String memberId, final UpdateMemberRoleRequest request) throws IOException, NovuNetworkException { try { @@ -1029,6 +1673,12 @@ public MemberResponse updateMemberRole(final String memberId, final UpdateMember } } + /** + * Retrieve a list of all Members in the current Organizations. + * @return {@link FetchMembersResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public FetchMembersResponse fetchMembersOfOrganization() throws IOException, NovuNetworkException { try { return organizationHandler.fetchMembersOfOrganization(); @@ -1038,6 +1688,13 @@ public FetchMembersResponse fetchMembersOfOrganization() throws IOException, Nov } } + /** + * Update the brand of the current Organization. + * @param request an instance of {@link UpdateOrganizationBrandRequest} + * @return {@link UpdateOrganizationBrandResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public UpdateOrganizationBrandResponse updateOrganizationBrand(final UpdateOrganizationBrandRequest request) throws IOException, NovuNetworkException { try { @@ -1048,6 +1705,13 @@ public UpdateOrganizationBrandResponse updateOrganizationBrand(final UpdateOrgan } } + /** + * Create a Workflow override. + * @param request an instance of {@link CreateWorkflowOverrideRequest} + * @return {@link WorkflowOverrideResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public WorkflowOverrideResponse createWorkflowOverride(final CreateWorkflowOverrideRequest request) throws IOException, NovuNetworkException { try { @@ -1058,6 +1722,13 @@ public WorkflowOverrideResponse createWorkflowOverride(final CreateWorkflowOverr } } + /** + * Retrieve a list of Workflow overrides. This function supports pagination. + * @param request an instance of {@link GetWorkflowOverrideRequest} + * @return {@link BulkWorkflowOverridesResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public BulkWorkflowOverridesResponse getWorkflowOverrides(final GetWorkflowOverrideRequest request) throws IOException, NovuNetworkException { try { @@ -1068,6 +1739,14 @@ public BulkWorkflowOverridesResponse getWorkflowOverrides(final GetWorkflowOverr } } + /** + * Retrieve a Workflow override associated with a Tenant. + * @param workflowId the ID of the Workflow override to be retrieved + * @param tenantId the ID of the Tenant + * @return {@link WorkflowOverrideResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public WorkflowOverrideResponse getWorkflowOverride(final String workflowId, final String tenantId) throws IOException, NovuNetworkException { try { @@ -1078,6 +1757,13 @@ public WorkflowOverrideResponse getWorkflowOverride(final String workflowId, fin } } + /** + * Retrieve a Workflow override. + * @param overrideId the ID of the Workflow override to be retrieved + * @return {@link WorkflowOverrideResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public WorkflowOverrideResponse getWorkflowOverrideById(final String overrideId) throws IOException, NovuNetworkException { try { @@ -1088,6 +1774,14 @@ public WorkflowOverrideResponse getWorkflowOverrideById(final String overrideId) } } + /** + * Update a Workflow override. + * @param overrideId the ID of the Workflow override to be updated + * @param request an instance of {@link UpdateWorkflowOverrideRequest} + * @return {@link WorkflowOverrideResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public WorkflowOverrideResponse updateWorkflowOverrideById(final String overrideId, final UpdateWorkflowOverrideRequest request) throws IOException, NovuNetworkException { @@ -1099,6 +1793,15 @@ public WorkflowOverrideResponse updateWorkflowOverrideById(final String override } } + /** + * Update a Workflow override associated with a Tenant. + * @param workflowId the ID of the Workflow override to be updated + * @param tenantId the ID of the Tenant + * @param request an instance of {@link UpdateWorkflowOverrideRequest} + * @return {@link WorkflowOverrideResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public WorkflowOverrideResponse updateWorkflowOverride(final String workflowId, final String tenantId, final UpdateWorkflowOverrideRequest request) throws IOException, NovuNetworkException { @@ -1110,6 +1813,13 @@ public WorkflowOverrideResponse updateWorkflowOverride(final String workflowId, } } + /** + * Delete a Workflow override. + * @param overrideId the ID of the Workflow override to be deleted + * @return {@link DeleteWorkflowOverrideResponse} + * @throws IOException if a problem occurred talking to the server + * @throws NovuNetworkException if there is a connection error + */ public DeleteWorkflowOverrideResponse deleteWorkflowOverride(final String overrideId) throws IOException, NovuNetworkException { try { diff --git a/src/main/java/co/novu/common/base/NovuConfig.java b/src/main/java/co/novu/common/base/NovuConfig.java index 1a7f4f9..989da9e 100644 --- a/src/main/java/co/novu/common/base/NovuConfig.java +++ b/src/main/java/co/novu/common/base/NovuConfig.java @@ -3,9 +3,18 @@ import lombok.Data; import okhttp3.logging.HttpLoggingInterceptor; +/** + * A set of configurations used to construct Novu, these configurations ultimately control the way the SDK behaves. + * + * @author Joseph Olugbohunmi link + */ @Data public class NovuConfig { + /** + * Main constructor for initialising this class. + * @param novuApiKey API Key gotten from Settings + */ public NovuConfig(final String novuApiKey) { this.apiKey = novuApiKey; } diff --git a/src/test/java/co/novu/api/events/EventsHandlerTest.java b/src/test/java/co/novu/api/events/EventsHandlerTest.java index 8949f50..c5e4858 100644 --- a/src/test/java/co/novu/api/events/EventsHandlerTest.java +++ b/src/test/java/co/novu/api/events/EventsHandlerTest.java @@ -175,7 +175,7 @@ public void test_broadcastEventToSubscriber() throws IOException, NovuNetworkExc Gson gson = new Gson(); mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(gson.toJson(triggerEventResponse))); - TriggerEventResponse response = eventsHandler.broadcastEvent(new TriggerEventRequest()); + TriggerEventResponse response = eventsHandler.broadcastEvent(triggerEventRequest); RecordedRequest request = mockWebServer.takeRequest(); assertEquals("/events/trigger/broadcast", request.getPath()); diff --git a/src/test/java/co/novu/api/subscribers/SubscribersHandlerTest.java b/src/test/java/co/novu/api/subscribers/SubscribersHandlerTest.java index ea4a05b..40c11fa 100644 --- a/src/test/java/co/novu/api/subscribers/SubscribersHandlerTest.java +++ b/src/test/java/co/novu/api/subscribers/SubscribersHandlerTest.java @@ -381,7 +381,7 @@ public void test_markMessageActionAsSeen() throws IOException, NovuNetworkExcept mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(gson.toJson(notificationResponse))); - SubscriberNotificationResponse response = subscribersHandler.markMessageActionAsSeen(new MarkMessageActionAsSeenRequest(), "sId", "mId", "type"); + SubscriberNotificationResponse response = subscribersHandler.markMessageActionAsSeen(request, "sId", "mId", "type"); assertNotNull(response); final RecordedRequest recordedRequest = mockWebServer.takeRequest(); assertEquals("/subscribers/sId/messages/mId/actions/type", recordedRequest.getPath());