forked from fdesjardins/terminal-procedures
-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.js
78 lines (71 loc) · 2.4 KB
/
example.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const terminalProcedures = require('./')
// Should log current cycle effective object
terminalProcedures.fetchCycle().then(c => {
console.log('current cycle effective object, no param')
console.dir(c)
})
// Should log current cycle effective object
terminalProcedures.fetchCycle('Current').then(c => {
console.log('current cycle effective object, with param')
console.dir(c)
})
// Should log next cycle effective object
terminalProcedures.fetchCycle('Next').then(c => {
console.log('next cycle effective object, with param')
console.dir(c)
})
// Should log current cycle code
terminalProcedures.fetchCurrentCycleCode().then(c => {
console.log('current cycle code')
console.log(c)
})
// Should log the current cycle effective dates
terminalProcedures.getCycleEffectiveDates().then(c => {
console.log('the current cycle effective dates, no param')
console.log(c)
})
// Should log the current cycle effective dates
terminalProcedures.getCycleEffectiveDates('Current').then(c => {
console.log('the current cycle effective dates, with param')
console.log(c)
})
// Should log the next cycle effective dates
terminalProcedures.getCycleEffectiveDates('Next').then(c => {
console.log('the next cycle effective dates')
console.log(c)
})
// Should log the current cycle effective dates
terminalProcedures.currentCycleEffectiveDates().then(c => {
console.log('the current cycle effective dates')
console.log(c)
})
// Also try updating the Flag property to include one or more of the following:
// A for only those that were Added since the last effective date
// C for only those that were Changed since the last effective date
// D for only those that were Deleted since the last effective date
// Leave empty to get all regardless of if they've been added or changed
// The `getNextCycle` option will get the next cycle if it is available when set to true
// If it is omitted or set to false, the current cycle will be queried
terminalProcedures.list('PANC', { flag: [ ], getNextCycle: true, }).then(results => {
console.log(results)
const out = results.map(tp => {
return {
name: tp.procedure.name,
type: tp.type,
url: tp.procedure.url,
effectiveStartDate: tp.effectiveStartDate,
effectiveEndDate: tp.effectiveEndDate,
}
})
console.log(
JSON.stringify(
{
documents: {
terminalProcedures: [ out ]
}
},
null,
2
)
)
})