nextcloud.api_wrappers.notifications   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

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