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