AsiaSkills_Session3_MobileApp

General notes

API detail

Get Action Types

The method returns list of all action types with Id, Name, Colors (background and font) and Emergency flag.

HTTP codes

200 - OK

curl -X GET "http://web.ws.int:8051/api/ActionTypes"
GET /api/ActionTypes HTTP/1.1
Host: web.ws.int:8051
Status200 OK
[
    {
        "Id": 1,
        "Name": "Driver health check",
        "BackColorHex": "#4CAF50",
        "FontColorHex": "#FFFFFF",
        "IsEmergencyEvent": false
    },
    {
        "Id": 2,
        "Name": "Change driver",
        "BackColorHex": "#673AB7",
        "FontColorHex": "#FFFFFF",
        "IsEmergencyEvent": false
    },
    {
        "Id": 9,
        "Name": "Refuel",
        "BackColorHex": "#88345E",
        "FontColorHex": "#FFFFFF",
        "IsEmergencyEvent": false
    },
    {
        "Id": 10,
        "Name": "SOS",
        "BackColorHex": "#F44336",
        "FontColorHex": "#FFFFFF",
        "IsEmergencyEvent": true
    }
]

Get Current Truck

The method returns data about the Truck corresponding to a specific competitor.

Data about the Truck includes Id, Number, Type name, Vendor name, Model name, last data about location (latitude and longitude) and list of drivers. Data about the Driver includes Id, Full name, Date of birth, Phone and possible Medical health restrictions.

HTTP codes

200 - OK

404 - No Truck found

curl -X GET "http://web.ws.int:8051/api/CurrentTruck?competitorId=1"
GET /api/CurrentTruck?competitorId=1 HTTP/1.1
Host: web.ws.int:8051
Status200 OK
{
    "Id": 1,
    "Number": "C958HX13",
    "Type": "Trawl",
    "Vendor": "Mercedes",
    "Model": "Unimog",
    "CurrentLocationLatitude": 58.950522,
    "CurrentLocationLongitude": 32.213727,
    "Drivers": [
        {
            "Id": 40,
            "FullName": "Bryan Koala",
            "DateOfBirth": "1991-08-08",
            "Phone": "73701561491",
            "MedicalHealthRestriction": 4
        },
        {
            "Id": 45,
            "FullName": "Daniel Giraffe",
            "DateOfBirth": "1956-06-16",
            "Phone": "75110361216",
            "MedicalHealthRestriction": null
        }
    ]
}
Status404 Not Found

Get Current Transport Task

The method returns data about current transport task for the Truck, including Id, Created date and time, Deadline, information about Arrival and Destination Logistics Centers.

Data about each Logistics Center includes the Name of the center, text description of Address and its coordinates (latitude and longitude).

HTTP codes

200 - OK

404 - No Transport task found

curl -X GET "http://web.ws.int:8051/api/CurrentTransportTask?truckNumber=C958HX13"
GET /api/CurrentTransportTask?truckNumber=C958HX13 HTTP/1.1
Host: web.ws.int:8051
Status200 OK
{
    "Id": 6,
    "CreatedDateTime": "2021-08-10T19:34:12",
    "Deadline": "2021-08-26",
    "ArrivalLogisticsCenter": {
        "Address": "St Petersburg",
        "Name": "Beaver Freight",
        "LocationLatitude": 59.9375,
        "LocationLongitude": 30.308611
    },
    "DestinationLogisticsCenter": {
        "Address": "Blagoveshchensk",
        "Name": "Navis Pack",
        "LocationLatitude": 50.272778,
        "LocationLongitude": 127.540405
    }
}
Status404 Not Found

Get Road Actions for Truck

The method returns list of road actions (ordered by start date time from oldest to newest) for last transport task of specific truck.

If current transport task doesn’t have any road actions yet, you need to create them using Timeline rules from Test Project Description and then this method will return new road actions.

Each road action contains Unique Id, Action type identifier, start date time, possible driver full name, possible comment, possible place description and coordinates (latitude and longitude).

If you need to remove all road actions for current task, you can use ClearTransportTask method described in postman collection.

HTTP codes

200 - OK

404 - No Transport task found

curl -X GET "http://web.ws.int:8051/api/RoadActions?truckNumber=C958HX13"
GET /api/RoadActions?truckNumber=C958HX13 HTTP/1.1
Host: web.ws.int:8051
Status200 OK
[
    {
        "Id": 117,
        "ActionTypeId": 9,
        "StartDateTime": "2021-08-03T02:00:00",
        "Driver": null,
        "Comment": null,
        "PlaceDescription": null,
        "PlaceLatitude": null,
        "PlaceLongitude": null
    },
    {
        "Id": 119,
        "ActionTypeId": 2,
        "StartDateTime": "2021-08-03T02:30:00",
        "Driver": "Bryan Koala",
        "Comment": null,
        "PlaceDescription": null,
        "PlaceLatitude": null,
        "PlaceLongitude": null
    },
    {
        "Id": 118,
        "ActionTypeId": 7,
        "StartDateTime": "2021-08-03T03:42:29.04",
        "Driver": null,
        "Comment": null,
        "PlaceDescription": null,
        "PlaceLatitude": null,
        "PlaceLongitude": null
    }
]
Status404 Not Found

