Passed
Pull Request — master (#27)
by
unknown
01:13
created

nextcloud.api_wrappers.notifications   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 13
dl 0
loc 43
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A Notifications.get_notifications() 0 3 1
A Notifications.delete_all_notifications() 0 7 1
A Notifications.delete_notification() 0 11 1
A Notifications.get_notification() 0 11 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
    SUCCESS_CODE = 200
7
8
    def get_notifications(self):
9
        """ Get list of notifications for a logged in user """
10
        return self.requester.get()
11
12
    def get_notification(self, notification_id):
13
        """
14
        Get single notification by id for a user
15
16
        Args:
17
            notification_id (int): Notification id
18
19
        Returns:
20
21
        """
22
        return self.requester.get(url=notification_id)
23
24
    def delete_notification(self, notification_id):
25
        """
26
        Delete single notification by id for a user
27
28
        Args:
29
            notification_id (int): Notification id
30
31
        Returns:
32
33
        """
34
        return self.requester.delete(url=notification_id)
35
36
    def delete_all_notifications(self):
37
        """ Delete all notification for a logged in user
38
39
        Notes:
40
            This endpoint was added for Nextcloud 14
41
        """
42
        return self.requester.delete()
43