Activity recording
Activity recording is the main incoming data stream of the Mobilic API.
We will detail here the different operations that allow these records to be made.
Prerequisite
All operations below requires to be authenticated with an "activated" account :
after signing in, the user needs to confirm the email address to activate the account
while the user account is not actived, the operations won't be available
To know if the user account is activated, you can retrieve hasActivatedEmail
and hasConfirmedEmail
with this operation :
They must be equal totrue
.
Operations
Creation of a new mission
Before recording the activities, it is necessary to create a mission to which the activities will be attached. The operation for creating the mission is as follows :
There are two variables, both optional:
name
companyId
, which makes it possible to specify the company associated with the assignment in the case where the author is attached to several companies.
If a company is given via companyId
, the author must be attached to it, either as a manager or as a worker. If no company is specified, the mission is associated with the author's main company.
The creation of the mission does not trigger the start of the working time clock : the two moments are separated. This allows the operator, for example, to plan and create missions in advance in their business software, which could then be recorded in the mobile worker interface to allow them to enter the working time for each mission at the appropriate time.
Recording an activity
The registration of an activity is done by means of the operation logActivity
.
This is the main operation.
It takes into arguments :
type
, the nature of the new activity (travelling, working, accompanying)startTime
, the start time of the activitymissionId
, the mission for which the activity is carried outendTime
, the end time of the activity (optional)switch
, indicates whether the tachograph recording mode is activated (optional, default is yes)userId
, the mobile worker for whom to record the activity (optional, default is the authenticated user)context
, free data that will be linked to the activity
By default the activity is recorded for the user who performs the operation (the user authenticated with the token). In order to facilitate the use of the API it is possible to record activities for another user, using the userId
field.
Tachograph recording mode
The Mobilic API favours a real-time input of activities, in which activity change events are transmitted to the API. The end time of an activity is not determined until the next activity change.
Consequently, the logActivity
operation has two modes of operation:
the "tachograph" mode, corresponding to the above principle (
switch: true
). The API records activity changes.a more classical mode where activities are entered after the action with their possible end time (
switch: false
). The API records the activities directly.
More precisely, the "tachograph" mode works as follows :
the
startTime
variable corresponds to the time of the activity change. At the time of the operation the user cannot have any activity recorded after this time. In other words, the change of activity is only possible during or after the last activity.the operation does not accept an end time (
endTime
)if the user's last activity is not finished the operation terminates the last activity at the
startTime
.the operation creates a new activity starting at
startTime
and without an end time.
In contrast, the classic recording mode simply creates a new period of activity for the user, checking only that there is no overlap with their history. In particular, it can be used to insert a new activity among past activities (which the tachograph mode does not allow).
Updating an activity
The operation to correct or modify an activity is editActivity
. Only the time period of an activity can be modified (not the type of work, nor the mission nor the worker concerned).
It takes into argument :
activityId
, the identifier of the activity to be modifiedstartTime
, the new start time (optional, if it has been changed)endTime
, the new end time (optional, if it has been changed)e)removeEndTime
, indicates whether the end of the activity should be cancelled (optional and incompatible withendTime
). Useful if the activity was terminated by mistake.context
, free data that will be attached to the modification event.
Cancelling an activity
The operation to cancel an activity is cancelActivity
. It removes the activity from the user's history.
End of mission
The operation signals the end of the mission for the mobile worker.
The arguments of the operation have the same function as for recording an activity. In case the last user activity is not completed the operation terminates it at the endTime
.
Examples
We will illustrate the use and role of the above operations through the example of a typical working day.
Start of the day
The first action to perform is to create a mission.
Response
Start Location
Once the mission is created and the vehicle specified, you can log the location of the start of the mission, and the vehicle mileage.
These information are mandatory.
See page below for more information about logging a location
pageLocation recordingFirst activity
The start of the first activity of the mission can then be recorded.
Response
In tachograph mode the activity does not have an end time when it is recorded. As long as the API does not receive a new activity change or end event the stopwatch continues to run.
Second activity
The recording of the change of activity is done in the same way as the previous recording, i.e. in tachograph mode.
Response
The change of activity created a new activity starting at 11:00 (and with no end time) and ended the previous activity at the same time.
Break
To indicate the end of an activity without the immediate start of another activity, simply edit the end date of the activity.
Response
End of the day
Third activity
Once the pause is over, the recording of activities can be resumed, still in tachograph mode.
Réponse
When counting working time over the day, the gaps between two activities will automatically be counted as break time.
Fourth activity
Response
End location
Before ending a mission, you must specify the end location, and the updated mileage.
These information are mandatory
See page below for more information about logging a location
pageLocation recordingEnd of mission
To end the mission, simply perform the endMission
operation by passing the end date of the current activity.
Response
Possible corrections
The mobile worker notices some errors and omissions in his initial input.
Forgot to restart after the break
The real time of the restart after the lunch break is 1.30 p.m., but the user did not register the restart until 2 p.m. To correct this, the user simply indicates that the restart activity actually started half an hour earlier.
Response
Correcting the end of an activity
The mobile worker has reported the end of the assignment too early. He wants to shift the end date from 5pm to 5:30pm.
Response
Adding an activity after the event
The mobile worker wants to add an activity that took place between 8am and 9am. All he has to do is record an activity in classic mode.
Response
Last updated