-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
63 lines (52 loc) · 2.19 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
const ConnectWiseRest = require('connectwise-rest');
const opts = require('./config.json').rest;
const cw = new ConnectWiseRest({ ...opts, timeout: 120000 });
const Existing = require('@sdinteractive/connectwise-despacio-lib').Existing;
const dispatch = require('@sdinteractive/connectwise-despacio-lib').dispatch;
const params = {
// Member to dispatch.
memberIdentifier: 'tchristensen',
// Start dispatching on this date (inclusive.)
startDate: '2017-07-12',
// Stop dispatching on this date (inclusive.)
endDate: '2017-07-14',
// Timezone to dispatch in, beginning at startHour (e.g. 9:00 AM local time.)
timezone: 'America/Los_Angeles',
// Hour at which to start dispatching at (per above timezone.)
startHour: 9,
// Daily hours to dispatch.
daily: 9,
// Sum total of hours to dispatch, at most.
capTotalHours: 10,
// Don't assign inactive tickets.
// true: Skip canceled, pending qa, pending code review, on-hold, complete, etc.
// false: Assign all ticket ids.
// string: Skip only this ticket status (use lowercase.)
// array: Skip only these ticket statuses (use lowercase.)
skipByStatus: true,
// Skip dispatching tickets already dispatched for this member after startDate.
// Use this to re-run with additional ticket ids or date range.
// 'subtract': Reduce dispatch hours by already dispatched amount (possibly to zero.)
// 'skip': Skip, regardless of hours.
// 'ignore': Redispatch duplicate tickets with currently remaining hours.
skipDuplicateMode: 'subtract',
// Move the ticket to Assigned status after dispatching.
setAssigned: true,
// Skip actual dispatching, just log (dry-run.)
dry: true,
// Tickets to dispatch, array of objects:
// id: ticket ID to dispatch
// hours: Optional, override hours to dispatch. NOTE: Will force dispatch of inactive tickets if specified.
tickets: [
{id: '339429'},
{id: '340224', hours: 4},
],
};
Existing.get(cw, params).then(function (existing) {
return dispatch(cw, params, existing);
}).then(function (result) {
console.log(result);
}, function (err) {
console.error(err);
});