# adp-connection

> ADP Connection Library

Latest version **2.1.1** (published 2018-03-23) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install adp-connection
pnpm add adp-connection
yarn add adp-connection
bun add adp-connection
```

## 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 | 2.1.1 |
| Published | 2018-03-23 |
| First published | 2016-02-19 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 68.6 KB |
| Known vulnerabilities | 0 (+8 in 2 direct dependencies) |
| Install scripts | no |
| Author | ADP Marketplace |
| Maintainers | joshsteverson |

## Links

- npm: https://www.npmjs.com/package/adp-connection
- Repository: https://github.com/adplabs/adp-connection-node
- Homepage: https://github.com/adplabs/adp-connection-node#readme
- Issues: https://github.com/adplabs/adp-connection-node/issues
- npm.io page: https://npm.io/package/adp-connection

## Dependencies (6)

- [config](https://npm.io/package/config.md) ^1.19.0
- [request](https://npm.io/package/request.md) ^2.67.0
- [adp-core](https://npm.io/package/adp-core.md) ^1.0.0
- [mongoose](https://npm.io/package/mongoose.md) ^4.3.7
- [node-uuid](https://npm.io/package/node-uuid.md) ^1.4.7
- [underscore](https://npm.io/package/underscore.md) ^1.8.3

## Recent versions

- 2.1.1 (latest) — 2018-03-23
- 2.1.0 — 2017-12-21
- 2.0.2 — 2017-07-18
- 2.0.1 — 2017-07-18
- 2.0.0 — 2016-08-18
- 1.1.1 — 2016-05-23
- 1.1.0 — 2016-03-24
- 1.0.11 — 2016-03-23
- 1.0.10 — 2016-03-07
- 1.0.9 — 2016-03-02
- 1.0.8 — 2016-02-23
- 1.0.7 — 2016-02-23
- 1.0.6 — 2016-02-22
- 1.0.5 — 2016-02-22
- 1.0.4 — 2016-02-22
- … 4 more at https://npm.io/package/adp-connection/versions

## README

# ADP Connection Library

### Description
The ADP Connection library wraps the authorization (oAuth 2.0) connection steps for connecting to ADPs API gateway.

[![npm version](https://badge.fury.io/js/adp-connection.svg)](https://badge.fury.io/js/adp-connection)

### Previous version support
`npm install adp-connection@1.1.1`

### Installation
```sh
$ npm install adp-connection
```

# Usage 
## [API Docs & Examples](docs)

### Create Client Credentials ADP Connection
```js
import adpConnection from 'adp-connection';

const connectionOpts = {
    clientId: '1234567890',
    clientSecret: 'ABC-DEF-GHI-JKL',
    granttype: 'client_credentials',
    sslCertPath: './certs/cert.pem',
    sslKeyPath: './certs/cert.key'
};
const connectionComplete = err => {
    // Use adp-core to do all the things...
};
const conn = adpConnection.createConnection(connectionOpts);
conn.connect(connectionComplete);
```

### Create Authorization Code ADP Connection

```js
import adpConnection from 'adp-connection';

const connectionOpts = {
    clientId: '1234567890',
    clientSecret: 'ABC-DEF-GHI-JKL',
    granttype: 'authorization_code',
    sslCertPath: './certs/cert.pem',
    sslKeyPath: './certs/cert.key',
    callbackUrl: 'https://myapp.domain.com/callback'
};
const conn = adpConnection.createConnection(connectionOpts);

// in an express app...
res.redirect(conn.getAuthorizationRequest());

// Authorization endpoint will respond to `https://myapp.domain.com/callback` with `code` query parameter
const authorizationCode = req.query.code;

// Set authorizationCode in connection options. 
connectionOpts.authorizationCode = authorizationCode;

// createConnection with authorizationCode set.
const conn = adpConnection.createConnection(connectionOpts);
const connectionComplete = err => {
    // connected ...
};
conn.connect(connectionComplete);
```

# Debug
Enable debugging by setting the `NODE_DEBUG` environment variable.

```sh
$ export NODE_DEBUG=adp-connection,adp-core
```

# Contributing
To contribute to the library, please generate a pull request. Before generating the pull request, please insure the following:
1. Appropriate unit tests have been updated or created.
2. Code coverage on unit tests must be no less than 100%.
3. Your code updates have been fully tested and linted with no errors. 
4. Update README and API documentation as appropriate.

# Sample Client
A sample client is provided to demonstrate usage of the libraries. The sample client connects to a sandbox environment hosted by ADP, and comes preconfigured with the necessary credentials and certificates to connect to the sandbox server.

### Authorization Code Example
```sh
$ git clone https://github.com/adplabs/adp-connection-node.git
$ cd adp-connection-node
$ npm install
$ node authorizationCodeExample
```
### Client Credentials Example
```sh
$ git clone https://github.com/adplabs/adp-connection-node.git
$ cd adp-connection-node
$ npm install
$ node clientCredentialsExample
```

# Test Execution
```sh
$ npm test
```

# Code Coverage
```sh
$ npm run coverage
```

# Lint
```sh
$ npm run lint
```

# License 
[Apache 2](http://www.apache.org/licenses/LICENSE-2.0)

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