npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@davidsabine/myadmin-geotab-api

v2.0.2

Published

Forked from https://github.com/asaucedormz/myadmin-geotab-api, then modified to use axios instead of old version of node-fetch.

Downloads

2

Readme

myadmin-geotab-api

Unofficial nodejs client for myadmin.geotab.com.

  • https://myadmin.geotab.com/sdk#/api-reference

Installation

Using yarn:

$ yarn add @davidsabine/myadmin-geotab-api

Using npm:

$ npm i @davidsabine/myadmin-geotab-api

Getting Started

The order of operations is:

  1. Import myadmin-geotab-api in your code.
import MyAdminAPI from '@davidsabine/myadmin-geotab-api'
  1. Create an instance of the class object:
const myAPI = new MyAdminAPI({<authentication parameters here>})
  1. Tell that new instance to authenticate with GeoTab's server. This returns an object containing credentials, sessionId, apiKey, etc.
myAPI.authenticate()
  1. Then use myAPI.call() to perform actions against GeoTab's service. The return values will vary depending which method name you send to GeoTab's service:
myAPI.call(<a method name>, {<parameters related to that method>})

Examples:

Using Async/Await Promises

import MyAdminAPI from '@davidsabine/myadmin-geotab-api'

(async function main() {
	const username = process.env.YOURUSERNAME
	const password = process.env.YOURPASSWORD
	try	{
		const api = new MyAdminAPI({
			username,
			password,
			uri: 'https://myadminapitest.geotab.com/v2/MyAdminApi.ashx'
		})
		const authData = await api.authenticate()
		const result = await api.call(`GetCountries`, {})
		if(result.error) {
			console.log(result, `geotab responded with an error message`)
		} else {
			console.log(result, `the call was successful`)
		}
	} catch (error) {
		console.log(error, `an error was thrown in your code`)
	}
})()

Using Promises then catch

import MyAdminAPI from '@davidsabine/myadmin-geotab-api'

(async function main() {
	const username = process.env.YOURUSERNAME
	const password = process.env.YOURPASSWORD
	const api = new MyAdminAPI({
		username,
		password,
		uri: 'https://myadminapitest.geotab.com/v2/MyAdminApi.ashx'
	})
	api
	.authenticate()
	.then(() => {
		console.log(`You are authenticated!`)
		api.call('GetCountries', {})
		.then((theListofCountries) => {
			console.log(theListofCountries, `the call was successful`)
		})
		.catch((err) => {
			console.log(err, `geotab responded with an error message`)
		})
	})
	.catch((err) => {
		console.log(err, `an error was thrown in your code`)
	})
})()

Notes for users of previous version: <=0.1.2

New method names are available, old method names still supported

We felt it redundant to use 'Async' in the function name. New method names are:

.authenticate()
.call()

The old function names are still supported. You should not have to change any of your code.

.authenticateAsync()
.callAsync()

Improved error handling for post() method

This may break your previous code. And note that post() is used by callAsync().

Previously, if something went wrong during the HTTP call to GeoTab's service, post() (and thus callAsync()) would throw an exception.

The new implementation differentiates between internal and intended exceptions. (See notes on this page, https://mswjs.io/docs/recipes/mocking-error-responses.) As per general guidance, the new implementation treats an error response (from the fetch promise) as an actual response not an exception.

If you implement call() or post() incorrectly, an exception will occur. But if you implement those methods correctly and something goes wrong during the HTTP call to GeoTab's server, you should now expect a JSON response with an error message. The JSON response looks like this:

{
	result: {
		error: {
			code: an error code,
			message: an error message,
			name: a name of error, example: 'MissingMethodException'
		}
	}
}

See error handling in examples above.