Skip to content

Commit

Permalink
Merge pull request #123 from novuhq/feat-missing-fields
Browse files Browse the repository at this point in the history
Add Missing Request fields and Delete properties file
  • Loading branch information
Cliftonz authored Apr 29, 2024
2 parents 23f34fb + 6dfdeef commit a51c5cb
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 5 deletions.
52 changes: 50 additions & 2 deletions src/main/java/co/novu/api/events/requests/TriggerEventRequest.java
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&lt;String, Object&gt; 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;
}
1 change: 0 additions & 1 deletion src/main/resources/application.properties

This file was deleted.

23 changes: 22 additions & 1 deletion src/test/java/co/novu/api/events/EventsHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion techstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ tools:
category: Application Hosting
sub_category: Platform as a Service
image_url: https://img.stackshare.io/service/3276/xWt1RFo6_400x400.jpg
detection_source: src/main/resources/application.properties
last_updated_by: Mukhtar
last_updated_on: 2023-06-25 20:22:10.000000000 Z
- name: com.squareup.okhttp3:logging-interceptor
Expand Down

0 comments on commit a51c5cb

Please sign in to comment.