Completed
Push — master ( e847a5...5b0cc0 )
by Matěj
25s queued 10s
created

NextCloud.api_wrappers.notifications   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A Notifications.delete_notification() 0 11 1
A Notifications.get_notifications() 0 3 1
A Notifications.get_notification() 0 11 1
A Notifications.delete_all_notifications() 0 7 1
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