New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mg-api-node

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mg-api-node

Nodejs client for the MyGeotab API

  • 1.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
857
decreased by-24.89%
Maintainers
1
Weekly downloads
 
Created
Source

This project has been deprecated. Please use mg-api-js.

mg-api-node

Unofficial nodejs client for the MyGeotab API

Getting Started

$ npm install mg-api-node --save

Usage

var api = new API(userName, password, database);

api.authenticate(function(err, data) {

  if(err){
    console.log('Error', err);
    return;
  }

  api.call('Get', {
    typeName: 'User',
    search: {
      name: data.userName
    }
  }, function(err, data) {

    if(err){
      console.log('Error', err);
      return;
    }

    console.log('User', data);

  });

});
HTTP Timeout

If you need to handle potential slow HTTP requests, you can access request.setTimeout by passing an optional timeout (ms) and timeoutCallback to api.call() and api.multicall():

var api = new API(userName, password, database, server, {ssl: false}, sessionId);

// Timeout (ms) and TimeoutCallback
api.call('Get', {
  typeName: 'User',
  resultsLimit: 1
}, function(err, data) {
  if(err){
    console.log('Error', err);
    return;
  }
  console.log('User', data);
}, 10000, function(){
    console.log('Timeout');
});

// Just Timeout
api.call('Get', {
  typeName: 'User',
  resultsLimit: 1
}, function(err, data) {
  if(err){
    console.log('Error', err);
    return;
  }
  console.log('User', data);
}, 10000);

Session ID

It's also possible to supply session ID and direct server to re-use a session ID. This avoids costly authentication.

var api = new API(userName, password, database, server, options, sessionId);

api.call('Get', {
  typeName: 'User',
  resultsLimit: 1
}, function(err, data) {

  if(err){
    console.log('Error', err);
    return;
  }

  console.log('User', data);

});

Running Tests

$ npm install -g mocha
$ npm install
$ mocha

Keywords

FAQs

Package last updated on 19 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc