# intacct-api

> Intacct API Access Library

Latest version **0.3.0** (published 2020-03-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install intacct-api
pnpm add intacct-api
yarn add intacct-api
bun add intacct-api
```

## 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.3.0 |
| Published | 2020-03-13 |
| First published | 2016-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 8 |
| Unpacked size | 98.6 KB |
| Known vulnerabilities | 0 (+5 in 4 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Julian Lannigan |
| Maintainers | mrlannigan |

## Links

- npm: https://www.npmjs.com/package/intacct-api
- Repository: https://github.com/GoodwayGroup/intacct-api
- Homepage: https://github.com/GoodwayGroup/intacct-api#readme
- Issues: https://github.com/GoodwayGroup/intacct-api/issues
- npm.io page: https://npm.io/package/intacct-api

## Dependencies (8)

- [joi](https://npm.io/package/joi.md) ^9.2.0
- [hoek](https://npm.io/package/hoek.md) ^4.1.0
- [uuid](https://npm.io/package/uuid.md) ^3.0.0
- [wreck](https://npm.io/package/wreck.md) ^10.0.0
- [xml2js](https://npm.io/package/xml2js.md) ^0.4.17
- [bluebird](https://npm.io/package/bluebird.md) ^3.4.6
- [xmlbuilder](https://npm.io/package/xmlbuilder.md) ^8.2.2
- [lodash.flatten](https://npm.io/package/lodash.flatten.md) ^4.4.0

## Recent versions

- 0.3.0 (latest) — 2020-03-13
- 0.2.0 (beta) — 2017-03-16
- 0.2.1 — 2017-04-06
- 0.1.3 — 2016-12-06
- 0.1.0 — 2016-12-06

## README

# intacct-api

[![CircleCI](https://img.shields.io/circleci/project/github/GoodwayGroup/intacct-api.svg)](https://circleci.com/gh/GoodwayGroup/intacct-api)
[![Codecov](https://img.shields.io/codecov/c/github/GoodwayGroup/intacct-api.svg)](https://codecov.io/github/GoodwayGroup/intacct-api)

## IntacctApi(options)

### options

* auth
    * senderId
    * senderPassword
    * [sessionId] - required if missing userId
    * [userId] - cannot be used with sessionId
    * [companyId] - required if userId given
    * [password] - required if userId given
* [controlId] - defaults to v1 uuid
* [uniqueId] - boolean
* [dtdVersion] - defaults to '3.0'

### .request(...controlFunctions)

Make a request to Intacct's API to fulfill the given control functions. You can provide arrays of control functions via many arguments and/or single array. See the following examples:

```javascript
const api = new IntacctApi({ ... });

const cid1 = api.inspect({ object: 'PROJECT' });
const cid2 = api.inspect({ object: 'VENDOR' });

// With a single array
const singleArray = await api.request([cid1, cid2]);

// With arguments
const withArgs = await api.request(cid1, cid2);

// Mixed arguments
const mixedArgs = await api.request(cid1, [cid2]);
```

#### Request Result

There are a couple ways to retrieve the results from the control functions: 1) from the return of the `request` function call or 2) from the reference of the control function you passed into the `request` call.

##### Invocation Return

* functions - object hash of control functions keyed by control Function's control id
* payload - converted payload from xml
* rawPayload - raw payload string

## ControlFunction Class

It's exported from the module as `ControlFunction`.

### constructor(name, params = {}, controlId = null, parse = true)

Sets up a control function. It is recommended that you use one of the static factory methods.

### .get([path])

If path is given, [hoek.reach](https://github.com/hapijs/hoek/blob/master/API.md#reachobj-chain-options) is used to retrieve the desired property. If path isn't given, the entire `this.data` variable is returned.
```javascript
// EXAMPLE using ARINVOICE
const cid1 = IntacctApi.readByQuery({ object: 'ARINVOICE', pagesize: 1 });
const result1 = await obj.request(cid1);
let invoices = cid1.get('arinvoice');
```
### .isSuccessful()

Returns a boolean of the contextual control function's resulting success.

### .assignControlId(controlId = null)

Assigns or generates a control id. Caution to not duplicate control ids, duplicate id's will result in a thrown error.

## Static Functions

All static functions return an instance of the ControlFunction class with the name defined by the static function's name. All static functions have the same signature: `(params, controlId = null, parse = true)`

Refer to [Intacct's API Documentation](https://developer.intacct.com/api/) for how to understand the parameters needed to make these functions work.

* .consolidate(...)
* .create(...)
* .delete(...)
* .getAPISession(...)
* .getUserPermissions(...)
* .inspect(...)
* .installApp(...)
* .read(...)
* .readByName(...)
* .readByQuery(...)
* .readMore(...)
* .readRelated(...)
* .readReport(...)
* .readView(...)
* .update(...)

## Static Function: readMore

This static function is special in that, instead of passing a parameters object to it, you can pass it a successful ControlFunction. This is important because to paginate using Intacct's API, you have to pass it a cursor they understand. Passing the successful ControlFunction allows this function to properly construct a readMore control function for you to then request. See this example:

```javascript
const cid1 = IntacctApi.readByQuery({ object: 'PROJECT', pagesize: 1 });

const result1 = await obj.request(cid1);

const cid2 = IntacctApi.readMore(cid1);

const result2 = await obj.request(cid2);
```

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