# @inaza/motorjs

> Inaza JS SDK

Latest version **0.1.0-alpha** (published 2022-12-08) · 0 weekly downloads

## Install

```sh
npm install @inaza/motorjs
pnpm add @inaza/motorjs
yarn add @inaza/motorjs
bun add @inaza/motorjs
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0-alpha |
| Published | 2022-12-08 |
| First published | 2022-12-08 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 750.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | inaza-adesh |

## Links

- npm: https://www.npmjs.com/package/@inaza/motorjs
- Repository: https://github.com/nsurely/motorJS
- Homepage: https://github.com/nsurely/motorJS#readme
- Issues: https://github.com/nsurely/motorJS/issues
- npm.io page: https://npm.io/package/@inaza/motorjs

## Dependencies (5)

- [dotenv](https://npm.io/package/dotenv.md) ^16.0.3
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.7
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.19.0
- [regenerator-runtime](https://npm.io/package/regenerator-runtime.md) ^0.13.10
- [react-native-storage](https://npm.io/package/react-native-storage.md) ^1.0.1

## Recent versions

- 0.1.0-alpha (latest) — 2022-12-08

## README

# motorJS

motorJS provides a simple interface to the Inaza Motor APIs.

The goal of motorJS and other Inaza libraries and SDKs are to provide a layer of abstraction above the core Inaza services. By doing so, new solutions can be created in a shorter period of time as common areas such as auth, API routing and data parsing is taken care of.

## Installation

### Option 1: Importing the package in your frontend/backend project

Install the motorJS package using npm:

```console
foo@bar:~$ npm install @inaza/motorjs
```

Import motorJS

```js
import motorJS from '@inaza/motorjs';
```

### Option 2: Importing it directly via CDN

If your web based project does not support importing packages, you can still use motorJS by including it as an external script in your project

```html
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>Example HTML</title>
		<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/nSurely/motorJS@v0.1.0-alpha/dist/web/motorjs.min.js"></script>
	</head>
	<body>
		...
	</body>
	<script type="text/javascript">
		// You can make use of motorJS obj
	</script>
</html>
```

## Usage

```js
// Import the motorJS object from the package
import motorJS from '@inaza/motorjs';

// Optional - Import AsyncStorage if you are using the MotorJS sdk in a react native project.
import AsyncStorage from "@react-native-async-storage/async-storage";

// Initialise Auth
let auth = new motorJS.Auth({
	orgId: "<< your-org-id >>",
	region: "<< your-region >>",
	email: "<< some-user@org.com >>",
	password: "<< $tr0ngP@ssw0rd >>",
	accountType: "<< user or driver >>",
});

// Login
auth.login().then((res) => {
	console.log(res);
});

// Initialise the Motor SDK and pass the Auth object
let motor = new motorJS.Motor({
	orgId: "<< your-org-id >>",
	region: "<< your-region >>",
	// Pass AsyncStorage for react-native.
	// Else for any web-based project that runs in a browser, pass window.localStorage. eg. storage: window.localStorage
	// You can keep this as null, however data such as bearerToken and refershToken will not be persisted when application is closed and re-opened.
	storage: AsyncStorage,
	// Pass the auth instance
	auth: auth,
});

motor.orgSettings().then((res) => {
	console.log(res);
});

motor
	.getDriver({
		driverId: '<< driver-id >>',
	})
	.then((driver) => {
		console.log(driver.fullName());
	});
```

# License

Copyright (c) 2022, nSurely Limited trading as Inaza
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
   must display the following acknowledgement:
   This product includes software developed by Inaza.
4. Neither the name of Inaza nor the
   names of its contributors may be used to endorse or promote products
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

---
_Source: https://npm.io/package/@inaza/motorjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
