Activity

class moco_wrapper.models.Activity(moco)

Class for handling activities.

Activities are always created for a project task. The order of things is Project>Task>Activity. An activity always belongs to a task and that task always belongs to a project.

Example Usage:

from moco_wrapper import Moco

m = Moco()
project_id = 2
task_id = 3

#log time
created_activity = m.Activity.create(
    datetime.date(2020, 1, 1),
    project_id,
    task_id,
    0.25
    description="did things"
)
create(activity_date: datetime.date, project_id: int, task_id: int, hours: float, description: str = None, billable: bool = None, tag: str = None, remote_service: str = None, remote_id: int = None, remote_url: str = None)

Create an activity.

Parameters:
  • activity_date (datetime.date, str) – date of the activity
  • project_id (int) – id of the project this activity belongs to
  • task_id (int) – id of the task this activity belongs to (see project tasks)
  • hours (float) – hours to log to the activity (passing a 0 will start a timer if the date is today)
  • description (str) – activity description text
  • billable (bool) – true/false (if this activity is billable) (select none if billing is dependent on project configuration)
  • tag (str) – a tag string
  • remote_service (ActivityRemoteService, str) – if this task was created by a remote service, its name will be here.
  • remote_id (str) – id of the activity in the remote_service
  • remote_url (str) – address of the remote service
Returns:

the created activity

delete(activity_id: int)

Delete an activity.

Parameters:activity_id (int) – Id of the activity to delete
Returns:empty response on success
disregard(reason, activity_ids, company_id, project_id=None)

Disregard activities.

Parameters:
  • reason (str) – Reason text for disregarding these activities
  • activity_ids (list) – List of activity ids to disregard
  • company_id (int) – Company id these activities belong to
  • project_id (int) – Project id these activities belong to
Returns:

List with the activity ids that were disregarded

get(activity_id: int)

Get a single activity.

Parameters:activity_id (int) – Id of the activity:
Returns:The activity object
getlist(from_date: datetime.date, to_date: datetime.date, user_id: int = None, project_id: int = None, task_id: int = None, sort_by: str = None, sort_order: str = 'asc', page: int = 1)

Get a list of activity objects.

Parameters:
  • from_date (datetime.date, str) – Start date
  • to_date (datetime.date, str) – End date
  • user_id (int) – User id of the creator
  • project_id (int) – Id of the project the activity belongs to
  • task_id (int) – Id of the task the activity belongs t
  • sort_by (str) – Field to sort results by
  • sort_order (str) – asc or desc
  • page (int) – Page number (default 1)
Returns:

List of activities

start_timer(activity_id: int)

Start a timer on the specified activity.

The timer can only be started for activities on the current day.

Parameters:activity_id (int) – id of the activity
Returns:the activity the timer was started for
stop_timer(activity_id: int)

Stop a timer on the specified activity.

Parameters:activity_id (int) – Id of the activity
Returns:the activity the timer was stopped for
update(activity_id: int, activity_date: datetime.date = None, project_id: int = None, task_id: int = None, hours: float = None, description: str = None, billable: bool = None, tag: str = None, remote_service: str = None, remote_id: int = None, remote_url: str = None)

Create an activity.

Parameters:
  • activity_id (int) – id of the activity
  • activity_date (datetime.date, str) – date of the activity
  • project_id (int) – id of the project this activity belongs to
  • task_id (int) – id of the task this activity belongs to (see project tasks)
  • hours (float) – hours to log to the activity (passing a 0 will start a timer if the date is today)
  • description (str) – activity description text
  • billable (bool) – true/false (if this activity is billable) (select none if billing is dependent on project configuration)
  • tag (str) – a tag string
  • remote_service (ActivityRemoteService, str) – if this task was created by a remote service, its name will be here
  • remote_id (str) – id of the activity in the remote_service
  • remote_url (str) – address of the remote service
Returns:

the updated activity

class moco_wrapper.models.activity.ActivityRemoteService

Enumeration for allowed values used that can be supplied for the remote_service argument in Activity.create() and Activity.update()

from moco_wrapper import Moco
from moco_wrapper.models.activity import ActivityRemoteService

m = Moco()
activity_create = m.Activity.create(
    ..
    remote_service = ActivityRemoteService.TRELLO
)
ASANA = 'asana'
BASECAMP = 'basecamp'
BASECAMP2 = 'basecamp2'
BASECAMP3 = 'basecamp3'
GITHUB = 'github'
JIRA = 'jira'
MITE = 'mite'
TOGGL = 'toggl'
TRELLO = 'trello'
WUNDERLIST = 'wunderlist'
YOUTRACK = 'youtrack'