1.3.0 • Published 2 months ago

webfleetconnect v1.3.0

Weekly downloads
-
License
MIT License
Repository
github
Last release
2 months ago

WebfleetConnect

Webfleet logo

Library to consume WEBFLEET.connect API.

npm version

The WEBFLEET.connect API connects software appli­ca­tions with the Webfleet fleet management solution. Via WEBFLEET.connect you can enhance the value of all types of business solutions, including routing and scheduling optimization, ERP, Transport Management System (TMS), supply chain planning, asset management, and much more.

Check also the version for:

Installation

npm install webfleetconnect

Usage

const WebfleetConnect = require('webfleetconnect')

const webfleetConnect = WebfleetConnect.create()

webfleetConnect.showObjectReportExtern()
  .then(response => console.log(response))
  .catch(error => console.error(error))

WebfleetConnect.create() returns a new Session object which has the capabilities to request info from the WEBFLEET.connect API.

The Webfleet credential are taken from the env variables WEBFLEET_CONNECT_ACCOUNT, WEBFLEET_CONNECT_USERNAME, WEBFLEET_CONNECT_PASSWORD and WEBFLEET_CONNECT_APIKEY (if you want to know more about env variables check this link).

If your system needs to work with multiple accounts or you need to specify the credentials dynamically for some other reason, you can do it this way:

const credentials = { account: 'companyName', username: 'dev', password: 'VLm5PpiZST6U', apikey: 'ZSksD88s-F7Uf' }

const webfleetConnect = WebfleetConnect.create(credentials)

When one of the methods is used, for example showVehicleReportExtern, it returns an object with the next properties:

webfleetConnect.showObjectReportExtern()
  .then(response => console.log(response))
  .catch(error => console.error(error))

response.data       // gets the data as an Array of objects
response.statusCode // gets the status code of the request
response.url        // gets the url to fetch the information from WEBFLEET.connect
response.toString() // returns the data as a string

// On get an error

error.error      // gets the error returned by WEBFLEET.connect
error.statusCode // gets the status code of the request
error.url        // gets the url to fetch the information from WEBFLEET.connect

The methods available in this library are the same that are documented in the WEBFLEET.connect docs page.

Params

In order to add params to a request is as easy as passing an object of options in the request like:

const options = { filterstring: 'ECO', objectgroupname: 'Vehiculos', ungroupedonly: true }

const response = await webfleetConnect.showObjectReportExtern(options)

Extra config

The Session object works with the default configuration:

{ lang: 'en', outputformat: 'csv', useISO8601: false, useUTF8: false }

but you can change the default configuration when you create the object:

const params = {
  account:  'companyName',
  username: 'dev',
  password: 'VLm5PpiZST6U',
  apikey:   'ZSksD88s-F7Uf',
  lang: 'de',
  outputformat: 'json'
}

const webfleetConnect = WebfleetConnect.create(params)

Get the URL only

You can get the full URL to request without actually connection to Webfleet Connect API by using the function getURL

const options = { filterstring: 'ECO', objectgroupname: 'Vehiculos', ungroupedonly: true }

const url = await webfleetConnect.getUrl('showObjectReportExtern', options)

console.log(url)

Methods list

Mesage queues:

Objects:

Orders:

Messages:

Drivers:

Addresses:

Events:

Trips and working times:

Miscellaneous reports:

Geocoding and routing:

Configuration and security:

User management:

Vehicle maintenance:

Reporting:

Areas:

LINK.connect:

Plugins:

1.3.0

2 months ago

1.2.0

6 months ago

1.1.0

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago