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

mg-api-js

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mg-api-js

A MyGeotab API wrapper for clientside javascript

1.0.0
Version published
Weekly downloads
7.1K
10.96%
Maintainers
1
Weekly downloads
 
Created

mg-api-js

A MyGeotab API wrapper for clientside javascript

Installation

$ bower install --save mg-api-js

Usage

var api = GeotabApi(function (authenticateCallback) {
        
        // Put handling code here that executes when:
        //      a) We don't have credentials yet (first page load)
        //      b) The credentials have expired (password changed or server moved)
        //      c) You've called "api.forget()"
        // For example, show the login dialog if it is hidden, or prompt the user to enter their credentials
        
        authenticateCallback('server', 'database', 'userName', 'password', function(err) {
            console.error(err);
        });

    }, {
        // Overrides for default options
        rememberMe: false
    });

// Sample API invocation retrieves a single "Device" object
api.call('Get', {
    typeName: 'Device',
    resultsLimit: 1
}, function (result) {
    if (result) {
        console.log(result);
    }
}, function (err) {
    console.error(err);
});

API

call

Make a request to the database

api.call('Get', {
    typeName: 'Device',
    resultsLimit: 1
}, function (result) {
    if (result) {
        console.log(result);
    }
}, function (err) {
    console.error(err);
});

multiCall

Perform multiple queries against the database in a single HTTPS request

api.multiCall([
    ['Get', {
    typeName: 'Device',
    resultsLimit: 1
}],['Get', {
    typeName: 'User',
    resultsLimit: 1
}]
], function (result) {
    if (result) {
        console.log(result);
    }
}, function (err) {
    console.error(err);
}))

forget

Clears credentials and the credential store.

api.forget();

getSession

Retrieves the API user session.

api.getSession(function (session) {
    console.log(session);
});

License

MIT

FAQs

Package last updated on 05 Jun 2018

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