PTM API
Token request
Before start need to get token. Server send answer in json.
Data
|
Value
|
URL
|
http://tasks.<address>/backend/public/getToken
|
Method
|
GET
|
Params
|
|
Response
|
{"token": ***}
|
Put your token in all headers:
$.ajaxSetup({
headers: {
"X-CSRF-TOKEN": token
}
});
or you can put token like additional parameter:
<input type="hidden" name="_token" value="token">
If you use token like additional parameter than need to set it to all requests (POST, PUT, DELETE).
Token value - string
Example:
fetch("https://tasks.<address>/backend/public/getToken?_dc=1597911308273",
{
"headers": {
"accept": "*/*",
"accept-language": "uk-UA,uk;q=0.9,ru;q=0.8,en-US;q=0.7,en;q=0.6",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin"
},
"referrer": "https://tasks.pilot-gps.ru/",
"referrerPolicy": "no-referrer-when-downgrade",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
{"token":"CtrsOKz3NykfxWlyboPlq3LGNpPrWsCtIymrKq0G"}
User initialization
Data
|
Value
|
URL
|
http://tasks.<address>/backend/public/initAuth
|
Method
|
GET
|
Params
|
language - user language (string),
timezone - user's time zone (number)
|
Response:
if the user is already logged in:
{
"auth": true,
"items": { // information about user
"id": ***,
"name": ***,
"email": ***,
"c_fio": ***,
"c_account_id": ***,
},
"resAccParams": {...}, // account settings
"permissionsAcc": ..., // user rigths
// template settings
"parametersTemplate": {...},
"ip": ***
}
than:
{
"auth": false
}
If the user is not authorized, then proceed to his authorization.
Example:
fetch("https://tasks.<address>/backend/public/initAuth?_dc=1597911308943&language=en&timezone=-180", {
"headers": {
"accept": "*/*",
"accept-language": "uk-UA,uk;q=0.9,ru;q=0.8,en-US;q=0.7,en;q=0.6",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-csrf-token": "CtrsOKz3NykfxWlyboPlq3LGNpPrWsCtIymrKq0G"
},
"referrer": "https://tasks.<address>/",
"referrerPolicy": "no-referrer-when-downgrade",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
{"auth":false}
User authorization
Data
|
Value
|
URL
|
http://tasks.<address>/backend/public/login
|
Method
|
GET
|
Params
|
login - string,
password - string,
language - string,
timezone - unixtimestamp.
|
Response:
If the user is authorized, then:
{
"auth": true,
"items": { // Information about user
"id": ***,
"name": ***,
"email": ***,
"c_fio": ***,
"c_account_id": ***,
...
},
"resAccParams": {...}, // account settings
"permissionsAcc": ..., // user rights
// template settings
"parametersTemplate": {...},
"ip": ***
}
then:
{
"auth": false,
"msg": ***
}
Example:
fetch("https://tasks.<address>/backend/public/login", {
"headers": {
"accept": "*/*",
"accept-language": "uk-UA,uk;q=0.9,ru;q=0.8,en-US;q=0.7,en;q=0.6",
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-csrf-token": "CtrsOKz3NykfxWlyboPlq3LGNpPrWsCtIymrKq0G"
},
"referrer": "https://tasks.<address>/",
"referrerPolicy": "no-referrer-when-downgrade",
"body": "login=demo&password=demo&language=en&remember=true&timezone=-180",
"method": "POST",
"mode": "cors",
"credentials": "include"
});
Get Tasks list
Data
|
Value
|
URL
|
http://tasks.<address>/backend/public/dashboard/tasks
|
Method
|
GET
|
Params
|
page - page number (integer),
start - record number (integer),
limit - record count (integer),
usr_id - user ID(get from user initialization or authorization responce) (integer),
acc_id - account ID get from user initialization or authorization responce) (integer)
|
Response:
{"page" => ..., "items" => ..., "total" => ... }
Designation of the main fields:
'id' - Task ID (int4),
'c_status_id' - Task status ID (int4),
'c_task_type_id' - Task type ID (int4),
'c_initiator' - task initiator / applicant (string),
'c_address_initiator' - initiator address(string),
'c_address_tasks' - Task address (string),
'c_address_base' - Base address (string),
'c_tasks_lat' - lat (numeric),
'c_tasks_lon' - lon (numeric),
'c_base_lat' - lat (numeric),
'c_base_lon' - lon (numeric),
'c_user_id' - User ID that created task (integer),
'c_driver_id' - Drvier ID (integer),
'c_vehicle_id' - vehicle uniqid (string),
'c_initiator_type' - task template ID (integer),
'c_reminder' - (not used) (bool),
'c_begin_time' - (int8 (timestamp)),
'c_return_time' - (int8 (timestamp)),
'c_running_time' - (int8 (timestamp)),
'c_progress_time' - (int8 (timestamp)),
'c_end_time' - (int8 (timestamp)),
'c_reminder_time' - (not used) (int8 (timestamp)),
'c_information' – json,
'created_at' - Creation time,
'updated_at' - Update time,
'c_accept_time' - Time when driver accepted task (int8 (timestamp)),
'c_initiator_type_name' - Template name (string),
'c_initiator_parameters' - Template settings(json),
'c_status_name' - Task status name (string),
'c_task_type_name' - Name of task type (string),
'c_task_type_priority' - Priority task ID (string),
'c_task_type_priority_name' - Priority name (string),
'c_task_type_color' - Task type color (string)
// list of parameters depends on template settings
Example:
fetch("https://tasks.<address>/backend/public/get_drivers?_dc=1597911482130&page=1&start=0&limit=10000&sort=
%5B%7B%22property%22%3A%22id%22%2C%22direction%22%3A%22ASC%22%7D%5D", {
"headers": {
"accept": "*/*",
"accept-language": "uk-UA,uk;q=0.9,ru;q=0.8,en-US;q=0.7,en;q=0.6",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-csrf-token": "CtrsOKz3NykfxWlyboPlq3LGNpPrWsCtIymrKq0G"
},
"referrer": "https://tasks.pilot-gps.ru/",
"referrerPolicy": "no-referrer-when-downgrade",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
{"page":1,"items":[{"id":403,"name":"base_1","email":"base_1@mobile.task","c_fio":"Sergey Bocharov","c_driver_id":1,"c_information":"{\"phone\":\"89895114069\",\"address\":\"\",\"description\":\"\",\"id\":1,\"agent_id\":48162,\"account_id\":1107,\"name\":
\"Sergey Bocharov\",\"vehicle_id\":\"10518\",\"vehicle_number\":\"ECO DRIVING\",\"passport\":null}","is_busy":
true,"c_tasks_id":"155433","is_deleted":false}, ...],"total":22,"msg":[]}
Create Task
Data
|
Value
|
Data
|
Value
|
URL
|
http://tasks.<address>/backend/public/dashboard/tasks
|
Method
|
POST
|
URL
|
http://tasks.<address>/backend/public/dashboard/tasks/set
|
Method
|
GET
|
Params
|
''c_task_type_id' - Task type ID (integer),
'c_driver_id' - Driver ID (optional) (integer),
'c_vehicle_id' - vehicle uniqid (optional) (string),
'driver_phone' - Driver phone (optionsl) (string),
'c_initiator_type' - Initiator type (integer),
'c_begin_time' - (int8 (timestamp)),
'c_return_time' - (int8 (timestamp)),
'phone' - Initiator phone (optional) (string),
'office' - Office number (optional) (string),
'description' - (string),
'c_initiator' - (string),
'c_address_base' - (string),
'c_address_base_lat' - lat (numeric),
'c_address_base_lng' - lng (numeric),
'c_address_tasks' - (string),
'c_address_tasks_lat' - lat (numeric),
'c_address_tasks_lng' - lat (numeric),
'c_address_initiator' - (string),
* + all parameters that were included in template
If you use GET, need to set extra parameters:
'usr_id' - User ID get from user initialization or authorization responce) (integer),
'acc_id' - Account ID get from user initialization or authorization responce) (integer)
'acc_id' - account identifier (located in the object we receive upon successful initialization or authorization) (number).
|
Response
|
{'success': true/false, 'msg': '***'}
|
Example:
fetch("https://tasks.<address>/backend/public/dashboard/tasks", {
"headers": {
"accept": "*/*",
"accept-language": "uk-UA,uk;q=0.9,ru;q=0.8,en-US;q=0.7,en;q=0.6",
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-csrf-token": "CtrsOKz3NykfxWlyboPlq3LGNpPrWsCtIymrKq0G",
"x-requested-with": "XMLHttpRequest"
},
"referrer": "https://tasks.<address>/",
"referrerPolicy": "no-referrer-when-downgrade",
"body": "c_initiator_type=182&c_initiator=Test%20Query&phone=777777&c_address_initiator=&c_address_initiator_geofence_id=
&c_address_initiator_lat=&c_address_initiator_lng=&office=&c_vehicle_id=fgr5b7e657rtg&agent_id=97405&c_driver_id=317&driver_phone=
798345546&c_task_type_id=173&c_address_base=49%2C%20Ulitsa%20Oborony%2C%20Rostov%2C%20Russia&c_address_base_geofence_id=
&c_address_base_lat=47.216118&c_address_base_lng=39.707015&c_address_base_date_point_dt=20.08.2020&c_address_base_date_point_tm=
11%3A39&c_address_base_date_point=1597912740&c_address_base_time_point=20&c_address_tasks%5B%5D=
234%2C%20Ulitsa%20Tekucheva%2C%20Rostov%2C%20Russia&c_address_tasks%5B%5D=55%2C%20Prospekt%20Mikhaila%20Nagibina%2C%20Rostov%2C%20Russia&c_address_tasks_geofence_id%5B%5D=&c_address_tasks_geofence_id%5B%5D=&c_address_tasks_lat%5B%5D=
47.233978&c_address_tasks_lat%5B%5D=47.266229&c_address_tasks_lng%5B%5D=39.703632&c_address_tasks_lng%5B%5D=
39.720982&c_address_tasks_date_point_dt=20.08.2020&c_address_tasks_date_point_dt=20.08.2020&c_address_tasks_date_point_tm=
13%3A05&c_address_tasks_date_point_tm=14%3A05&c_address_tasks_date_point%5B%5D=
1597917900&c_address_tasks_date_point%5B%5D=1597921500&c_address_tasks_time_point%5B%5D=
20&c_address_tasks_time_point%5B%5D=20&c_begin_time_dt=20.08.2020&c_begin_time_tm=11%3A35&c_begin_time=
1597912500&c_return_time_dt=20.08.2020&c_return_time_tm=18%3A00&c_return_time=1597935600&description=
Test%20description&Anyfields=Hi&template_for_act=%D0%A0%D0%B5%D0%BC%D0%BE%D0%BD%D1%82&forecast=&count_copy_task=
1",
"method": "POST",
"mode": "cors",
"credentials": "include"
});
Edit Task
Data
|
Value
|
Data
|
Value
|
URL
|
http://tasks.<address>/backend/public/dashboard/tasks
|
Method
|
PUT
|
URL
|
http://tasks.<address>/backend/public/dashboard/tasks/update
|
Method
|
GET
|
Params
|
'c_task_type_id' - (integer),
'c_driver_id' - Driver ID (optional) (integer),
'c_vehicle_id' - vehicle uniqid (optional) (string),
'driver_phone' - Driver phone (optional) (string),
'c_initiator_type' - Initiator type (integer),
'c_begin_time' - (int8 (timestamp)),
'c_return_time' - (int8 (timestamp)),
'phone' - Initiator phone (optional) (string),
'office' - (optional) (string),
'description' - (optional) (string),
'c_initiator' - (string),
'c_address_base' - (string),
'c_address_base_lat' - lat (numeric),
'c_address_base_lng' - lng (numeric),
'c_address_tasks' - (string),
'c_address_tasks_lat' - lat (numeric),
'c_address_tasks_lng' - lat (numeric),
'c_address_initiator' - (string),
* + all parameters that were included in template
If you use GET, need to set extra parameters:
'usr_id' - User ID get from user initialization or authorization responce) (integer),
'acc_id' - Account ID get from user initialization or authorization responce) (integer)
|
Response
|
{'success': true/false, 'msg': '***'}
|
Delete Task
Data
|
Value
|
URL
|
http://tasks.<address>/backend/public/dashboard/tasks
|
Method
|
DELETE
|
URL
|
http://tasks.<address>/backend/public/dashboard/tasks/delete
|
Method
|
GET
|
Params
|
‘list_id’ - List of tasks ID sepparated by comma (string)
If you use GET, need to set extra parameters:
'usr_id' - User ID get from user initialization or authorization responce) (integer),
'acc_id' - Account ID get from user initialization or authorization responce) (integer
|
Response
|
{'success': true/false, 'msg': '***'}
|
Get templates list
Data
|
Value
|
URL
|
http://tasks.<address>/backend/public/dictionary/initiators
|
Method
|
GET
|
Params
|
page - (integer),
start - record nimber (integer),
limit - record counts (integer),
'usr_id' - User ID get from user initialization or authorization responce) (integer),
'acc_id' - Account ID get from user initialization or authorization responce) (integer)
|
Response
|
{"page" => ..., "items" => ..., "total" => ... }
Description of main fileds:
'id' - Template ID,
'c_name' - Template name,
'c_parameters' - Template parameters in json,
'c_information' - Additional information about template in json,
'created_at' - Server time of template creation,
'updated_at' - Server time of update of template,
'is_default' - Flag for default template
|
Example:
fetch("https://tasks.<address>/backend/public/dictionary/initiators?_dc=1597911482387&page=1&start=0&limit=25&sort=
%5B%7B%22property%22%3A%22id%22%2C%22direction%22%3A%22ASC%22%7D%5D", {
"headers": {
"accept": "*/*",
"accept-language": "uk-UA,uk;q=0.9,ru;q=0.8,en-US;q=0.7,en;q=0.6",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-csrf-token": "CtrsOKz3NykfxWlyboPlq3LGNpPrWsCtIymrKq0G"
},
"referrer": "https://tasks.<address>/",
"referrerPolicy": "no-referrer-when-downgrade",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
Get tasks types description
Data
|
Value
|
URL
|
http://tasks.<address>/backend/public/dictionary/tasks/types
|
Method
|
GET
|
Params
|
'usr_id' - User ID get from user initialization or authorization responce) (integer),
'acc_id' - Account ID get from user initialization or authorization responce) (integer)
|
Response
|
{"page" => ..., "items" => ..., "total" => ... }
Description of main fields:
id - Task type ID,
c_name - Task type name,
c_priority - Task priority ID,
c_information - Additional information in json,
c_account_id - Account ID,
c_priority_name - Priority name,
c_color - Task type color,
is_default - Flag for default type
|
Example:
fetch("https://tasks.<address>/backend/public/dictionary/tasks/types?_dc=1597911482366&page=
1&start=0&limit=
100&sort=%5B%7B%22property%22%3A%22id%22%2C%22direction%22%3A%22ASC%22%7D%2C%7B%22property%
22%3A%22c_priority%22%2C%22direction%22%3A%22ASC%22%7D%5D", {
"headers": {
"accept": "*/*",
"accept-language": "uk-UA,uk;q=0.9,ru;q=0.8,en-US;q=0.7,en;q=0.6",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-csrf-token": "CtrsOKz3NykfxWlyboPlq3LGNpPrWsCtIymrKq0G"
},
"referrer": "https://tasks.<address>/",
"referrerPolicy": "no-referrer-when-downgrade",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
{"page":1,"items":[{"id":1,"c_name":"Information","c_priority":3,"c_information":"{\"description\":
\"This type of task is intended for setting up
a job without the possibility of executing it. It is purely informational in nature.\"}","c_account_id":0,"c_priority_name":
a job without the possibility of executing it. It is purely informational in nature.\"}","c_account_id":0,"c_priority_name":
"Not urgent","c_color":"event-severity-a0eac9","is_default":null},{"id":2,"c_name":"LOGISTICS: Delivery","c_priority":5,"c_information":
"{\"description\":
\"This type of task denotes tasks imported from the PILOT logistics module.\"}","c_account_id":0,"c_priority_name":
"Pilot task","c_color":
"event-severity-6d9eeb","is_default":null},{"id":89,"c_name":"LOGISTICS: Loading","c_priority":1,"c_information":
"{\"description\":
\"This type of task denotes tasks imported from the PILOT logistics module.\"}","c_account_id":0,"c_priority_name":
"Very urgent","c_color":"event-severity-efa093","is_default":null},{"id":90,"c_name":"LOGISTICS: Unloading",
"c_priority":2,"c_information":"{\"description\":
\"This type of task denotes tasks imported from the PILOT logistics module.\"}","c_account_id":0,"c_priority_name":
"Urgently","c_color":
"event-severity-ffd6a2","is_default":null},{"id":173,"c_name":"Delivery","c_priority":2,"c_information":"{\"description\":
\"Type designating the delivery of various goods\"}","c_account_id":1107,"c_priority_name":"Urgently","c_color":
"event-severity-ffd6a2","is_default":true},{"id":174,"c_name":
"Repairs","c_priority":
1,"c_information":"{\"description\":\"Type designating for the repair of various items\"}","c_account_id":1107,
"c_priority_name":
"Very urgent",
"c_color":"event-severity-efa093","is_default":false},{"id":211,"c_name":"Booking","c_priority":3,"c_information":
"{\"description\":\"\"}",
"c_account_id":1107,"c_priority_name":"Not urgent","c_color":"event-severity-a0eac9","is_default":false}],"total":7}
Get Drivers list
Data
|
Value
|
URL
|
http://tasks.<address>/backend/public/get_drivers
|
Method
|
GET
|
Params
|
page - (integer),
start - record number (integer),
limit - records count (integer),
'usr_id' - User ID get from user initialization or authorization responce) (integer),
'acc_id' - Account ID get from user initialization or authorization responce) (integer)
|
Response
|
{"page" => ..., "items" => ..., "total" => ... }
Description of main fields:
'id' – user ID,
'name' – user login,
' email',
' c_fio' – user name and surname,
' c_driver_id' – driver id,
' c_information' – additional information in json,
' is_busy' – flag, busy driver or not,
' c_tasks_id' – List of tasks that were send for this driver,
' is_deleted'
|
Get Vehicles list
Data
|
Value
|
URL
|
https://tasks.<address>/backend/public/get_vehicles
|
Method
|
GET
|
Params
|
'usr_id' - User ID get from user initialization or authorization responce) (integer),
'acc_id' - Account ID get from user initialization or authorization responce) (integer)
|
Response
|
{"page" => ..., "items" => ..., "total" => ... }
Description of main fields:
'id' – record ID,
'c_vehicle_id' – Vehicle ID in PILOT system,
'c_driver_id' - Driver ID that linked with vehicle,
'c_account_id' – Account ID,
'c_status_id' – Resource status,
'c_information' - additional information in json,
'c_task_id' – Current task ID,
'c_ping_ts' – Last connection time of mobile app,
'c_set_status_time' – Last status change time,
'agent_id' – Agent ID,
'is_busy' - Flag if vehicle busy or not,
'c_ass_tasks_id' - List of tasks for this vehicle
|
Example:
fetch("https://tasks.<address>/backend/public/get_vehicles?_dc=1597911482354&page=1&start=
0&limit=10000", {
"headers": {
"accept": "*/*",
"accept-language": "uk-UA,uk;q=0.9,ru;q=0.8,en-US;q=0.7,en;q=0.6",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-csrf-token": "CtrsOKz3NykfxWlyboPlq3LGNpPrWsCtIymrKq0G"
},
"referrer": "https://tasks.<address>/",
"referrerPolicy": "no-referrer-when-downgrade",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
{"page":1,"items":[{"id":64314,"c_vehicle_id":"fgr5b7e657rtg","c_driver_id":317,"c_account_id":1107,"c_status_id":
1,"c_information":
"{\"id\":\"fgr5b7e657rtg\",\"agentid\":97405,\"veh_id\":97405,\"account_id\":1107,\"number\":\"test ds 222\",\"model\":
\"\",\"driver_id\":
317,\"driver_name\":\"Ivan Ivanov\",\"driver_phone\":\"798345546\",\"folder\":\"MAIN\",\"volume\":\"0.000\",\"disabled\":
false,\"info\":\"\",\"year\":\"1900\",\"parent_folder\":null,\"parent_folder_1\":null,\"parent_folder_2\":null,\"parent_folder_3\":
null,\"full_capacity\":\"0\",\"seating_capacity\":\"0\",\"work_schedule\":{\"schedule\":\"09:00-18:00\",\"days_of_week\":
[0,1,2,3,4]}}","c_task_id":154955,"c_ping_ts":1597735213,
"c_set_status_time":1597735213,"agent_id":97405,"is_busy":true,"c_ass_tasks_id":"154955,155627,155628,155629"}],
"total":1,"msg":[]}
Get List of statuses of vehicles (if there is pair vehicle-driver and app used)
Data
|
Value
|
URL
|
https://tasks.<address>/backend/public/dictionary/devices/statuses
|
Method
|
GET
|
Params
|
page - (integer),
start - record number (integer),
limit - records count (integer),
'usr_id' - User ID get from user initialization or authorization responce) (integer),
'acc_id' - Account ID get from user initialization or authorization responce) (integer)
|
Response
|
{"page" => ..., "items" => ..., "total" => ... }
Description of main fields:
Id – record ID,
c_name – status name,
c_information - additioanl information in json,
c_status_type_id – status type,
c_function_name – function (call) name,
c_function_arg – function input parameters,
c_status_type_name – status type name,
c_trigger - тригер,
c_account_id – account ID,
c_status_task_id – status type ID
|