Passed
Pull Request — master (#19)
by
unknown
01:06
created

Notifications.get_notifications()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
from NextCloud.base import WithRequester
2
3
4
class Notifications(WithRequester):
5
    API_URL = "/ocs/v2.php/apps/notifications/api/v2/notifications"
6
7
    def get_notifications(self):
8
        """ Get list of notifications for a logged in user """
9
        return self.requester.get()
10
11
    def get_notification(self, notification_id):
12
        """
13
        Get single notification by id for a user
14
15
        Args:
16
            notification_id (int): Notification id
17
18
        Returns:
19
20
        """
21
        return self.requester.get(url=notification_id)
22
23
    def delete_notification(self, notification_id):
24
        """
25
        Delete single notification by id for a user
26
27
        Args:
28
            notification_id (int): Notification id
29
30
        Returns:
31
32
        """
33
        return self.requester.delete(url=notification_id)
34
35
    def delete_all_notifications(self):
36
        """ Delete all notification for a logged in user
37
38
        Notes:
39
            This endpoint was added for Nextcloud 14
40
        """
41
        return self.requester.delete()
42