| Total Complexity | 4 |
| Total Lines | 43 |
| 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 | 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 |