From 294c399e5b260313a2d49a0fed1516116a23fbd5 Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Fri, 1 Jun 2018 10:43:16 -0300 Subject: update api to support notificators --- .../traccar/api/resource/NotificationResource.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/api/resource/NotificationResource.java b/src/org/traccar/api/resource/NotificationResource.java index 830e34fc0..2347b43fa 100644 --- a/src/org/traccar/api/resource/NotificationResource.java +++ b/src/org/traccar/api/resource/NotificationResource.java @@ -21,6 +21,7 @@ import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -51,9 +52,25 @@ public class NotificationResource extends ExtendedObjectResource { @POST @Path("test") public Response testMessage() throws NotificationException, InterruptedException { - Context.getNotificatorManager().getMail().sendSync(getUserId(), new Event("test", 0), null); - Context.getNotificatorManager().getSms().sendSync(getUserId(), new Event("test", 0), null); + for (String method : Context.getNotificatorManager().getNotificatorTypes()) { + Context.getNotificatorManager().getNotificator(method).sendSync(getUserId(), new Event("test", 0), null); + } return Response.noContent().build(); } + @POST + @Path("test/{method}") + public Response testMessage(@PathParam("method") String method) throws NotificationException, InterruptedException { + Context.getNotificatorManager().getNotificator(method).sendSync(getUserId(), new Event("test", 0), null); + return Response.noContent().build(); + } + + + @GET + @Path("notificators") + public Collection getNotificators() { + return Context.getNotificatorManager().getNotificatorTypes(); + } + + } -- cgit v1.2.3