# @cumulus-consulting/mfgx-io-api-client

> Client package for api.mfgx.io

Latest version **3.3.0** (published 2020-04-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cumulus-consulting/mfgx-io-api-client
pnpm add @cumulus-consulting/mfgx-io-api-client
yarn add @cumulus-consulting/mfgx-io-api-client
bun add @cumulus-consulting/mfgx-io-api-client
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.3.0 |
| Published | 2020-04-10 |
| First published | 2018-03-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 19 |
| Unpacked size | 97.9 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| Author | Cumulus Consulting, LLC |
| Maintainers | lmenard |

## Links

- npm: https://www.npmjs.com/package/@cumulus-consulting/mfgx-io-api-client
- npm.io page: https://npm.io/package/@cumulus-consulting/mfgx-io-api-client

## Dependencies (19)

- [qs](https://npm.io/package/qs.md) ^6.9.0
- [btoa](https://npm.io/package/btoa.md) ^1.2.1
- [axios](https://npm.io/package/axios.md) ^0.19.0
- [ramda](https://npm.io/package/ramda.md) ^0.26.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [graphql](https://npm.io/package/graphql.md) ^0.13.2
- [apollo-link](https://npm.io/package/apollo-link.md) ^1.2.13
- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.0.4
- [graphql-tag](https://npm.io/package/graphql-tag.md) ^2.10.1
- [apollo-client](https://npm.io/package/apollo-client.md) ^2.6.4
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.5.5
- [apollo-link-ws](https://npm.io/package/apollo-link-ws.md) ^1.0.19
- [apollo-link-http](https://npm.io/package/apollo-link-http.md) ^1.5.16
- [apollo-utilities](https://npm.io/package/apollo-utilities.md) ^1.3.2
- [apollo-link-retry](https://npm.io/package/apollo-link-retry.md) ^2.2.15
- [apollo-link-context](https://npm.io/package/apollo-link-context.md) ^1.0.19
- [apollo-upload-client](https://npm.io/package/apollo-upload-client.md) ^11.0.0
- [apollo-cache-inmemory](https://npm.io/package/apollo-cache-inmemory.md) ^1.6.3
- [subscriptions-transport-ws](https://npm.io/package/subscriptions-transport-ws.md) ^0.9.16

## Recent versions

- 3.3.0 (latest) — 2020-04-10
- 3.2.0 — 2020-03-17
- 3.1.1 — 2020-03-12
- 3.1.0 — 2020-02-27
- 3.0.0 — 2019-10-31
- 2.6.0 — 2019-10-01
- 2.5.0 — 2019-09-17
- 2.4.2 — 2019-09-04
- 2.4.1 — 2019-08-19
- 2.4.0 — 2019-07-24
- 2.3.0 — 2019-07-11
- 2.2.6 — 2019-06-28
- 2.2.5 — 2019-06-05
- 2.2.4 — 2019-05-13
- 2.2.3 — 2019-04-26
- … 21 more at https://npm.io/package/@cumulus-consulting/mfgx-io-api-client/versions

## README

# @cumulus-consulting/mfgx-io-api-client
API client designed to simplify use of MFGx APIs. Works in Node and browser environments.

### Install via npm
`npm install --save @cumulus-consulting/mfgx-io-api-client`

### Quick Start (ES6)
```js
import { apiClient } from '@cumulus-consulting/mfgx-io-api-client';

apiClient.setBaseUrl('https://api.instance.mfgx.io');

await apiClient.signIn({
	email: 'test@email.com',
	password: 'password'
});

const { data: { userMany } } = await apiClient.graphQL({
	query: `{
	  userMany {
	    id
	    email
	  }
	}`
});
```

## Documentation
### Exports
```js
import { 
  // Pre-constructed API client instance with default options.
  apiClient, 
  // Main API client class, used to construct a new instance or extend the client.
  MFGxClient, 
  // Map of MFGx APIs; see APIs section below
  APIS 
} from '@cumulus-consulting/mfgx-io-api-client'; 
```

### Constructor Options
```js
{
  // Base MFGx API url (i.e. 'https://api.instance.mfgx.io').  Can also be set
  // or changed via the setBaseUrl function on a client instance.
	url,
	// Promise-returning functions to get, set, and clear a token from storage.
	// Default behavior is to store tokens in a closure; override provides the
	// ability to store tokens in persistent or secure storage.
	tokenStorage: {
		get,
		set,
		clear,
	},
	// When true, token expiration 401 errors will be automatically caught, the
  // token will attempt to be refreshed, and the request retried.  Defaults to
  // false.
	autoRefreshToken: false,
  // Callback called when errors occur, in addition to function throws.  
  // Can be used to display error UI or for global error logging.
	onError,
	// Promise-returning callback used to request device information when
	// needed by the client.  Device information returned should match the
	// format of the DeviceInformationInput type in the signIn API.
	onRequestDeviceInformation,
}
```

### APIs
```js
{
	// Primary graphQL sign-in API.
	SIGN_IN:  '/signIn',
	// Main graphQL application API.
	GRAPHQL:  '/graphql',
	// Metadata graphQL API for system data.
	METADATA:  '/metadata',
	OCR: {
		// REST API to execute raw OCR requests; only applicable if OCR is enabled.
		RAW:  '/ocr/raw'
	},
	DOCUMENTS: {
		// REST API to generate PDF documents.
		GENERATE:  '/documents/generate'
	},
	WEBHOOKS: {
		// REST API to publish into a user-defined webhook.
		UDT:  '/webhooks/udt'
	},
	INTEGRATION: {
		// REST API for standardized requests to external systems.
		ENDPOINT:  '/integration/endpoint'
	},
	// Transformation graphQL API for executing MFGx scripts.
	TRANSFORMATION:  '/transformation'
}
```

---
_Source: https://npm.io/package/@cumulus-consulting/mfgx-io-api-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
