| Total Complexity | 4 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |