Skip to content

Commit 3f00892

Browse files
feat(api): Add query params to Notification graph stats, and notifications
1 parent 882e0d5 commit 3f00892

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/Actions/ManagesNotifications.php

+19-7
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,25 @@ trait ManagesNotifications
1717
*/
1818
public function getNotification($notificationId)
1919
{
20-
$response = $this->get("notifications/{$notificationId}");
20+
$response = $this->get("notifications/{$notificationId}")['data'];
2121

2222
return new Notification($response, $this);
2323
}
2424

2525
/**
2626
* Get All Notifications
27-
*
27+
* @param array $queryParams
2828
* @return \Novu\SDK\Resources\Notification
2929
*/
30-
public function getNotifications()
30+
public function getNotifications(array $queryParams = [])
3131
{
32-
$response = $this->get("notifications")['data'];
32+
$uri = "notifications";
33+
34+
if(! empty($queryParams)) {
35+
$uri .= '?' . http_build_query($queryParams);
36+
}
37+
38+
$response = $this->get($uri);
3339

3440
return new Notification($response, $this);
3541
}
@@ -48,13 +54,19 @@ public function getNotificationStats()
4854

4955
/**
5056
* Get Notification Graph Stats
51-
*
57+
* @param array $queryParams
5258
* @return \Novu\SDK\Resources\NotificationGraphStats
5359
*/
54-
public function getNotificationGraphStats()
60+
public function getNotificationGraphStats(array $queryParams = [])
5561
{
56-
$response = $this->get("notifications/graph/stats")['data'];
62+
$uri = "notifications/graph/stats";
63+
64+
if(! empty($queryParams)) {
65+
$uri .= '?' . http_build_query($queryParams);
66+
}
5767

68+
$response = $this->get($uri)['data'];
69+
5870
return new NotificationGraphStats($response, $this);
5971
}
6072

0 commit comments

Comments
 (0)