1 | connectwise-action-api
|
2 | ======================
|
3 |
|
4 | A thin high performance JavaScript layer for the ConnectWise XML Action API designed for Node.js.
|
5 |
|
6 | buffered usage
|
7 | --------------
|
8 | Buffer results and return with callback api. Optimized for smaller result sets. Entire response is buffered, then parsed into a JavaScript object.
|
9 | ```javascript
|
10 | var cw = require('connectwise-action-api').configure(
|
11 | 'SERVER HOST NAME',
|
12 | 'COMPANY NAME',
|
13 | 'INTEGRATOR LOGIN ID',
|
14 | 'INTEGRATOR PASSWORD'
|
15 | );
|
16 |
|
17 | cw.action('GetTicketAction', {
|
18 | SrServiceRecid: 12345
|
19 | }, function (error, result) {
|
20 | error && console.error(error);
|
21 | if (result) {
|
22 | var ticket = result.GetTicketAction.Ticket;
|
23 | console.dir(ticket);
|
24 | }
|
25 | });
|
26 | ```
|
27 |
|
28 | streaming usage
|
29 | ---------------
|
30 | Stream results using event emitter api. Optimized for large result sets. Uses less memory. Matches can be processed immediately and asynchronously. No need to depend on server paging. Fewer server round trips. Each xPath match is parsed into a JavaScript object and emitted as an event.
|
31 | ```javascript
|
32 | var cw = require('connectwise-action-api').configure(
|
33 | 'SERVER HOST NAME',
|
34 | 'COMPANY NAME',
|
35 | 'INTEGRATOR LOGIN ID',
|
36 | 'INTEGRATOR PASSWORD'
|
37 | );
|
38 |
|
39 | cw.actionStream('RunReportQueryAction', '//Result', {
|
40 | ReportName: 'Schedule',
|
41 | Limit: 100000
|
42 | })
|
43 | .on('match', function (match) {
|
44 | console.dir(match);
|
45 | })
|
46 | .on('error', function (error) {
|
47 | console.error(error);
|
48 | })
|
49 | .on('end', function () {
|
50 | // all done
|
51 | });
|
52 | ```
|
53 |
|
54 | tests
|
55 | -----
|
56 |
|
57 | See [`tests`](tests) directory for documentation and examples of API actions.
|
58 | Tests clean up after themselves.
|
59 | * Configure tests in `test-config.js`
|
60 | * Run all tests: `node test`
|
61 | * Run specific tests using file name pattern: `node test version`
|
62 | ```
|
63 | d:\connectwise-action-api>node test version
|
64 |
|
65 | get-connectwise-version.js
|
66 | { Version: 'v2014.4.23325', IsCloud: 'false' }
|
67 | ✔ get_connectwise_version
|
68 |
|
69 | OK: 2 assertions (729ms)
|
70 | ```
|
71 | * Clean up after tests: `npm run clean`
|
72 |
|
73 | install
|
74 | -------
|
75 | ```
|
76 | npm install --save connectwise-action-api
|
77 | ```
|
78 |
|
79 | docs
|
80 | ----
|
81 |
|
82 | [available reports and fields](./available-reports.md)
|
83 |
|
84 | ideas
|
85 | -----
|
86 | * make it work with Node.js and Browser
|