Completed
Push — master ( a9b8b6...971575 )
by Matěj
12s
created

Activity.get_activities()   A

Complexity

Conditions 3

Size

Total Lines 26
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 26
rs 9.9
c 0
b 0
f 0
cc 3
nop 6
1
from nextcloud.base import WithRequester
2
3
4
class Activity(WithRequester):
5
    API_URL = "/ocs/v2.php/apps/activity/api/v2/activity"
6
    SUCCESS_CODE = 200
7
8
    def get_activities(self, since=None, limit=None, object_type=None, object_id=None, sort=None):
9
        """
10
        Get an activity feed showing your file changes and other interesting things going on in your Nextcloud
11
12
        All args are optional
13
14
        Args:
15
            since (int): ID of the last activity that you’ve seen
16
            limit (int): How many activities should be returned (default: 50)
17
            object_type (string): Filter the activities to a given object. May only appear together with object_id
18
            object_id (string): Filter the activities to a given object. May only appear together with object_type
19
            sort (str, "asc" or "desc"): Sort activities ascending or descending (from the since) (Default: desc)
20
21
        Returns:
22
23
        """
24
        params = dict(
25
            since=since,
26
            limit=limit,
27
            object_type=object_type,
28
            object_id=object_id,
29
            sort=sort
30
        )
31
        if params['object_type'] and params['object_id']:
32
            return self.requester.get(url="filter", params=params)
33
        return self.requester.get(params=params)
34