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