# spendesk-collect

> A Node.js library for Spendesk Collect

Latest version **0.0.15** (published 2019-05-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install spendesk-collect
pnpm add spendesk-collect
yarn add spendesk-collect
bun add spendesk-collect
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.15 |
| Published | 2019-05-18 |
| First published | 2018-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 8.11.x |
| Dependencies | 9 |
| Unpacked size | 15.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Auree Aubert |
| Maintainers | aureeaubert |

## Links

- npm: https://www.npmjs.com/package/spendesk-collect
- Repository: git@github.com:Spendesk/collect-node
- npm.io page: https://npm.io/package/spendesk-collect

## Dependencies (9)

- [kue](https://npm.io/package/kue.md) ^0.11.6
- [cors](https://npm.io/package/cors.md) ^2.8.5
- [delay](https://npm.io/package/delay.md) ^4.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [express](https://npm.io/package/express.md) ^4.16.4
- [winston](https://npm.io/package/winston.md) ^3.1.0
- [puppeteer](https://npm.io/package/puppeteer.md) ^1.13.0
- [superagent](https://npm.io/package/superagent.md) ^4.0.0
- [body-parser](https://npm.io/package/body-parser.md) ^1.18.3

## Recent versions

- 0.0.15 (latest) — 2019-05-18
- 0.0.14 — 2019-04-17
- 0.0.13 — 2019-04-17
- 0.0.12 — 2019-04-16
- 0.0.11 — 2019-04-05
- 0.0.10 — 2019-03-25
- 0.0.9 — 2019-03-25
- 0.0.8 — 2019-02-18
- 0.0.7 — 2019-02-18
- 0.0.6 — 2019-02-15
- 0.0.5 — 2019-01-07
- 0.0.4 — 2018-12-26
- 0.0.3 — 2018-12-26
- 0.0.2 — 2018-12-15
- 0.0.1 — 2018-12-03

## README

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

# Spendesk Collect Node

## Installation

```
yarn add spendesk-collect
```

## Spendesk Collect Collector

```javascript
const collector = new SpendeskCollect.Collector(PORT);
collector.startApp();
```

The collector module launches automatically an server instance and exposes what's necessary to develop a collector.

- `auth` action: returns if ship settings are valids or not
- `collect` action: called to extract invoices from a supplier
- `description`: redirects to `./DESCRIPTION.md`, collector description
- `manifest`: redirects to `./manifest.json`
- `assets/*`: redirects to `./assets` that contains the list of assets needed like logo (`logo.png`).

context is inialized for `status` and `collect` actions.

```javascript
module.exports = async (ship, client, captchaSolver) => {
  // client is SpendeskCollect.Client instance
  // ship is an object that contains information { settings, nextCollectAt, currentSettingsStepTag }
  // captchaSolver is a instance of a captcha solver (see below for more information)
}
```

## Spendesk Collect Client

```javascript
const client = new SpendeskCollect.Client("SHIP_TOKEN");
```

This Client API allows to connect with the Spendesk Collect infrastructure. Here the list of methods available: 

- `done(status, metadata)`: returns to broker the status of the ship
  - `status` is an object: `{ label: ok|error, type: auth|collect }`
  - `metadata` is an optional object: `{ currentSettingsStepTag }`
- `invoices.create(file, metadata, fileOptions)`: uploads a new invoice
  - `file` needs a path or a buffer
  - `metadata` is an object that contains invoice metadata. Requested attributes: `identifier`, `dueAt`, `amount`, `currency`
  - `fileOptions` is optional if `file` is a path otherwise it needs to follow this pattern: `{ contentType, filename }`
- `logger`: winston logger (`error`, `warn`, `info`, `verbose`, `debug`, `silly`)


## Spendesk Collect Captcha Solver

```javascript
const captchaSolver = new SpendeskCollect.CaptchaSolver("CAPTCHA_SOLVER_TOKEN");
```

List of methods availables:

- `solveReCaptcha(googlekey, pageurl, proxy, proxytype)`: method to solve google recaptcha
  - `googlekey` corresponds to the captcha key. You can find it in the src of the iframe https://www.google.com/recaptcha/api2/anchor?ar=1&k=GOOGLE_KEY&co=XXX&hl=en&v=VVV&size=normal&cb=YYY
  - `pageurl` corresponds to the website url where the captcha is
  - (optional) `proxy` allows you to add a proxy url if wanted
  - (optional) `proxytype`

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