Vehicle

  • 15.5
This article is may not be up to date with the latest stable release of M4.

Description

The Vehicle endpoint provides the API consumer with access to methods pertaining to adding/getting information about vehicles in the fleet.

Methods

URL base/GPS/Vehicle/Specification
Action GET
Description Returns a data dictionary that details the available web service methods related to the Vehicle.
Parameters None
 Returns  A JSON object with method descriptions
Sample Return Object
        [
        {
            "HttpAction": "Get",
            "MethodName": "GetVehicle",
            "Description": "Returns the record for a single vehicle given the passed in ID value (see Path).",
            "Path": "/Vehicle/GetVehicle/25032"
        },
        {
            "HttpAction": "Post",
            "MethodName": "GetVehicleByDeviceID",
            "Description": "Returns the record for a single vehicle given the DeviceID.",
            "Format": {
                "DeviceID": "DV2323432"
            }
        },
        {
            "HttpAction": "Post",
            "MethodName": "GetVehicleByName",
            "Description": "Returns the record for a single vehicle given the vehicle name.",
            "Format": {
                "VehicleName": "Vehicle 234324"
            }
        },
        {
            "HttpAction": "Get",
            "MethodName": "GetVehicles",
            "Description": "Returns records for all vehicles in the database.",
            "Path": "/Vehicle/GetVehicles"
        },
        {
            "HttpAction": "Post",
            "MethodName": "AddVehicle",
            "Description": "Adds a new Vehicle to the database using the specified format.",
            "Format": {
                "VehicleName": "Vehicle 342234",
                "DeviceID": "DV8973454",
                "TechID": 34,
                "Description": "Work truck -- specializing in low rise installations"
            }
        }
    ]
URL base/GPS/Vehicle/GetVehicle/ID
Action GET
Description Returns a Vehicle object when given an ID of a valid Vehicle in the M4 database.
Parameters
Name Required? Type Description
ID Yes Integer An integer value representing the ID of a Ticket in the M4 database.
Returns A JSON Vehicle data object
Sample Return Object
        {
            "ID": 4,
            "Description": "Electrical Truck",
            "TechID": 12,
            "TechName": "John Ramos",
            "VehicleName": "Truck 3432",
            "DeviceID": "DT873343"
        }
        
URL base/GPS/Vehicle/GetVehicleByDeviceID
Action POST
Description Returns the Vehicle object associated with the device ID in the M4 database.
Parameters
Name Required? Type Description
DeviceID Yes String The device ID of the vehicle in the M4 database.
Sample JSON Package
    {
        "DeviceID": "DT342987234"
    }
    
Returns A JSON Vehicle data object
Sample Return Object
    {
        "ID": 4,
        "Description": "Electrical Truck",
        "TechID": 12,
        "TechName": "John Ramos",
        "VehicleName": "Truck 3432",
        "DeviceID": "DT873343"
    }
    
Business Rules
Any violations of these business rules result in an appropriate error message being returned to the API consumer.

DeviceID:
  • The DeviceID must be a valid device ID of a vehicle in the database.
URL base/GPS/Vehicle/GetVehicleByName
Action POST
Description Returns the Vehicle object associated with a vehicle name in the M4 database.
Parameters
Name Required? Type Description
VehicleName Yes String The vehicle name of a vehicle in the M4 database.
Sample JSON Package
    {
        "VehicleName": "VH-23434234"
    }
    
Returns A JSON Vehicle data object
Sample Return Object
    {
        "ID": 4,
        "Description": "Electrical Truck",
        "TechID": 12,
        "TechName": "John Ramos",
        "VehicleName": "Truck 3432",
        "DeviceID": "DT873343"
    }
    
Business Rules
Any violations of these business rules result in an appropriate error message being returned to the API consumer.

VehicleName:
  • The VehicleName must be a valid name of a vehicle in the database.
URL base/GPS/Vehicle/GetVehicles
Action GET
Description Returns a collection of Vehicle objects listed in the M4 database.
Returns A collection of JSON Vehicle data objects
Sample Return Object
        [
            {
                "ID": 4,
                "Description": "Electrical Truck",
                "TechID": 12,
                "TechName": "John Ramos",
                "VehicleName": "Truck 3432",
                "DeviceID": "DT873343"
            },
            {
                "ID": 5,
                "Description": "Electrical Truck",
                "TechID": 14,
                "TechName": "Sarah Smith",
                "VehicleName": "Truck 3448",
                "DeviceID": "DT873392"
            },
            {
                "ID": 5,
                "Description": "Electrical Truck",
                "TechID": 45,
                "TechName": "Jason Brown",
                "VehicleName": "Truck 2218",
                "DeviceID": "DT871392"
            }
        ]
        
URL base/GPS/Vehicle/AddVehicle
Action POST
Description Adds a new vehicle into the M4 database.
Parameters
Name Required? Type Description
VehicleName *Yes (see below) String The vehicle name of the vehicle.
DeviceID *Yes (see below) String The device ID of the vehicle.
TechID No Integer The tech ID of a technician assigned to the vehicle.
Description No String A description of the vehicle.
Sample JSON Package
    {
        "VehicleName": "VH-345344",
        "DeviceID": "DT098320423",
        "TechID": 3,
        "Description": "Secondary electrical truck"
    }
    
Returns A JSON Vehicle data object
Sample Return Object
    {
        "ID": 4,
        "Description": "Electrical Truck",
        "TechID": 12,
        "TechName": "John Ramos",
        "VehicleName": "Truck 3432",
        "DeviceID": "DT873343"
    }
    
Business Rules
Any violations of these business rules result in an appropriate error message being returned to the API consumer.

*VehicleName / *DeviceID:
  • A VehicleName or DeviceID must be supplied (you can choose to supply both, but both values cannot be null).
VehicleName:
  • The VehicleName must be unique and cannot already be assigned to another vehicle.
DeviceID:
  • The DeviceID must be unique and cannot already be assigned to another vehicle.
TechID:
  • The TechID must link to a valid technician in the M4 database.
  • The Technician cannot be assigned to more than one vehicle.

Was this article helpful?

Related Articles