1
+ <?php
2
+
3
+ namespace Novu \SDK \Actions ;
4
+
5
+ use Novu \SDK \Resources \Notification ;
6
+ use Novu \SDK \Resources \NotificationStats ;
7
+ use Novu \SDK \Resources \NotificationGraphStats ;
8
+
9
+ trait ManagesNotifications
10
+ {
11
+
12
+ /**
13
+ * Get A Notification
14
+ *
15
+ * @param string $notificationId
16
+ * @return \Novu\SDK\Resources\Notification
17
+ */
18
+ public function getNotification ($ notificationId )
19
+ {
20
+ $ response = $ this ->get ("notifications/ {$ notificationId }" )['data ' ];
21
+
22
+ return new Notification ($ response , $ this );
23
+ }
24
+
25
+ /**
26
+ * Get All Notifications
27
+ * @param array $queryParams
28
+ * @return \Novu\SDK\Resources\Notification
29
+ */
30
+ public function getNotifications (array $ queryParams = [])
31
+ {
32
+ $ uri = "notifications " ;
33
+
34
+ if (! empty ($ queryParams )) {
35
+ $ uri .= '? ' . http_build_query ($ queryParams );
36
+ }
37
+
38
+ $ response = $ this ->get ($ uri );
39
+
40
+ return new Notification ($ response , $ this );
41
+ }
42
+
43
+ /**
44
+ * Get Notification Statistics
45
+ *
46
+ * @return \Novu\SDK\Resources\NotificationStats
47
+ */
48
+ public function getNotificationStats ()
49
+ {
50
+ $ response = $ this ->get ("notifications/stats " )['data ' ];
51
+
52
+ return new NotificationStats ($ response , $ this );
53
+ }
54
+
55
+ /**
56
+ * Get Notification Graph Stats
57
+ * @param array $queryParams
58
+ * @return \Novu\SDK\Resources\NotificationGraphStats
59
+ */
60
+ public function getNotificationGraphStats (array $ queryParams = [])
61
+ {
62
+ $ uri = "notifications/graph/stats " ;
63
+
64
+ if (! empty ($ queryParams )) {
65
+ $ uri .= '? ' . http_build_query ($ queryParams );
66
+ }
67
+
68
+ $ response = $ this ->get ($ uri )['data ' ];
69
+
70
+ return new NotificationGraphStats ($ response , $ this );
71
+ }
72
+
73
+ }
0 commit comments