UNPKG

2.19 kBMarkdownView Raw
1connectwise-action-api
2======================
3
4A thin high performance JavaScript layer for the ConnectWise XML Action API designed for Node.js.
5
6buffered usage
7--------------
8Buffer results and return with callback api. Optimized for smaller result sets. Entire response is buffered, then parsed into a JavaScript object.
9```javascript
10var cw = require('connectwise-action-api').configure(
11 'SERVER HOST NAME',
12 'COMPANY NAME',
13 'INTEGRATOR LOGIN ID',
14 'INTEGRATOR PASSWORD'
15);
16
17cw.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
28streaming usage
29---------------
30Stream 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
32var cw = require('connectwise-action-api').configure(
33 'SERVER HOST NAME',
34 'COMPANY NAME',
35 'INTEGRATOR LOGIN ID',
36 'INTEGRATOR PASSWORD'
37);
38
39cw.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
54tests
55-----
56
57See [`tests`](tests) directory for documentation and examples of API actions.
58Tests 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```
63d:\connectwise-action-api>node test version
64
65get-connectwise-version.js
66{ Version: 'v2014.4.23325', IsCloud: 'false' }
67✔ get_connectwise_version
68
69OK: 2 assertions (729ms)
70```
71* Clean up after tests: `npm run clean`
72
73install
74-------
75```
76npm install --save connectwise-action-api
77```
78
79docs
80----
81
82[available reports and fields](./available-reports.md)
83
84ideas
85-----
86* make it work with Node.js and Browser