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)

Update an activity.

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

the created activity

delete(id: int)

Delete an activity.

Parameters:id – id of the activity to delete
Returns:empty response on success (in default configuration moco_wrapper.util.response.EmptyResponse)
disregard(reason, activity_ids, company_id, project_id=None)

Disregard activities.

Parameters:
  • reason – reason text for disregarding these activities
  • activity_ids – list of activity ids to disregard
  • company_id – company id these activities belong to
  • project_id – project id these activities belong to
Returns:

list with the activity ids that were disregarded (in default configuration moco_wrapper.util.response.ListingResponse)

get(id: int)

Get a single activity.

Parameters:id – id of the activity:
Returns:the activity object (in default configuration moco_wrapper.util.response.JsonResponse)
getlist(from_date: datetime.date, to_date: datetime.date, user_id: int = None, project_id: int = None, sort_by: str = None, sort_order: str = 'asc', page: int = 1)

Get a list of activity objects.

Parameters:
  • from_date – start date
  • to_date – end date
  • user_id – user id
  • project_id – project id the activity belongs to
  • sort_by – field to sort results by
  • sort_order – asc or desc
  • page – page number (default 1)
Returns:

list of activities

start_timer(id: int)

Start a timer on the specified activity.

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

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

Stop a timer on the specified activity.

Parameters:id – id of the activity
Returns:the activity the timer was stopped for (in default configuration moco_wrapper.util.response.JsonResponse)
update(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:
  • id – id of the activity
  • activity_date – date of the activity
  • project_id – id of the project this activity belongs to
  • task_id – id of the task this activity belongs to (see project tasks)
  • hours – hours to log to the activity (passing a 0 will start a timer if the date is today)
  • description – activity description text
  • billable – true/false (if this activity is billable) (select none if billing is dependent on project configuration)
  • tag – a tag string
  • remote_service – if this task was created by a remote service, its name will be here. For allowed values see ActivityRemoteService
  • remote_id – id of the activity in the remote_service
  • remote_url – 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'