-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from novuhq/feat-missing-fields
Add Missing Request fields and Delete properties file
- Loading branch information
Showing
4 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
52 changes: 50 additions & 2 deletions
52
src/main/java/co/novu/api/events/requests/TriggerEventRequest.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 |
---|---|---|
@@ -1,16 +1,64 @@ | ||
package co.novu.api.events.requests; | ||
|
||
import co.novu.api.common.SubscriberRequest; | ||
import co.novu.api.tenants.pojos.Tenant; | ||
import co.novu.common.contracts.IRequest; | ||
import lombok.Data; | ||
|
||
import java.util.Map; | ||
|
||
|
||
@Data | ||
public class TriggerEventRequest implements IRequest { | ||
private String name; | ||
private Object to;// Possible types this field accepts are; SubscriberRequest, List<SubscriberRequest>, Topic or List<Topic> | ||
|
||
/** | ||
* Possible types this field accepts are; {@link SubscriberRequest}, list of {@link SubscriberRequest}, {@link Topic} or list of {@link Topic} | ||
* | ||
* <p>For example: | ||
* | ||
* <pre><code> | ||
* SubscriberRequest subscriberRequest = new SubscriberRequest(); | ||
* subscriberRequest.setFirstName("fName"); | ||
* subscriberRequest.setLastName("lName"); | ||
* subscriberRequest.setEmail("[email protected]"); | ||
* subscriberRequest.setSubscriberId("subId"); | ||
* </code></pre> | ||
*/ | ||
private Object to; | ||
private Map<String, Object> payload; | ||
private Map<String, Object> overrides; | ||
private String transactionId; | ||
|
||
/** | ||
* Possible types this field accepts are; String or {@link Map} | ||
* | ||
* <p>For example: | ||
* | ||
* <pre><code> | ||
* Map<String, Object> actorMap = new HashMap<>(); | ||
* actorMap.put("subscriberId", "sId"); | ||
* actorMap.put("email", "[email protected]"); | ||
* actorMap.put("firstName", "fName"); | ||
* actorMap.put("lastName", "lName"); | ||
* actorMap.put("phone", "phoneNo"); | ||
* actorMap.put("avatar", "avatarUrl"); | ||
* actorMap.put("locale", "locale"); | ||
* actorMap.put("data", new Object()); | ||
* </code></pre> | ||
*/ | ||
private Object actor; | ||
|
||
/** | ||
* Possible types this field accepts are; String or {@link Tenant} | ||
* | ||
* <p>For example: | ||
* | ||
* <pre><code> | ||
* Tenant tenant = new Tenant(); | ||
* tenant.setIdentifier("identifier"); | ||
* tenant.setName("name"); | ||
* tenant.setData(new Object()); | ||
* </code></pre> | ||
*/ | ||
private Object tenant; | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import co.novu.api.events.responses.CancelEventResponse; | ||
import co.novu.api.events.responses.TriggerEventResponse; | ||
import co.novu.api.events.responses.TriggerEventResponseData; | ||
import co.novu.api.tenants.pojos.Tenant; | ||
import co.novu.common.base.NovuConfig; | ||
import co.novu.common.rest.NovuNetworkException; | ||
import co.novu.common.rest.RestHandler; | ||
|
@@ -16,10 +17,11 @@ | |
import okhttp3.mockwebserver.MockResponse; | ||
import okhttp3.mockwebserver.MockWebServer; | ||
import okhttp3.mockwebserver.RecordedRequest; | ||
import org.mockito.Mockito; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class EventsHandlerTest extends TestCase { | ||
|
||
|
@@ -47,6 +49,8 @@ public void test_triggerEventToSubscriber() throws IOException, NovuNetworkExcep | |
|
||
triggerEventRequest.setTo(subscriberRequest); | ||
triggerEventRequest.setPayload(Collections.singletonMap("customVariables", "Hello")); | ||
triggerEventRequest.setActor("actor"); | ||
triggerEventRequest.setTenant("tenant"); | ||
|
||
TriggerEventResponse triggerEventResponse = new TriggerEventResponse(); | ||
TriggerEventResponseData data = new TriggerEventResponseData(); | ||
|
@@ -77,6 +81,23 @@ public void test_triggerEventToTopic() throws IOException, NovuNetworkException, | |
triggerEventRequest.setTo(topic); | ||
triggerEventRequest.setPayload(Collections.singletonMap("customVariables", "Hello")); | ||
|
||
Map<String, Object> actorMap = new HashMap<>(); | ||
actorMap.put("subscriberId", "sId"); | ||
actorMap.put("email", "[email protected]"); | ||
actorMap.put("firstName", "fName"); | ||
actorMap.put("lastName", "lName"); | ||
actorMap.put("phone", "phoneNo"); | ||
actorMap.put("avatar", "avatarUrl"); | ||
actorMap.put("locale", "locale"); | ||
actorMap.put("data", new Object()); | ||
triggerEventRequest.setActor(actorMap); | ||
|
||
Tenant tenant = new Tenant(); | ||
tenant.setIdentifier("identifier"); | ||
tenant.setName("name"); | ||
tenant.setData(new Object()); | ||
triggerEventRequest.setTenant(tenant); | ||
|
||
TriggerEventResponse triggerEventResponse = new TriggerEventResponse(); | ||
TriggerEventResponseData data = new TriggerEventResponseData(); | ||
data.setAcknowledged(true); | ||
|
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