Introduction

We have created a javascript library that will enable users to access our system in a simple manner. Please click on the following link to download the library:


DOWNLOAD

Usage

After downloading the javascript library, you can include it into your HTML page with script tag. For example:


              
                <script type="text/javascript" src="javascripts/logistricsservicesapi.min.js" />
              
            

Once the library has been included, you will need to instantiate a instance of the library class. You'll also need to set the authentication and the unique identifier for your device. This can be done like this:


              
                var lsLib = new LogistricsService();
                lsLib.setImei("Enter IMEI Here");
                lsLib.setAuthentication("Email", "Password");
              
            

From here, you can start tracking by calling the startTracking function, or directly set the location of the device by calling setLocation. You can also query for a location using the getLocation function.



Reference

LogistricsService Class


Constructor
LogistricsService() Creates a new instance of the logistrics service object

Methods
sendAuth(username, password, Success callback, Error callback) Sends a authentication message to the server to authenticate the user.
getLocation(imei, Success callback, Error callback) Gets the current location of the requested device
setImei(imei) Sets the identifier for this device.
getImei() Gets the current identifier for this device
startTracking(Success callback, Error callback) Starts the device tracking for location. A periodic GPS message will be sent to the server.
stopTracking() Stops the device tracking.

Introduction

The Android Library implements our HTTP API in order to make integration simpler. You can download it here:


DOWNLOAD

Installation

Once you have downloaded the AAR library, you can copy it to the libs folder of your project.




You will then need to add the aar file dependancy to your build.gradle file located within your app folder. You will also need to add dependancy to the Google Play Services.


              
                dependencies {
                    compile (name: 'logistricsserviceapi-release', ext:'aar')
                    compile 'com.google.android.gms:play-services:11.0.4'
                    compile 'com.google.android.gms:play-services-maps:11.0.4'
                }
              
            

You will also need to tell Gradle where to find the library by adding the following section to your build.gradle file within your app folder.


              
                repositories {
                  flatDir {
                      dirs 'libs'
                  }
                }
              
            

Finally, the library will need you to add the following permissions to your AndroidManifest.xml file.


              
                <uses-permission android:name="android.permission.INTERNET"/>
                <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
                <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
                <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
              
            


Usage

For usage, you will need to instantiate a instance of the LogistricsService class and passing it the current activity. Once the instance has been created, you will need to authenticate by setting the credentials with the setAuthentication method and then sending a authentication request via the sendAuthReq method. Once that has been done successfully, you can start and stop the GPS collection with the start and stop methods for the class instance. See below for some sample code on how to get the service started:


              
                LogistricsService ls = new LogistricsService(this);
                ls.setAuthentication("username", "password");
                ls.sendAuthReq();
                ls.start();
              
            

Introduction

The following will list the API currently available for our website. All of our requests will require the user request for a API key via the ‘Request API key’ call. HTTP requests made to our website must be using the POST method.


Methods

Request API Key

Path: api/request_api_key

Info: Requests an authentication token for future requests. This token expires after 1 week and will need to be requested again

Parameters:

Name Description
email Email used to login
password Password to authenticate

Return Values:
Success:
Will return the API key as text in the body of the response
Error:
Status 400 for missing email or password
Status 401 for invalid/inactive user


Clear API Key

Path: api/clear_api_key

Info: Invalidates a given API key

Parameters:

Name Description
token Authentication Token

Return Values:
Success:
Will return "OK"
Error:
Status 400 for missing token
Status 401 for invalid/inactive user


Get Location

Path: api/request_location

Info: Requests the last known location of the requested unit.

Parameters:

Name Description
token Authentication Token
unit_id ID of the unit

Return Values:
Success:
Will return the results in JSON format with the following parameters:

Name Description
id ID of the unit
time Time when the location was obtained
latitude Latitude of the location
longitude Longitude of the location
Error:
Status 400 for missing token or unit not found
Status 401 for invalid/inactive user or invalid token


Set Location

Path: api/add_location

Info: Adds a location point for a unit

Parameters:

Name Description
token Authentication Token
imei IMEI of the unit
time Time in seconds since epoch
odo Odometer reading
speed Speed in mph
heading GPS Heading
lat latitude
lng longitude

Return Values:
Success:
Will return 200 OK with a body of "OK"
Error:
Status 400 for missing token or unit not found
Status 401 for invalid/inactive user or invalid token