1.0.0 • Published 7 years ago

trafficlive v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

trafficlive

A wrapper for the TrafficLive API.

Install via NPM!

npm install trafficlive

Example usage

'use strict'
var TrafficLive = require('trafficlive');

var tl = new TrafficLive({
    email: 'YOUR_EMAIL_ADDRESS',
    token : 'YOUR_API_TOKEN',
    pageSize: 250 //max 500
});
//All Employees
tl.employees.all(function(response) {
  response.data.map(function(item) {
    console.log(item)
  })
})

//Single Employee
tl.employees.one(12345,function(response){
    console.log(response);
});

Supported methods

employees

  • employees.all(callback)
  • employees.one(employeeId, callback)
  • employees.find(filter, callback)

clients

  • clients.all(callback)
  • clients.one(clientId, callback)
  • clients.find(filter, callback)

entries

  • entries.all(callback)
  • entries.one(entryId, filter, callback)
  • entries.find(filter, callback)

jobs

  • jobs.all(callback)
  • jobs.one(jobId, callback)
  • jobs.allDetails(callback)
  • jobs.oneDetail(jobId, callback)

departments

  • departments.all(callback)
  • departments.one(departmentId, callback)

invoices

  • invoices.all(callback)
  • invoices.one(invoiceId, callback)

Filtering

Criteria filtering enables you to apply filters to your API requests in order to limit your results to more relevant data. The format for applying a criteria filter is:

Property|Comparator|Value

Property refers to the property of the object in the list such as the jobNumber or dateModified for example. Value refers to the value you want to compare to. And comparator refers to one of the following types (some of them have two forms):

comparatorexamplesdescription
EQUAL / EQjobNumber|EQ|"J55"Equality comparator
NOT_EQUAL / NEjobNumber|NOT_EQUAL|"J55"Not equality comparator
LIKEjobStateType|LIKE|"progress"Like case insensitive comparator
LIKE_CASE_SENSITIVEjobStateType|LIKE_CASE_SENSITIVE|"PROGRESS"Like case sensitive comparator
NOT_LIKEjobStateType|NOT_LIKE|"progress"Not like case insensitive comparator
NOT_LIKE_CASE_SENSITIVEjobStateType|NOT_LIKE_CASE_SENSITIVE|"PROGRESS"Not like case sensitive comparator
LESS_THAN / LTid|LESS_THAN|50Less than comparator
GREATER_THAN / GTid|GT|50Greater than comparator
LESS_OR_EQUAL / LEid|LE|50Less or equal comparator
GREATER_OR_EQUAL / GEid|GREATER_OR_EQUAL|50Greater or equal comparator
INid|IN|1,2,3,4,10In comparator
IN_ALLid|IN_ALL|1,2,3,4,10In all comparator
Example Filters
//Find employee by username
tl.employees.find('userName|EQ|"john.doe@example.com"', function(response){
   console.log(response);
});

//Find client using partial name
tl.clients.find('name|LIKE|"Acme%"', function(response){
   console.log(response);
});

//Find employees who started after January 2015
tl.employees.find('filter=dateCreated|GT|"2015-01-01T00:00:00.000+0000"', function(response){
   console.log(response);
});

//
1.0.0

7 years ago

0.3.6

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.0

8 years ago

0.0.4

8 years ago

0.0.2

8 years ago