Post SOS Road Action

The method POSTs SOS road emergency action for specific truck with current coordinates (latitude and longitude).

The truck can send a SOS signal, only when executing a specific transport task.

The encouraging message with registered road action ID should be returned.

HTTP codes

201 - Successfully created

400 - Invalid coordinates

400 - No actual Transport Task

curl -X POST "http://web.ws.int:8051/api/RoadActions/SOS?truckNumber=C958HX13&lat=54.66454&lng=45.77453"
POST /api/RoadActions/SOS?truckNumber=C958HX13&lat=54.66454&lng=45.77453 HTTP/1.1
Host: web.ws.int:8051
Status201 Created
{
    "Message": "SOS #177. Brace yourself! Help is on the way!"
}
Status400 Bad Request
{
    "Message": "This car doesn't currently have actual transport task right now."
}
Status400 Bad Request
{
    "Message": "Invalid coordinates"
}

Post Emergency Road Action

The method POSTs road emergency action for specific truck for the current date and time.

Body json parameter should contain Road Action object with the following necessary data: emergency action type identifier and transport task identifier. The following data can be added optionally: place description (max 100 symbols), driver identifier, comment and location coordinates (necessary both latitude in range from -90 to 90 and longitude in range from -180 to 180).

The registered road action data should be returned which includes ID param.

HTTP codes

201 - Successfully created

400 - No body road action

400 - Invalid Action type

400 - Invalid Transport Task

400 - Invalid Driver identifier

400 - Invalid coordinates

400 - Long place description

curl -X POST -d '{
    "ActionTypeId": 4,
    "PlaceDescription": "Near the tall tree in the forest",
    "TransportTaskId": 6,
    "DriverId": 33,
    "Comment": "Replacing the right front wheel",
    "PlaceLatitude": 14.66443,
    "PlaceLongitude": 34.7757
}' "http://web.ws.int:8051/api/RoadActions"
POST /api/RoadActions HTTP/1.1
Host: web.ws.int:8051

{
    "ActionTypeId": 4,
    "PlaceDescription": "Near the tall tree in the forest",
    "TransportTaskId": 6,
    "DriverId": 33,
    "Comment": "Replacing the right front wheel",
    "PlaceLatitude": 14.66443,
    "PlaceLongitude": 34.7757
}
Status201 Created
{
    "Id": 237,
    "ActionTypeId": 4,
    "PlaceDescription": null,
    "TransportTaskId": 6,
    "DriverId": null,
    "Comment": null,
    "PlaceLatitude": null,
    "PlaceLongitude": null
}
Status201 Created
{
    "Id": 185,
    "ActionTypeId": 4,
    "PlaceDescription": "Near the tall tree in the forest",
    "TransportTaskId": 6,
    "DriverId": 33,
    "Comment": "Replacing the right front wheel",
    "PlaceLatitude": 14.66443,
    "PlaceLongitude": 34.7757
}
Status400 Bad Request
{
    "Message": "Invalid coordinates"
}
Status400 Bad Request
{
    "Message": "Invalid driver id."
}
Status400 Bad Request
{
    "Message": "Invalid emergency action type."
}
Status400 Bad Request
{
    "Message": "Invalid transport task id."
}
Status400 Bad Request
{
    "Message": "Invalid RoadAction object"
}
Status400 Bad Request
{
    "Message": "Too long place description."
}

Post Emergency Road Action Photo

The method POSTs photo, attached to the road action. The method contains path parameter - Identifier of the road action. /api/RoadActions/Photo/{Id}, where {Id} is “174”, for example.

Pay attention to request Content-Type and name of form-data param.

HTTP codes

200 - OK

400 - Bad request (no file param)

409 - No RoadAction with this ID

curl -X POST "http://web.ws.int:8051/api/RoadActions/Photo/174"
POST /api/RoadActions/Photo/174 HTTP/1.1
Host: web.ws.int:8051

Clear Road Actions of Transport Task

The method changes information about the Transport Task, clearing its all road actions data.

The method contains path parameter - Transport Task identifier. /api/ClearTransportTask/{id}, where {id} is “6”, for example.

Competitors can clear only actions, that refers to his specific truck and transport task. Access is verified with competitor’s password in query parameter.

HTTP codes

204 - OK, no content

401 - Unauthorized

404 - No Transport task found

curl -X PUT "http://web.ws.int:8051/api/ClearTransportTask/6?password=competitor_password"
PUT /api/ClearTransportTask/6?password=competitor_password HTTP/1.1
Host: web.ws.int:8051