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:
import datetime 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 = None, seconds: int = 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_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
- hours (float) – Hours to log to the activity (pass 0 to start a timer, if the date is today) (default
None
) - seconds (int) – Pass seconds instead of hours to avoid rounding issues (default
None
) - description (str) – Activity description text (default
None
) - billable (bool) – If this activity is billable
(pass
None
if billing is dependent on project configuration) (defaultNone
) - tag (str) – Tag string (default
None
) - remote_service (
ActivityRemoteService
, str) – Name of the remote service referenced by the activity (defaultNone
) - remote_id (str) – Id of the activity in the remote_service (default
None
) - remote_url (str) – Url of the remote service (default
None
)
Returns: The created activity
Return type:
-
delete
(activity_id: int)¶ Delete an activity.
Parameters: activity_id (int) – Id of the activity to delete Returns: Empty response on success Return type: moco_wrapper.util.response.EmptyResponse
-
disregard
(reason: str, activity_ids: list, company_id: int, project_id: int = 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 (default
None
)
Returns: List with the activity ids that were disregarded
Return type:
-
static
endpoints
() → List[moco_wrapper.util.endpoint.endpoint.Endpoint]¶ Returns all endpoints associated with the model
Returns: List of Endpoint objects Return type: moco_wrapper.util.endpoint.Endpoint
-
get
(activity_id: int)¶ Get a single activity.
Parameters: activity_id (int) – Id of the activity Returns: The activity object Return type: moco_wrapper.util.response.ObjectResponse
-
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 activities.
Parameters: - from_date (datetime.date, str) – Start date
- to_date (datetime.date, str) – End date
- user_id (int) – User Id the activity belongs to (default
None
) - project_id (int) – Id of the project the activity belongs to (default
None
) - task_id (int) – Id of the task the activity belongs to (default
None
) - sort_by (str) – Field to sort results by (default
None
) - sort_order (str) – asc or desc (default
"asc"
) - page (int) – Page number (default 1)
Returns: List of activities
Return type:
-
start_timer
(activity_id: int)¶ Start a timer on the specified activity.
Timers can only be started for activities of the current day.
Parameters: activity_id (int) – Id of the activity Returns: The activity the timer was started for Return type: moco_wrapper.util.response.ObjectResponse
Note
Timers can only be started for activities of the current day
-
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 Return type: moco_wrapper.util.response.ObjectResponse
-
update
(activity_id: int, activity_date: datetime.date = None, project_id: int = None, task_id: int = None, hours: float = None, seconds: int = None, 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_id (int) – Id of the activity
- activity_date (datetime.date, str) – Date of the activity (default
None
) - project_id (int) – Id of the project this activity belongs to (default
None
) - task_id (int) – Id of the task this activity belongs to (default
None
) - hours (float) – Hours to log to the activity (pass 0 to start a timer, if the date is today) (default
None
- seconds (int) – Pass seconds instead of hours to avoid rounding issues (default
None
) - description (str) – Description text (default
None
) - billable (bool) – If this activity is billable
(pass
None
) if billing is dependent on project configuration) (defaultNone
) - tag (str) – Tag string (default
None
) - remote_service (
ActivityRemoteService
, str) – Name of the remote service referenced by the activity (defaultNone
) - remote_id (str) – Id of the activity in the remote_service (default
None
) - remote_url (str) – Url of the remote service (default
None
)
Returns: The updated activity
Return type:
-
-
class
moco_wrapper.models.activity.
ActivityRemoteService
¶ Enumeration for allowed values used that can be supplied for the
remote_service
argument inActivity.create()
andActivity.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'¶
-
CLICKUP
= 'clickup'¶
-
GITHUB
= 'github'¶
-
JIRA
= 'jira'¶
-
MITE
= 'mite'¶
-
TOGGL
= 'toggl'¶
-
TRELLO
= 'trello'¶
-
WUNDERLIST
= 'wunderlist'¶
-
YOUTRACK
= 'youtrack'¶
-