@itentialopensource/adapter-tmf641_service_ordering_management 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +18 -0
  3. package/.jshintrc +3 -0
  4. package/AUTH.md +39 -0
  5. package/BROKER.md +199 -0
  6. package/CALLS.md +290 -0
  7. package/CHANGELOG.md +16 -0
  8. package/CODE_OF_CONDUCT.md +43 -0
  9. package/CONTRIBUTING.md +172 -0
  10. package/ENHANCE.md +69 -0
  11. package/LICENSE +201 -0
  12. package/PROPERTIES.md +641 -0
  13. package/README.md +337 -0
  14. package/SUMMARY.md +9 -0
  15. package/SYSTEMINFO.md +11 -0
  16. package/TROUBLESHOOT.md +47 -0
  17. package/adapter.js +2487 -0
  18. package/adapterBase.js +1787 -0
  19. package/entities/.generic/action.json +214 -0
  20. package/entities/.generic/schema.json +28 -0
  21. package/entities/.system/action.json +50 -0
  22. package/entities/.system/mockdatafiles/getToken-default.json +3 -0
  23. package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
  24. package/entities/.system/schema.json +19 -0
  25. package/entities/.system/schemaTokenReq.json +53 -0
  26. package/entities/.system/schemaTokenResp.json +53 -0
  27. package/entities/CancelServiceOrder/action.json +66 -0
  28. package/entities/CancelServiceOrder/mockdatafiles/listCancelServiceOrder-default.json +95 -0
  29. package/entities/CancelServiceOrder/schema.json +21 -0
  30. package/entities/EventsSubscription/action.json +44 -0
  31. package/entities/EventsSubscription/schema.json +20 -0
  32. package/entities/NotificationListenersClientSide/action.json +204 -0
  33. package/entities/NotificationListenersClientSide/schema.json +28 -0
  34. package/entities/ServiceOrder/action.json +106 -0
  35. package/entities/ServiceOrder/schema.json +23 -0
  36. package/error.json +190 -0
  37. package/package.json +85 -0
  38. package/pronghorn.json +1646 -0
  39. package/propertiesDecorators.json +14 -0
  40. package/propertiesSchema.json +1248 -0
  41. package/refs?service=git-upload-pack +0 -0
  42. package/report/adapterInfo.json +10 -0
  43. package/report/creationReport.json +350 -0
  44. package/report/test641.json +10238 -0
  45. package/sampleProperties.json +195 -0
  46. package/test/integration/adapterTestBasicGet.js +83 -0
  47. package/test/integration/adapterTestConnectivity.js +93 -0
  48. package/test/integration/adapterTestIntegration.js +866 -0
  49. package/test/unit/adapterBaseTestUnit.js +949 -0
  50. package/test/unit/adapterTestUnit.js +1874 -0
  51. package/utils/adapterInfo.js +206 -0
  52. package/utils/addAuth.js +94 -0
  53. package/utils/artifactize.js +146 -0
  54. package/utils/basicGet.js +50 -0
  55. package/utils/checkMigrate.js +63 -0
  56. package/utils/entitiesToDB.js +178 -0
  57. package/utils/findPath.js +74 -0
  58. package/utils/methodDocumentor.js +225 -0
  59. package/utils/modify.js +154 -0
  60. package/utils/packModificationScript.js +35 -0
  61. package/utils/patches2bundledDeps.js +90 -0
  62. package/utils/pre-commit.sh +32 -0
  63. package/utils/removeHooks.js +20 -0
  64. package/utils/setup.js +33 -0
  65. package/utils/tbScript.js +246 -0
  66. package/utils/tbUtils.js +490 -0
  67. package/utils/testRunner.js +298 -0
  68. package/utils/troubleshootingAdapter.js +195 -0
  69. package/workflows/README.md +3 -0
package/adapter.js ADDED
@@ -0,0 +1,2487 @@
1
+ /* @copyright Itential, LLC 2019 (pre-modifications) */
2
+
3
+ /* eslint import/no-dynamic-require: warn */
4
+ /* eslint object-curly-newline: warn */
5
+
6
+ // Set globals
7
+ /* global log */
8
+
9
+ /* Required libraries. */
10
+ const path = require('path');
11
+
12
+ /* Fetch in the other needed components for the this Adaptor */
13
+ const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
14
+
15
+ /**
16
+ * This is the adapter/interface into tmf641_service_ordering_management
17
+ */
18
+
19
+ /* GENERAL ADAPTER FUNCTIONS */
20
+ class Tmf641ServiceOrderingManagement extends AdapterBaseCl {
21
+ /**
22
+ * Tmf641ServiceOrderingManagement Adapter
23
+ * @constructor
24
+ */
25
+ /* Working on changing the way we do Emit methods due to size and time constrainsts
26
+ constructor(prongid, properties) {
27
+ // Instantiate the AdapterBase super class
28
+ super(prongid, properties);
29
+
30
+ const restFunctionNames = this.iapGetAdapterWorkflowFunctions();
31
+
32
+ // Dynamically bind emit functions
33
+ for (let i = 0; i < restFunctionNames.length; i += 1) {
34
+ // Bind function to have name fnNameEmit for fnName
35
+ const version = restFunctionNames[i].match(/__v[0-9]+/);
36
+ const baseFnName = restFunctionNames[i].replace(/__v[0-9]+/, '');
37
+ const fnNameEmit = version ? `${baseFnName}Emit${version}` : `${baseFnName}Emit`;
38
+ this[fnNameEmit] = function (...args) {
39
+ // extract the callback
40
+ const callback = args[args.length - 1];
41
+ // slice the callback from args so we can insert our own
42
+ const functionArgs = args.slice(0, args.length - 1);
43
+ // create a random name for the listener
44
+ const eventName = `${restFunctionNames[i]}:${Math.random().toString(36)}`;
45
+ // tell the calling class to start listening
46
+ callback({ event: eventName, status: 'received' });
47
+ // store parent for use of this context later
48
+ const parent = this;
49
+ // store emission function
50
+ const func = function (val, err) {
51
+ parent.removeListener(eventName, func);
52
+ parent.emit(eventName, val, err);
53
+ };
54
+ // Use apply to call the function in a specific context
55
+ this[restFunctionNames[i]].apply(this, functionArgs.concat([func])); // eslint-disable-line prefer-spread
56
+ };
57
+ }
58
+
59
+ // Uncomment if you have things to add to the constructor like using your own properties.
60
+ // Otherwise the constructor in the adapterBase will be used.
61
+ // Capture my own properties - they need to be defined in propertiesSchema.json
62
+ // if (this.allProps && this.allProps.myownproperty) {
63
+ // mypropvariable = this.allProps.myownproperty;
64
+ // }
65
+ }
66
+ */
67
+
68
+ /**
69
+ * @callback healthCallback
70
+ * @param {Object} reqObj - the request to send into the healthcheck
71
+ * @param {Callback} callback - The results of the call
72
+ */
73
+ healthCheck(reqObj, callback) {
74
+ // you can modify what is passed into the healthcheck by changing things in the newReq
75
+ let newReq = null;
76
+ if (reqObj) {
77
+ newReq = Object.assign(...reqObj);
78
+ }
79
+ super.healthCheck(newReq, callback);
80
+ }
81
+
82
+ /**
83
+ * @iapGetAdapterWorkflowFunctions
84
+ */
85
+ iapGetAdapterWorkflowFunctions(inIgnore) {
86
+ let myIgnore = [
87
+ 'healthCheck',
88
+ 'iapGetAdapterWorkflowFunctions',
89
+ 'iapHasAdapterEntity',
90
+ 'iapVerifyAdapterCapability',
91
+ 'iapUpdateAdapterEntityCache',
92
+ 'hasEntities'
93
+ ];
94
+ if (!inIgnore && Array.isArray(inIgnore)) {
95
+ myIgnore = inIgnore;
96
+ } else if (!inIgnore && typeof inIgnore === 'string') {
97
+ myIgnore = [inIgnore];
98
+ }
99
+
100
+ // The generic adapter functions should already be ignored (e.g. healthCheck)
101
+ // you can add specific methods that you do not want to be workflow functions to ignore like below
102
+ // myIgnore.push('myMethodNotInWorkflow');
103
+
104
+ return super.iapGetAdapterWorkflowFunctions(myIgnore);
105
+ }
106
+
107
+ /**
108
+ * iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
109
+ * allows customers to make changes to adapter configuration without having to be on the
110
+ * file system.
111
+ *
112
+ * @function iapUpdateAdapterConfiguration
113
+ * @param {string} configFile - the name of the file being updated (required)
114
+ * @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
115
+ * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
116
+ * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
117
+ * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
118
+ * @param {Callback} callback - The results of the call
119
+ */
120
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
121
+ const meth = 'adapter-iapUpdateAdapterConfiguration';
122
+ const origin = `${this.id}-${meth}`;
123
+ log.trace(origin);
124
+
125
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
126
+ }
127
+
128
+ /**
129
+ * See if the API path provided is found in this adapter
130
+ *
131
+ * @function iapFindAdapterPath
132
+ * @param {string} apiPath - the api path to check on
133
+ * @param {Callback} callback - The results of the call
134
+ */
135
+ iapFindAdapterPath(apiPath, callback) {
136
+ const meth = 'adapter-iapFindAdapterPath';
137
+ const origin = `${this.id}-${meth}`;
138
+ log.trace(origin);
139
+
140
+ super.iapFindAdapterPath(apiPath, callback);
141
+ }
142
+
143
+ /**
144
+ * @summary Suspends adapter
145
+ *
146
+ * @function iapSuspendAdapter
147
+ * @param {Callback} callback - callback function
148
+ */
149
+ iapSuspendAdapter(mode, callback) {
150
+ const meth = 'adapter-iapSuspendAdapter';
151
+ const origin = `${this.id}-${meth}`;
152
+ log.trace(origin);
153
+
154
+ try {
155
+ return super.iapSuspendAdapter(mode, callback);
156
+ } catch (error) {
157
+ log.error(`${origin}: ${error}`);
158
+ return callback(null, error);
159
+ }
160
+ }
161
+
162
+ /**
163
+ * @summary Unsuspends adapter
164
+ *
165
+ * @function iapUnsuspendAdapter
166
+ * @param {Callback} callback - callback function
167
+ */
168
+ iapUnsuspendAdapter(callback) {
169
+ const meth = 'adapter-iapUnsuspendAdapter';
170
+ const origin = `${this.id}-${meth}`;
171
+ log.trace(origin);
172
+
173
+ try {
174
+ return super.iapUnsuspendAdapter(callback);
175
+ } catch (error) {
176
+ log.error(`${origin}: ${error}`);
177
+ return callback(null, error);
178
+ }
179
+ }
180
+
181
+ /**
182
+ * @summary Get the Adaoter Queue
183
+ *
184
+ * @function iapGetAdapterQueue
185
+ * @param {Callback} callback - callback function
186
+ */
187
+ iapGetAdapterQueue(callback) {
188
+ const meth = 'adapter-iapGetAdapterQueue';
189
+ const origin = `${this.id}-${meth}`;
190
+ log.trace(origin);
191
+
192
+ return super.iapGetAdapterQueue(callback);
193
+ }
194
+
195
+ /**
196
+ * @summary Runs troubleshoot scripts for adapter
197
+ *
198
+ * @function iapTroubleshootAdapter
199
+ * @param {Object} props - the connection, healthcheck and authentication properties
200
+ *
201
+ * @param {boolean} persistFlag - whether the adapter properties should be updated
202
+ * @param {Callback} callback - The results of the call
203
+ */
204
+ iapTroubleshootAdapter(props, persistFlag, callback) {
205
+ const meth = 'adapter-iapTroubleshootAdapter';
206
+ const origin = `${this.id}-${meth}`;
207
+ log.trace(origin);
208
+
209
+ try {
210
+ return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
211
+ } catch (error) {
212
+ log.error(`${origin}: ${error}`);
213
+ return callback(null, error);
214
+ }
215
+ }
216
+
217
+ /**
218
+ * @summary runs healthcheck script for adapter
219
+ *
220
+ * @function iapRunAdapterHealthcheck
221
+ * @param {Adapter} adapter - adapter instance to troubleshoot
222
+ * @param {Callback} callback - callback function
223
+ */
224
+ iapRunAdapterHealthcheck(callback) {
225
+ const meth = 'adapter-iapRunAdapterHealthcheck';
226
+ const origin = `${this.id}-${meth}`;
227
+ log.trace(origin);
228
+
229
+ try {
230
+ return super.iapRunAdapterHealthcheck(this, callback);
231
+ } catch (error) {
232
+ log.error(`${origin}: ${error}`);
233
+ return callback(null, error);
234
+ }
235
+ }
236
+
237
+ /**
238
+ * @summary runs connectivity check script for adapter
239
+ *
240
+ * @function iapRunAdapterConnectivity
241
+ * @param {Callback} callback - callback function
242
+ */
243
+ iapRunAdapterConnectivity(callback) {
244
+ const meth = 'adapter-iapRunAdapterConnectivity';
245
+ const origin = `${this.id}-${meth}`;
246
+ log.trace(origin);
247
+
248
+ try {
249
+ return super.iapRunAdapterConnectivity(callback);
250
+ } catch (error) {
251
+ log.error(`${origin}: ${error}`);
252
+ return callback(null, error);
253
+ }
254
+ }
255
+
256
+ /**
257
+ * @summary runs basicGet script for adapter
258
+ *
259
+ * @function iapRunAdapterBasicGet
260
+ * @param {Callback} callback - callback function
261
+ */
262
+ iapRunAdapterBasicGet(callback) {
263
+ const meth = 'adapter-iapRunAdapterBasicGet';
264
+ const origin = `${this.id}-${meth}`;
265
+ log.trace(origin);
266
+
267
+ try {
268
+ return super.iapRunAdapterBasicGet(callback);
269
+ } catch (error) {
270
+ log.error(`${origin}: ${error}`);
271
+ return callback(null, error);
272
+ }
273
+ }
274
+
275
+ /**
276
+ * @summary moves entites into Mongo DB
277
+ *
278
+ * @function iapMoveAdapterEntitiesToDB
279
+ * @param {getCallback} callback - a callback function to return the result (Generics)
280
+ * or the error
281
+ */
282
+ iapMoveAdapterEntitiesToDB(callback) {
283
+ const meth = 'adapter-iapMoveAdapterEntitiesToDB';
284
+ const origin = `${this.id}-${meth}`;
285
+ log.trace(origin);
286
+
287
+ try {
288
+ return super.iapMoveAdapterEntitiesToDB(callback);
289
+ } catch (err) {
290
+ log.error(`${origin}: ${err}`);
291
+ return callback(null, err);
292
+ }
293
+ }
294
+
295
+ /* BROKER CALLS */
296
+ /**
297
+ * @summary Determines if this adapter supports the specific entity
298
+ *
299
+ * @function iapHasAdapterEntity
300
+ * @param {String} entityType - the entity type to check for
301
+ * @param {String/Array} entityId - the specific entity we are looking for
302
+ *
303
+ * @param {Callback} callback - An array of whether the adapter can has the
304
+ * desired capability or an error
305
+ */
306
+ iapHasAdapterEntity(entityType, entityId, callback) {
307
+ const origin = `${this.id}-adapter-iapHasAdapterEntity`;
308
+ log.trace(origin);
309
+
310
+ // Make the call -
311
+ // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
312
+ return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
313
+ }
314
+
315
+ /**
316
+ * @summary Provides a way for the adapter to tell north bound integrations
317
+ * whether the adapter supports type, action and specific entity
318
+ *
319
+ * @function iapVerifyAdapterCapability
320
+ * @param {String} entityType - the entity type to check for
321
+ * @param {String} actionType - the action type to check for
322
+ * @param {String/Array} entityId - the specific entity we are looking for
323
+ *
324
+ * @param {Callback} callback - An array of whether the adapter can has the
325
+ * desired capability or an error
326
+ */
327
+ iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
328
+ const meth = 'adapterBase-iapVerifyAdapterCapability';
329
+ const origin = `${this.id}-${meth}`;
330
+ log.trace(origin);
331
+
332
+ // if caching
333
+ if (this.caching) {
334
+ // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
335
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
336
+ if (error) {
337
+ return callback(null, error);
338
+ }
339
+
340
+ // if the cache needs to be updated, update and try again
341
+ if (results && results[0] === 'needupdate') {
342
+ switch (entityType) {
343
+ case 'template_entity': {
344
+ // if the cache is invalid, update the cache
345
+ return this.getEntities(null, null, null, null, (data, err) => {
346
+ if (err) {
347
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
348
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
349
+ return callback(null, errorObj);
350
+ }
351
+
352
+ // need to check the cache again since it has been updated
353
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
354
+ if (verror) {
355
+ return callback(null, verror);
356
+ }
357
+
358
+ return this.capabilityResults(vcapable, callback);
359
+ });
360
+ });
361
+ }
362
+ default: {
363
+ // unsupported entity type
364
+ const result = [false];
365
+
366
+ // put false in array for all entities
367
+ if (Array.isArray(entityId)) {
368
+ for (let e = 1; e < entityId.length; e += 1) {
369
+ result.push(false);
370
+ }
371
+ }
372
+
373
+ return callback(result);
374
+ }
375
+ }
376
+ }
377
+
378
+ // return the results
379
+ return this.capabilityResults(results, callback);
380
+ });
381
+ }
382
+
383
+ // if no entity id
384
+ if (!entityId) {
385
+ // need to check the cache again since it has been updated
386
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
387
+ if (verror) {
388
+ return callback(null, verror);
389
+ }
390
+
391
+ return this.capabilityResults(vcapable, callback);
392
+ });
393
+ }
394
+
395
+ // if not caching
396
+ switch (entityType) {
397
+ case 'template_entity': {
398
+ // need to get the entities to check
399
+ return this.getEntities(null, null, null, null, (data, err) => {
400
+ if (err) {
401
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
402
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
403
+ return callback(null, errorObj);
404
+ }
405
+
406
+ // need to check the cache again since it has been updated
407
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
408
+ if (verror) {
409
+ return callback(null, verror);
410
+ }
411
+
412
+ // is the entity in the list?
413
+ const isEntity = this.entityInList(entityId, data.response, callback);
414
+ const res = [];
415
+
416
+ // not found
417
+ for (let i = 0; i < isEntity.length; i += 1) {
418
+ if (vcapable) {
419
+ res.push(isEntity[i]);
420
+ } else {
421
+ res.push(false);
422
+ }
423
+ }
424
+
425
+ return callback(res);
426
+ });
427
+ });
428
+ }
429
+ default: {
430
+ // unsupported entity type
431
+ const result = [false];
432
+
433
+ // put false in array for all entities
434
+ if (Array.isArray(entityId)) {
435
+ for (let e = 1; e < entityId.length; e += 1) {
436
+ result.push(false);
437
+ }
438
+ }
439
+
440
+ return callback(result);
441
+ }
442
+ }
443
+ }
444
+
445
+ /**
446
+ * @summary Updates the cache for all entities by call the get All entity method
447
+ *
448
+ * @function iapUpdateAdapterEntityCache
449
+ *
450
+ */
451
+ iapUpdateAdapterEntityCache() {
452
+ const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
453
+ log.trace(origin);
454
+
455
+ if (this.caching) {
456
+ // if the cache is invalid, update the cache
457
+ this.getEntities(null, null, null, null, (data, err) => {
458
+ if (err) {
459
+ log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
460
+ }
461
+ });
462
+ }
463
+ }
464
+
465
+ /**
466
+ * @summary Determines if this adapter supports any in a list of entities
467
+ *
468
+ * @function hasEntities
469
+ * @param {String} entityType - the entity type to check for
470
+ * @param {Array} entityList - the list of entities we are looking for
471
+ *
472
+ * @param {Callback} callback - A map where the entity is the key and the
473
+ * value is true or false
474
+ */
475
+ hasEntities(entityType, entityList, callback) {
476
+ const meth = 'adapter-hasEntities';
477
+ const origin = `${this.id}-${meth}`;
478
+ log.trace(origin);
479
+
480
+ try {
481
+ return super.hasEntities(entityType, entityList, callback);
482
+ } catch (err) {
483
+ log.error(`${origin}: ${err}`);
484
+ return callback(null, err);
485
+ }
486
+ }
487
+
488
+ /**
489
+ * @summary Get Appliance that match the deviceName
490
+ *
491
+ * @function getDevice
492
+ * @param {String} deviceName - the deviceName to find (required)
493
+ *
494
+ * @param {getCallback} callback - a callback function to return the result
495
+ * (appliance) or the error
496
+ */
497
+ getDevice(deviceName, callback) {
498
+ const meth = 'adapter-getDevice';
499
+ const origin = `${this.id}-${meth}`;
500
+ log.trace(origin);
501
+
502
+ try {
503
+ return super.getDevice(deviceName, callback);
504
+ } catch (err) {
505
+ log.error(`${origin}: ${err}`);
506
+ return callback(null, err);
507
+ }
508
+ }
509
+
510
+ /**
511
+ * @summary Get Appliances that match the filter
512
+ *
513
+ * @function getDevicesFiltered
514
+ * @param {Object} options - the data to use to filter the appliances (optional)
515
+ *
516
+ * @param {getCallback} callback - a callback function to return the result
517
+ * (appliances) or the error
518
+ */
519
+ getDevicesFiltered(options, callback) {
520
+ const meth = 'adapter-getDevicesFiltered';
521
+ const origin = `${this.id}-${meth}`;
522
+ log.trace(origin);
523
+
524
+ try {
525
+ return super.getDevicesFiltered(options, callback);
526
+ } catch (err) {
527
+ log.error(`${origin}: ${err}`);
528
+ return callback(null, err);
529
+ }
530
+ }
531
+
532
+ /**
533
+ * @summary Gets the status for the provided appliance
534
+ *
535
+ * @function isAlive
536
+ * @param {String} deviceName - the deviceName of the appliance. (required)
537
+ *
538
+ * @param {configCallback} callback - callback function to return the result
539
+ * (appliance isAlive) or the error
540
+ */
541
+ isAlive(deviceName, callback) {
542
+ const meth = 'adapter-isAlive';
543
+ const origin = `${this.id}-${meth}`;
544
+ log.trace(origin);
545
+
546
+ try {
547
+ return super.isAlive(deviceName, callback);
548
+ } catch (err) {
549
+ log.error(`${origin}: ${err}`);
550
+ return callback(null, err);
551
+ }
552
+ }
553
+
554
+ /**
555
+ * @summary Gets a config for the provided Appliance
556
+ *
557
+ * @function getConfig
558
+ * @param {String} deviceName - the deviceName of the appliance. (required)
559
+ * @param {String} format - the desired format of the config. (optional)
560
+ *
561
+ * @param {configCallback} callback - callback function to return the result
562
+ * (appliance config) or the error
563
+ */
564
+ getConfig(deviceName, format, callback) {
565
+ const meth = 'adapter-getConfig';
566
+ const origin = `${this.id}-${meth}`;
567
+ log.trace(origin);
568
+
569
+ try {
570
+ return super.getConfig(deviceName, format, callback);
571
+ } catch (err) {
572
+ log.error(`${origin}: ${err}`);
573
+ return callback(null, err);
574
+ }
575
+ }
576
+
577
+ /**
578
+ * @summary Gets the device count from the system
579
+ *
580
+ * @function iapGetDeviceCount
581
+ *
582
+ * @param {getCallback} callback - callback function to return the result
583
+ * (count) or the error
584
+ */
585
+ iapGetDeviceCount(callback) {
586
+ const meth = 'adapter-iapGetDeviceCount';
587
+ const origin = `${this.id}-${meth}`;
588
+ log.trace(origin);
589
+
590
+ try {
591
+ return super.iapGetDeviceCount(callback);
592
+ } catch (err) {
593
+ log.error(`${origin}: ${err}`);
594
+ return callback(null, err);
595
+ }
596
+ }
597
+
598
+ /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
599
+ /**
600
+ * Makes the requested generic call
601
+ *
602
+ * @function genericAdapterRequest
603
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
604
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
605
+ * @param {Object} queryData - the parameters to be put on the url (optional).
606
+ * Can be a stringified Object.
607
+ * @param {Object} requestBody - the body to add to the request (optional).
608
+ * Can be a stringified Object.
609
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
610
+ * Can be a stringified Object.
611
+ * @param {getCallback} callback - a callback function to return the result (Generics)
612
+ * or the error
613
+ */
614
+ genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
615
+ const meth = 'adapter-genericAdapterRequest';
616
+ const origin = `${this.id}-${meth}`;
617
+ log.trace(origin);
618
+
619
+ if (this.suspended && this.suspendMode === 'error') {
620
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
621
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
622
+ return callback(null, errorObj);
623
+ }
624
+
625
+ /* HERE IS WHERE YOU VALIDATE DATA */
626
+ if (uriPath === undefined || uriPath === null || uriPath === '') {
627
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
628
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
629
+ return callback(null, errorObj);
630
+ }
631
+ if (restMethod === undefined || restMethod === null || restMethod === '') {
632
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
633
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
634
+ return callback(null, errorObj);
635
+ }
636
+
637
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
638
+ // remove any leading / and split the uripath into path variables
639
+ let myPath = uriPath;
640
+ while (myPath.indexOf('/') === 0) {
641
+ myPath = myPath.substring(1);
642
+ }
643
+ const pathVars = myPath.split('/');
644
+ const queryParamsAvailable = queryData;
645
+ const queryParams = {};
646
+ const bodyVars = requestBody;
647
+
648
+ // loop in template. long callback arg name to avoid identifier conflicts
649
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
650
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
651
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
652
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
653
+ }
654
+ });
655
+
656
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
657
+ const reqObj = {
658
+ payload: bodyVars,
659
+ uriPathVars: pathVars,
660
+ uriQuery: queryParams,
661
+ uriOptions: {}
662
+ };
663
+ // add headers if provided
664
+ if (addlHeaders) {
665
+ reqObj.addlHeaders = addlHeaders;
666
+ }
667
+
668
+ // determine the call and return flag
669
+ let action = 'getGenerics';
670
+ let returnF = true;
671
+ if (restMethod.toUpperCase() === 'POST') {
672
+ action = 'createGeneric';
673
+ } else if (restMethod.toUpperCase() === 'PUT') {
674
+ action = 'updateGeneric';
675
+ } else if (restMethod.toUpperCase() === 'PATCH') {
676
+ action = 'patchGeneric';
677
+ } else if (restMethod.toUpperCase() === 'DELETE') {
678
+ action = 'deleteGeneric';
679
+ returnF = false;
680
+ }
681
+
682
+ try {
683
+ // Make the call -
684
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
685
+ return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
686
+ // if we received an error or their is no response on the results
687
+ // return an error
688
+ if (irReturnError) {
689
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
690
+ return callback(null, irReturnError);
691
+ }
692
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
693
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
694
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
695
+ return callback(null, errorObj);
696
+ }
697
+
698
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
699
+ // return the response
700
+ return callback(irReturnData, null);
701
+ });
702
+ } catch (ex) {
703
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
704
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
705
+ return callback(null, errorObj);
706
+ }
707
+ }
708
+
709
+ /**
710
+ * Makes the requested generic call with no base path or version
711
+ *
712
+ * @function genericAdapterRequestNoBasePath
713
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
714
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
715
+ * @param {Object} queryData - the parameters to be put on the url (optional).
716
+ * Can be a stringified Object.
717
+ * @param {Object} requestBody - the body to add to the request (optional).
718
+ * Can be a stringified Object.
719
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
720
+ * Can be a stringified Object.
721
+ * @param {getCallback} callback - a callback function to return the result (Generics)
722
+ * or the error
723
+ */
724
+ genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
725
+ const meth = 'adapter-genericAdapterRequestNoBasePath';
726
+ const origin = `${this.id}-${meth}`;
727
+ log.trace(origin);
728
+
729
+ if (this.suspended && this.suspendMode === 'error') {
730
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
731
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
732
+ return callback(null, errorObj);
733
+ }
734
+
735
+ /* HERE IS WHERE YOU VALIDATE DATA */
736
+ if (uriPath === undefined || uriPath === null || uriPath === '') {
737
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
738
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
739
+ return callback(null, errorObj);
740
+ }
741
+ if (restMethod === undefined || restMethod === null || restMethod === '') {
742
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
743
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
744
+ return callback(null, errorObj);
745
+ }
746
+
747
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
748
+ // remove any leading / and split the uripath into path variables
749
+ let myPath = uriPath;
750
+ while (myPath.indexOf('/') === 0) {
751
+ myPath = myPath.substring(1);
752
+ }
753
+ const pathVars = myPath.split('/');
754
+ const queryParamsAvailable = queryData;
755
+ const queryParams = {};
756
+ const bodyVars = requestBody;
757
+
758
+ // loop in template. long callback arg name to avoid identifier conflicts
759
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
760
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
761
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
762
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
763
+ }
764
+ });
765
+
766
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
767
+ const reqObj = {
768
+ payload: bodyVars,
769
+ uriPathVars: pathVars,
770
+ uriQuery: queryParams,
771
+ uriOptions: {}
772
+ };
773
+ // add headers if provided
774
+ if (addlHeaders) {
775
+ reqObj.addlHeaders = addlHeaders;
776
+ }
777
+
778
+ // determine the call and return flag
779
+ let action = 'getGenericsNoBase';
780
+ let returnF = true;
781
+ if (restMethod.toUpperCase() === 'POST') {
782
+ action = 'createGenericNoBase';
783
+ } else if (restMethod.toUpperCase() === 'PUT') {
784
+ action = 'updateGenericNoBase';
785
+ } else if (restMethod.toUpperCase() === 'PATCH') {
786
+ action = 'patchGenericNoBase';
787
+ } else if (restMethod.toUpperCase() === 'DELETE') {
788
+ action = 'deleteGenericNoBase';
789
+ returnF = false;
790
+ }
791
+
792
+ try {
793
+ // Make the call -
794
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
795
+ return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
796
+ // if we received an error or their is no response on the results
797
+ // return an error
798
+ if (irReturnError) {
799
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
800
+ return callback(null, irReturnError);
801
+ }
802
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
803
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
804
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
805
+ return callback(null, errorObj);
806
+ }
807
+
808
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
809
+ // return the response
810
+ return callback(irReturnData, null);
811
+ });
812
+ } catch (ex) {
813
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
814
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
815
+ return callback(null, errorObj);
816
+ }
817
+ }
818
+
819
+ /**
820
+ * @callback healthCallback
821
+ * @param {Object} result - the result of the get request (contains an id and a status)
822
+ */
823
+ /**
824
+ * @callback getCallback
825
+ * @param {Object} result - the result of the get request (entity/ies)
826
+ * @param {String} error - any error that occurred
827
+ */
828
+ /**
829
+ * @callback createCallback
830
+ * @param {Object} item - the newly created entity
831
+ * @param {String} error - any error that occurred
832
+ */
833
+ /**
834
+ * @callback updateCallback
835
+ * @param {String} status - the status of the update action
836
+ * @param {String} error - any error that occurred
837
+ */
838
+ /**
839
+ * @callback deleteCallback
840
+ * @param {String} status - the status of the delete action
841
+ * @param {String} error - any error that occurred
842
+ */
843
+
844
+ /**
845
+ * @function listServiceOrder
846
+ * @pronghornType method
847
+ * @name listServiceOrder
848
+ * @summary listServiceOrder
849
+ *
850
+ * @param {string} [fields] - Comma-separated properties to be provided in response
851
+ * @param {number} [offset] - Requested index for start of resources to be provided in response
852
+ * @param {number} [limit] - Requested number of resources to be provided in response
853
+ * @param {getCallback} callback - a callback function to return the result
854
+ * @return {object} results - An object containing the response of the action
855
+ *
856
+ * @route {POST} /listServiceOrder
857
+ * @roles admin
858
+ * @task true
859
+ */
860
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
861
+ listServiceOrder(fields, offset, limit, callback) {
862
+ const meth = 'adapter-listServiceOrder';
863
+ const origin = `${this.id}-${meth}`;
864
+ log.trace(origin);
865
+
866
+ if (this.suspended && this.suspendMode === 'error') {
867
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
868
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
869
+ return callback(null, errorObj);
870
+ }
871
+
872
+ /* HERE IS WHERE YOU VALIDATE DATA */
873
+
874
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
875
+ const queryParamsAvailable = { fields, offset, limit };
876
+ const queryParams = {};
877
+ const pathVars = [];
878
+ const bodyVars = {};
879
+
880
+ // loop in template. long callback arg name to avoid identifier conflicts
881
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
882
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
883
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
884
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
885
+ }
886
+ });
887
+
888
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
889
+ // see adapter code documentation for more information on the request object's fields
890
+ const reqObj = {
891
+ payload: bodyVars,
892
+ uriPathVars: pathVars,
893
+ uriQuery: queryParams
894
+ };
895
+
896
+ try {
897
+ // Make the call -
898
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
899
+ return this.requestHandlerInst.identifyRequest('ServiceOrder', 'listServiceOrder', reqObj, true, (irReturnData, irReturnError) => {
900
+ // if we received an error or their is no response on the results
901
+ // return an error
902
+ if (irReturnError) {
903
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
904
+ return callback(null, irReturnError);
905
+ }
906
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
907
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listServiceOrder'], null, null, null);
908
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
909
+ return callback(null, errorObj);
910
+ }
911
+
912
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
913
+ // return the response
914
+ return callback(irReturnData, null);
915
+ });
916
+ } catch (ex) {
917
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
918
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
919
+ return callback(null, errorObj);
920
+ }
921
+ }
922
+
923
+ /**
924
+ * @function createServiceOrder
925
+ * @pronghornType method
926
+ * @name createServiceOrder
927
+ * @summary createServiceOrder
928
+ *
929
+ * @param {object} body - The ServiceOrder to be created
930
+ * @param {getCallback} callback - a callback function to return the result
931
+ * @return {object} results - An object containing the response of the action
932
+ *
933
+ * @route {POST} /createServiceOrder
934
+ * @roles admin
935
+ * @task true
936
+ */
937
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
938
+ createServiceOrder(body, callback) {
939
+ const meth = 'adapter-createServiceOrder';
940
+ const origin = `${this.id}-${meth}`;
941
+ log.trace(origin);
942
+
943
+ if (this.suspended && this.suspendMode === 'error') {
944
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
945
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
946
+ return callback(null, errorObj);
947
+ }
948
+
949
+ /* HERE IS WHERE YOU VALIDATE DATA */
950
+ if (body === undefined || body === null || body === '') {
951
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
952
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
953
+ return callback(null, errorObj);
954
+ }
955
+
956
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
957
+ const queryParamsAvailable = {};
958
+ const queryParams = {};
959
+ const pathVars = [];
960
+ const bodyVars = body;
961
+
962
+ // loop in template. long callback arg name to avoid identifier conflicts
963
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
964
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
965
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
966
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
967
+ }
968
+ });
969
+
970
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
971
+ // see adapter code documentation for more information on the request object's fields
972
+ const reqObj = {
973
+ payload: bodyVars,
974
+ uriPathVars: pathVars,
975
+ uriQuery: queryParams
976
+ };
977
+
978
+ try {
979
+ // Make the call -
980
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
981
+ return this.requestHandlerInst.identifyRequest('ServiceOrder', 'createServiceOrder', reqObj, true, (irReturnData, irReturnError) => {
982
+ // if we received an error or their is no response on the results
983
+ // return an error
984
+ if (irReturnError) {
985
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
986
+ return callback(null, irReturnError);
987
+ }
988
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
989
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createServiceOrder'], null, null, null);
990
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
991
+ return callback(null, errorObj);
992
+ }
993
+
994
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
995
+ // return the response
996
+ return callback(irReturnData, null);
997
+ });
998
+ } catch (ex) {
999
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1000
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1001
+ return callback(null, errorObj);
1002
+ }
1003
+ }
1004
+
1005
+ /**
1006
+ * @function retrieveServiceOrder
1007
+ * @pronghornType method
1008
+ * @name retrieveServiceOrder
1009
+ * @summary retrieveServiceOrder
1010
+ *
1011
+ * @param {string} id - Identifier of the ServiceOrder
1012
+ * @param {string} [fields] - Comma-separated properties to provide in response
1013
+ * @param {getCallback} callback - a callback function to return the result
1014
+ * @return {object} results - An object containing the response of the action
1015
+ *
1016
+ * @route {POST} /retrieveServiceOrder
1017
+ * @roles admin
1018
+ * @task true
1019
+ */
1020
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1021
+ retrieveServiceOrder(id, fields, callback) {
1022
+ const meth = 'adapter-retrieveServiceOrder';
1023
+ const origin = `${this.id}-${meth}`;
1024
+ log.trace(origin);
1025
+
1026
+ if (this.suspended && this.suspendMode === 'error') {
1027
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1028
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1029
+ return callback(null, errorObj);
1030
+ }
1031
+
1032
+ /* HERE IS WHERE YOU VALIDATE DATA */
1033
+ if (id === undefined || id === null || id === '') {
1034
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
1035
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1036
+ return callback(null, errorObj);
1037
+ }
1038
+
1039
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1040
+ const queryParamsAvailable = { fields };
1041
+ const queryParams = {};
1042
+ const pathVars = [id];
1043
+ const bodyVars = {};
1044
+
1045
+ // loop in template. long callback arg name to avoid identifier conflicts
1046
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1047
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1048
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1049
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1050
+ }
1051
+ });
1052
+
1053
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1054
+ // see adapter code documentation for more information on the request object's fields
1055
+ const reqObj = {
1056
+ payload: bodyVars,
1057
+ uriPathVars: pathVars,
1058
+ uriQuery: queryParams
1059
+ };
1060
+
1061
+ try {
1062
+ // Make the call -
1063
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1064
+ return this.requestHandlerInst.identifyRequest('ServiceOrder', 'retrieveServiceOrder', reqObj, true, (irReturnData, irReturnError) => {
1065
+ // if we received an error or their is no response on the results
1066
+ // return an error
1067
+ if (irReturnError) {
1068
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1069
+ return callback(null, irReturnError);
1070
+ }
1071
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1072
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveServiceOrder'], null, null, null);
1073
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1074
+ return callback(null, errorObj);
1075
+ }
1076
+
1077
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1078
+ // return the response
1079
+ return callback(irReturnData, null);
1080
+ });
1081
+ } catch (ex) {
1082
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1083
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1084
+ return callback(null, errorObj);
1085
+ }
1086
+ }
1087
+
1088
+ /**
1089
+ * @function deleteServiceOrder
1090
+ * @pronghornType method
1091
+ * @name deleteServiceOrder
1092
+ * @summary deleteServiceOrder
1093
+ *
1094
+ * @param {string} id - Identifier of the ServiceOrder
1095
+ * @param {getCallback} callback - a callback function to return the result
1096
+ * @return {object} results - An object containing the response of the action
1097
+ *
1098
+ * @route {POST} /deleteServiceOrder
1099
+ * @roles admin
1100
+ * @task true
1101
+ */
1102
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1103
+ deleteServiceOrder(id, callback) {
1104
+ const meth = 'adapter-deleteServiceOrder';
1105
+ const origin = `${this.id}-${meth}`;
1106
+ log.trace(origin);
1107
+
1108
+ if (this.suspended && this.suspendMode === 'error') {
1109
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1110
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1111
+ return callback(null, errorObj);
1112
+ }
1113
+
1114
+ /* HERE IS WHERE YOU VALIDATE DATA */
1115
+ if (id === undefined || id === null || id === '') {
1116
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
1117
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1118
+ return callback(null, errorObj);
1119
+ }
1120
+
1121
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1122
+ const queryParamsAvailable = {};
1123
+ const queryParams = {};
1124
+ const pathVars = [id];
1125
+ const bodyVars = {};
1126
+
1127
+ // loop in template. long callback arg name to avoid identifier conflicts
1128
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1129
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1130
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1131
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1132
+ }
1133
+ });
1134
+
1135
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1136
+ // see adapter code documentation for more information on the request object's fields
1137
+ const reqObj = {
1138
+ payload: bodyVars,
1139
+ uriPathVars: pathVars,
1140
+ uriQuery: queryParams
1141
+ };
1142
+
1143
+ try {
1144
+ // Make the call -
1145
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1146
+ return this.requestHandlerInst.identifyRequest('ServiceOrder', 'deleteServiceOrder', reqObj, false, (irReturnData, irReturnError) => {
1147
+ // if we received an error or their is no response on the results
1148
+ // return an error
1149
+ if (irReturnError) {
1150
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1151
+ return callback(null, irReturnError);
1152
+ }
1153
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1154
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteServiceOrder'], null, null, null);
1155
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1156
+ return callback(null, errorObj);
1157
+ }
1158
+
1159
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1160
+ // return the response
1161
+ return callback(irReturnData, null);
1162
+ });
1163
+ } catch (ex) {
1164
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1165
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1166
+ return callback(null, errorObj);
1167
+ }
1168
+ }
1169
+
1170
+ /**
1171
+ * @function patchServiceOrder
1172
+ * @pronghornType method
1173
+ * @name patchServiceOrder
1174
+ * @summary patchServiceOrder
1175
+ *
1176
+ * @param {string} id - Identifier of the ServiceOrder
1177
+ * @param {object} body - The ServiceOrder to be updated
1178
+ * @param {getCallback} callback - a callback function to return the result
1179
+ * @return {object} results - An object containing the response of the action
1180
+ *
1181
+ * @route {POST} /patchServiceOrder
1182
+ * @roles admin
1183
+ * @task true
1184
+ */
1185
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1186
+ patchServiceOrder(id, body, callback) {
1187
+ const meth = 'adapter-patchServiceOrder';
1188
+ const origin = `${this.id}-${meth}`;
1189
+ log.trace(origin);
1190
+
1191
+ if (this.suspended && this.suspendMode === 'error') {
1192
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1193
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1194
+ return callback(null, errorObj);
1195
+ }
1196
+
1197
+ /* HERE IS WHERE YOU VALIDATE DATA */
1198
+ if (id === undefined || id === null || id === '') {
1199
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
1200
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1201
+ return callback(null, errorObj);
1202
+ }
1203
+ if (body === undefined || body === null || body === '') {
1204
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1205
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1206
+ return callback(null, errorObj);
1207
+ }
1208
+
1209
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1210
+ const queryParamsAvailable = {};
1211
+ const queryParams = {};
1212
+ const pathVars = [id];
1213
+ const bodyVars = body;
1214
+
1215
+ // loop in template. long callback arg name to avoid identifier conflicts
1216
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1217
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1218
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1219
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1220
+ }
1221
+ });
1222
+
1223
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1224
+ // see adapter code documentation for more information on the request object's fields
1225
+ const reqObj = {
1226
+ payload: bodyVars,
1227
+ uriPathVars: pathVars,
1228
+ uriQuery: queryParams
1229
+ };
1230
+
1231
+ try {
1232
+ // Make the call -
1233
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1234
+ return this.requestHandlerInst.identifyRequest('ServiceOrder', 'patchServiceOrder', reqObj, false, (irReturnData, irReturnError) => {
1235
+ // if we received an error or their is no response on the results
1236
+ // return an error
1237
+ if (irReturnError) {
1238
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1239
+ return callback(null, irReturnError);
1240
+ }
1241
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1242
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchServiceOrder'], null, null, null);
1243
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1244
+ return callback(null, errorObj);
1245
+ }
1246
+
1247
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1248
+ // return the response
1249
+ return callback(irReturnData, null);
1250
+ });
1251
+ } catch (ex) {
1252
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1253
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1254
+ return callback(null, errorObj);
1255
+ }
1256
+ }
1257
+
1258
+ /**
1259
+ * @function listCancelServiceOrder
1260
+ * @pronghornType method
1261
+ * @name listCancelServiceOrder
1262
+ * @summary listCancelServiceOrder
1263
+ *
1264
+ * @param {string} [fields] - Comma-separated properties to be provided in response
1265
+ * @param {number} [offset] - Requested index for start of resources to be provided in response
1266
+ * @param {number} [limit] - Requested number of resources to be provided in response
1267
+ * @param {getCallback} callback - a callback function to return the result
1268
+ * @return {object} results - An object containing the response of the action
1269
+ *
1270
+ * @route {POST} /listCancelServiceOrder
1271
+ * @roles admin
1272
+ * @task true
1273
+ */
1274
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1275
+ listCancelServiceOrder(fields, offset, limit, callback) {
1276
+ const meth = 'adapter-listCancelServiceOrder';
1277
+ const origin = `${this.id}-${meth}`;
1278
+ log.trace(origin);
1279
+
1280
+ if (this.suspended && this.suspendMode === 'error') {
1281
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1282
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1283
+ return callback(null, errorObj);
1284
+ }
1285
+
1286
+ /* HERE IS WHERE YOU VALIDATE DATA */
1287
+
1288
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1289
+ const queryParamsAvailable = { fields, offset, limit };
1290
+ const queryParams = {};
1291
+ const pathVars = [];
1292
+ const bodyVars = {};
1293
+
1294
+ // loop in template. long callback arg name to avoid identifier conflicts
1295
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1296
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1297
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1298
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1299
+ }
1300
+ });
1301
+
1302
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1303
+ // see adapter code documentation for more information on the request object's fields
1304
+ const reqObj = {
1305
+ payload: bodyVars,
1306
+ uriPathVars: pathVars,
1307
+ uriQuery: queryParams
1308
+ };
1309
+
1310
+ try {
1311
+ // Make the call -
1312
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1313
+ return this.requestHandlerInst.identifyRequest('CancelServiceOrder', 'listCancelServiceOrder', reqObj, true, (irReturnData, irReturnError) => {
1314
+ // if we received an error or their is no response on the results
1315
+ // return an error
1316
+ if (irReturnError) {
1317
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1318
+ return callback(null, irReturnError);
1319
+ }
1320
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1321
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCancelServiceOrder'], null, null, null);
1322
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1323
+ return callback(null, errorObj);
1324
+ }
1325
+
1326
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1327
+ // return the response
1328
+ return callback(irReturnData, null);
1329
+ });
1330
+ } catch (ex) {
1331
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1332
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1333
+ return callback(null, errorObj);
1334
+ }
1335
+ }
1336
+
1337
+ /**
1338
+ * @function createCancelServiceOrder
1339
+ * @pronghornType method
1340
+ * @name createCancelServiceOrder
1341
+ * @summary createCancelServiceOrder
1342
+ *
1343
+ * @param {object} body - The CancelServiceOrder to be created
1344
+ * @param {getCallback} callback - a callback function to return the result
1345
+ * @return {object} results - An object containing the response of the action
1346
+ *
1347
+ * @route {POST} /createCancelServiceOrder
1348
+ * @roles admin
1349
+ * @task true
1350
+ */
1351
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1352
+ createCancelServiceOrder(body, callback) {
1353
+ const meth = 'adapter-createCancelServiceOrder';
1354
+ const origin = `${this.id}-${meth}`;
1355
+ log.trace(origin);
1356
+
1357
+ if (this.suspended && this.suspendMode === 'error') {
1358
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1359
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1360
+ return callback(null, errorObj);
1361
+ }
1362
+
1363
+ /* HERE IS WHERE YOU VALIDATE DATA */
1364
+ if (body === undefined || body === null || body === '') {
1365
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1366
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1367
+ return callback(null, errorObj);
1368
+ }
1369
+
1370
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1371
+ const queryParamsAvailable = {};
1372
+ const queryParams = {};
1373
+ const pathVars = [];
1374
+ const bodyVars = body;
1375
+
1376
+ // loop in template. long callback arg name to avoid identifier conflicts
1377
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1378
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1379
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1380
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1381
+ }
1382
+ });
1383
+
1384
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1385
+ // see adapter code documentation for more information on the request object's fields
1386
+ const reqObj = {
1387
+ payload: bodyVars,
1388
+ uriPathVars: pathVars,
1389
+ uriQuery: queryParams
1390
+ };
1391
+
1392
+ try {
1393
+ // Make the call -
1394
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1395
+ return this.requestHandlerInst.identifyRequest('CancelServiceOrder', 'createCancelServiceOrder', reqObj, true, (irReturnData, irReturnError) => {
1396
+ // if we received an error or their is no response on the results
1397
+ // return an error
1398
+ if (irReturnError) {
1399
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1400
+ return callback(null, irReturnError);
1401
+ }
1402
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1403
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createCancelServiceOrder'], null, null, null);
1404
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1405
+ return callback(null, errorObj);
1406
+ }
1407
+
1408
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1409
+ // return the response
1410
+ return callback(irReturnData, null);
1411
+ });
1412
+ } catch (ex) {
1413
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1414
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1415
+ return callback(null, errorObj);
1416
+ }
1417
+ }
1418
+
1419
+ /**
1420
+ * @function retrieveCancelServiceOrder
1421
+ * @pronghornType method
1422
+ * @name retrieveCancelServiceOrder
1423
+ * @summary retrieveCancelServiceOrder
1424
+ *
1425
+ * @param {string} id - Identifier of the CancelServiceOrder
1426
+ * @param {string} [fields] - Comma-separated properties to provide in response
1427
+ * @param {getCallback} callback - a callback function to return the result
1428
+ * @return {object} results - An object containing the response of the action
1429
+ *
1430
+ * @route {POST} /retrieveCancelServiceOrder
1431
+ * @roles admin
1432
+ * @task true
1433
+ */
1434
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1435
+ retrieveCancelServiceOrder(id, fields, callback) {
1436
+ const meth = 'adapter-retrieveCancelServiceOrder';
1437
+ const origin = `${this.id}-${meth}`;
1438
+ log.trace(origin);
1439
+
1440
+ if (this.suspended && this.suspendMode === 'error') {
1441
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1442
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1443
+ return callback(null, errorObj);
1444
+ }
1445
+
1446
+ /* HERE IS WHERE YOU VALIDATE DATA */
1447
+ if (id === undefined || id === null || id === '') {
1448
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
1449
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1450
+ return callback(null, errorObj);
1451
+ }
1452
+
1453
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1454
+ const queryParamsAvailable = { fields };
1455
+ const queryParams = {};
1456
+ const pathVars = [id];
1457
+ const bodyVars = {};
1458
+
1459
+ // loop in template. long callback arg name to avoid identifier conflicts
1460
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1461
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1462
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1463
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1464
+ }
1465
+ });
1466
+
1467
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1468
+ // see adapter code documentation for more information on the request object's fields
1469
+ const reqObj = {
1470
+ payload: bodyVars,
1471
+ uriPathVars: pathVars,
1472
+ uriQuery: queryParams
1473
+ };
1474
+
1475
+ try {
1476
+ // Make the call -
1477
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1478
+ return this.requestHandlerInst.identifyRequest('CancelServiceOrder', 'retrieveCancelServiceOrder', reqObj, true, (irReturnData, irReturnError) => {
1479
+ // if we received an error or their is no response on the results
1480
+ // return an error
1481
+ if (irReturnError) {
1482
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1483
+ return callback(null, irReturnError);
1484
+ }
1485
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1486
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveCancelServiceOrder'], null, null, null);
1487
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1488
+ return callback(null, errorObj);
1489
+ }
1490
+
1491
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1492
+ // return the response
1493
+ return callback(irReturnData, null);
1494
+ });
1495
+ } catch (ex) {
1496
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1497
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1498
+ return callback(null, errorObj);
1499
+ }
1500
+ }
1501
+
1502
+ /**
1503
+ * @function listenToServiceOrderCreateEvent
1504
+ * @pronghornType method
1505
+ * @name listenToServiceOrderCreateEvent
1506
+ * @summary listenToServiceOrderCreateEvent
1507
+ *
1508
+ * @param {object} body - The event data
1509
+ * @param {getCallback} callback - a callback function to return the result
1510
+ * @return {object} results - An object containing the response of the action
1511
+ *
1512
+ * @route {POST} /listenToServiceOrderCreateEvent
1513
+ * @roles admin
1514
+ * @task true
1515
+ */
1516
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1517
+ listenToServiceOrderCreateEvent(body, callback) {
1518
+ const meth = 'adapter-listenToServiceOrderCreateEvent';
1519
+ const origin = `${this.id}-${meth}`;
1520
+ log.trace(origin);
1521
+
1522
+ if (this.suspended && this.suspendMode === 'error') {
1523
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1524
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1525
+ return callback(null, errorObj);
1526
+ }
1527
+
1528
+ /* HERE IS WHERE YOU VALIDATE DATA */
1529
+ if (body === undefined || body === null || body === '') {
1530
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1531
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1532
+ return callback(null, errorObj);
1533
+ }
1534
+
1535
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1536
+ const queryParamsAvailable = {};
1537
+ const queryParams = {};
1538
+ const pathVars = [];
1539
+ const bodyVars = body;
1540
+
1541
+ // loop in template. long callback arg name to avoid identifier conflicts
1542
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1543
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1544
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1545
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1546
+ }
1547
+ });
1548
+
1549
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1550
+ // see adapter code documentation for more information on the request object's fields
1551
+ const reqObj = {
1552
+ payload: bodyVars,
1553
+ uriPathVars: pathVars,
1554
+ uriQuery: queryParams
1555
+ };
1556
+
1557
+ try {
1558
+ // Make the call -
1559
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1560
+ return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToServiceOrderCreateEvent', reqObj, true, (irReturnData, irReturnError) => {
1561
+ // if we received an error or their is no response on the results
1562
+ // return an error
1563
+ if (irReturnError) {
1564
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1565
+ return callback(null, irReturnError);
1566
+ }
1567
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1568
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToServiceOrderCreateEvent'], null, null, null);
1569
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1570
+ return callback(null, errorObj);
1571
+ }
1572
+
1573
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1574
+ // return the response
1575
+ return callback(irReturnData, null);
1576
+ });
1577
+ } catch (ex) {
1578
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1579
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1580
+ return callback(null, errorObj);
1581
+ }
1582
+ }
1583
+
1584
+ /**
1585
+ * @function listenToServiceOrderAttributeValueChangeEvent
1586
+ * @pronghornType method
1587
+ * @name listenToServiceOrderAttributeValueChangeEvent
1588
+ * @summary listenToServiceOrderAttributeValueChangeEvent
1589
+ *
1590
+ * @param {object} body - The event data
1591
+ * @param {getCallback} callback - a callback function to return the result
1592
+ * @return {object} results - An object containing the response of the action
1593
+ *
1594
+ * @route {POST} /listenToServiceOrderAttributeValueChangeEvent
1595
+ * @roles admin
1596
+ * @task true
1597
+ */
1598
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1599
+ listenToServiceOrderAttributeValueChangeEvent(body, callback) {
1600
+ const meth = 'adapter-listenToServiceOrderAttributeValueChangeEvent';
1601
+ const origin = `${this.id}-${meth}`;
1602
+ log.trace(origin);
1603
+
1604
+ if (this.suspended && this.suspendMode === 'error') {
1605
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1606
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1607
+ return callback(null, errorObj);
1608
+ }
1609
+
1610
+ /* HERE IS WHERE YOU VALIDATE DATA */
1611
+ if (body === undefined || body === null || body === '') {
1612
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1613
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1614
+ return callback(null, errorObj);
1615
+ }
1616
+
1617
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1618
+ const queryParamsAvailable = {};
1619
+ const queryParams = {};
1620
+ const pathVars = [];
1621
+ const bodyVars = body;
1622
+
1623
+ // loop in template. long callback arg name to avoid identifier conflicts
1624
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1625
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1626
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1627
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1628
+ }
1629
+ });
1630
+
1631
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1632
+ // see adapter code documentation for more information on the request object's fields
1633
+ const reqObj = {
1634
+ payload: bodyVars,
1635
+ uriPathVars: pathVars,
1636
+ uriQuery: queryParams
1637
+ };
1638
+
1639
+ try {
1640
+ // Make the call -
1641
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1642
+ return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToServiceOrderAttributeValueChangeEvent', reqObj, true, (irReturnData, irReturnError) => {
1643
+ // if we received an error or their is no response on the results
1644
+ // return an error
1645
+ if (irReturnError) {
1646
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1647
+ return callback(null, irReturnError);
1648
+ }
1649
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1650
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToServiceOrderAttributeValueChangeEvent'], null, null, null);
1651
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1652
+ return callback(null, errorObj);
1653
+ }
1654
+
1655
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1656
+ // return the response
1657
+ return callback(irReturnData, null);
1658
+ });
1659
+ } catch (ex) {
1660
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1661
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1662
+ return callback(null, errorObj);
1663
+ }
1664
+ }
1665
+
1666
+ /**
1667
+ * @function listenToServiceOrderStateChangeEvent
1668
+ * @pronghornType method
1669
+ * @name listenToServiceOrderStateChangeEvent
1670
+ * @summary listenToServiceOrderStateChangeEvent
1671
+ *
1672
+ * @param {object} body - The event data
1673
+ * @param {getCallback} callback - a callback function to return the result
1674
+ * @return {object} results - An object containing the response of the action
1675
+ *
1676
+ * @route {POST} /listenToServiceOrderStateChangeEvent
1677
+ * @roles admin
1678
+ * @task true
1679
+ */
1680
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1681
+ listenToServiceOrderStateChangeEvent(body, callback) {
1682
+ const meth = 'adapter-listenToServiceOrderStateChangeEvent';
1683
+ const origin = `${this.id}-${meth}`;
1684
+ log.trace(origin);
1685
+
1686
+ if (this.suspended && this.suspendMode === 'error') {
1687
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1688
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1689
+ return callback(null, errorObj);
1690
+ }
1691
+
1692
+ /* HERE IS WHERE YOU VALIDATE DATA */
1693
+ if (body === undefined || body === null || body === '') {
1694
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1695
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1696
+ return callback(null, errorObj);
1697
+ }
1698
+
1699
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1700
+ const queryParamsAvailable = {};
1701
+ const queryParams = {};
1702
+ const pathVars = [];
1703
+ const bodyVars = body;
1704
+
1705
+ // loop in template. long callback arg name to avoid identifier conflicts
1706
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1707
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1708
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1709
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1710
+ }
1711
+ });
1712
+
1713
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1714
+ // see adapter code documentation for more information on the request object's fields
1715
+ const reqObj = {
1716
+ payload: bodyVars,
1717
+ uriPathVars: pathVars,
1718
+ uriQuery: queryParams
1719
+ };
1720
+
1721
+ try {
1722
+ // Make the call -
1723
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1724
+ return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToServiceOrderStateChangeEvent', reqObj, true, (irReturnData, irReturnError) => {
1725
+ // if we received an error or their is no response on the results
1726
+ // return an error
1727
+ if (irReturnError) {
1728
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1729
+ return callback(null, irReturnError);
1730
+ }
1731
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1732
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToServiceOrderStateChangeEvent'], null, null, null);
1733
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1734
+ return callback(null, errorObj);
1735
+ }
1736
+
1737
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1738
+ // return the response
1739
+ return callback(irReturnData, null);
1740
+ });
1741
+ } catch (ex) {
1742
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1743
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1744
+ return callback(null, errorObj);
1745
+ }
1746
+ }
1747
+
1748
+ /**
1749
+ * @function listenToServiceOrderDeleteEvent
1750
+ * @pronghornType method
1751
+ * @name listenToServiceOrderDeleteEvent
1752
+ * @summary listenToServiceOrderDeleteEvent
1753
+ *
1754
+ * @param {object} body - The event data
1755
+ * @param {getCallback} callback - a callback function to return the result
1756
+ * @return {object} results - An object containing the response of the action
1757
+ *
1758
+ * @route {POST} /listenToServiceOrderDeleteEvent
1759
+ * @roles admin
1760
+ * @task true
1761
+ */
1762
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1763
+ listenToServiceOrderDeleteEvent(body, callback) {
1764
+ const meth = 'adapter-listenToServiceOrderDeleteEvent';
1765
+ const origin = `${this.id}-${meth}`;
1766
+ log.trace(origin);
1767
+
1768
+ if (this.suspended && this.suspendMode === 'error') {
1769
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1770
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1771
+ return callback(null, errorObj);
1772
+ }
1773
+
1774
+ /* HERE IS WHERE YOU VALIDATE DATA */
1775
+ if (body === undefined || body === null || body === '') {
1776
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1777
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1778
+ return callback(null, errorObj);
1779
+ }
1780
+
1781
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1782
+ const queryParamsAvailable = {};
1783
+ const queryParams = {};
1784
+ const pathVars = [];
1785
+ const bodyVars = body;
1786
+
1787
+ // loop in template. long callback arg name to avoid identifier conflicts
1788
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1789
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1790
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1791
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1792
+ }
1793
+ });
1794
+
1795
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1796
+ // see adapter code documentation for more information on the request object's fields
1797
+ const reqObj = {
1798
+ payload: bodyVars,
1799
+ uriPathVars: pathVars,
1800
+ uriQuery: queryParams
1801
+ };
1802
+
1803
+ try {
1804
+ // Make the call -
1805
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1806
+ return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToServiceOrderDeleteEvent', reqObj, true, (irReturnData, irReturnError) => {
1807
+ // if we received an error or their is no response on the results
1808
+ // return an error
1809
+ if (irReturnError) {
1810
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1811
+ return callback(null, irReturnError);
1812
+ }
1813
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1814
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToServiceOrderDeleteEvent'], null, null, null);
1815
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1816
+ return callback(null, errorObj);
1817
+ }
1818
+
1819
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1820
+ // return the response
1821
+ return callback(irReturnData, null);
1822
+ });
1823
+ } catch (ex) {
1824
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1825
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1826
+ return callback(null, errorObj);
1827
+ }
1828
+ }
1829
+
1830
+ /**
1831
+ * @function listenToServiceOrderInformationRequiredEvent
1832
+ * @pronghornType method
1833
+ * @name listenToServiceOrderInformationRequiredEvent
1834
+ * @summary listenToServiceOrderInformationRequiredEvent
1835
+ *
1836
+ * @param {object} body - The event data
1837
+ * @param {getCallback} callback - a callback function to return the result
1838
+ * @return {object} results - An object containing the response of the action
1839
+ *
1840
+ * @route {POST} /listenToServiceOrderInformationRequiredEvent
1841
+ * @roles admin
1842
+ * @task true
1843
+ */
1844
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1845
+ listenToServiceOrderInformationRequiredEvent(body, callback) {
1846
+ const meth = 'adapter-listenToServiceOrderInformationRequiredEvent';
1847
+ const origin = `${this.id}-${meth}`;
1848
+ log.trace(origin);
1849
+
1850
+ if (this.suspended && this.suspendMode === 'error') {
1851
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1852
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1853
+ return callback(null, errorObj);
1854
+ }
1855
+
1856
+ /* HERE IS WHERE YOU VALIDATE DATA */
1857
+ if (body === undefined || body === null || body === '') {
1858
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1859
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1860
+ return callback(null, errorObj);
1861
+ }
1862
+
1863
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1864
+ const queryParamsAvailable = {};
1865
+ const queryParams = {};
1866
+ const pathVars = [];
1867
+ const bodyVars = body;
1868
+
1869
+ // loop in template. long callback arg name to avoid identifier conflicts
1870
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1871
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1872
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1873
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1874
+ }
1875
+ });
1876
+
1877
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1878
+ // see adapter code documentation for more information on the request object's fields
1879
+ const reqObj = {
1880
+ payload: bodyVars,
1881
+ uriPathVars: pathVars,
1882
+ uriQuery: queryParams
1883
+ };
1884
+
1885
+ try {
1886
+ // Make the call -
1887
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1888
+ return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToServiceOrderInformationRequiredEvent', reqObj, true, (irReturnData, irReturnError) => {
1889
+ // if we received an error or their is no response on the results
1890
+ // return an error
1891
+ if (irReturnError) {
1892
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1893
+ return callback(null, irReturnError);
1894
+ }
1895
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1896
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToServiceOrderInformationRequiredEvent'], null, null, null);
1897
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1898
+ return callback(null, errorObj);
1899
+ }
1900
+
1901
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1902
+ // return the response
1903
+ return callback(irReturnData, null);
1904
+ });
1905
+ } catch (ex) {
1906
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1907
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1908
+ return callback(null, errorObj);
1909
+ }
1910
+ }
1911
+
1912
+ /**
1913
+ * @function listenToServiceOrderMilestoneEvent
1914
+ * @pronghornType method
1915
+ * @name listenToServiceOrderMilestoneEvent
1916
+ * @summary listenToServiceOrderMilestoneEvent
1917
+ *
1918
+ * @param {object} body - The event data
1919
+ * @param {getCallback} callback - a callback function to return the result
1920
+ * @return {object} results - An object containing the response of the action
1921
+ *
1922
+ * @route {POST} /listenToServiceOrderMilestoneEvent
1923
+ * @roles admin
1924
+ * @task true
1925
+ */
1926
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1927
+ listenToServiceOrderMilestoneEvent(body, callback) {
1928
+ const meth = 'adapter-listenToServiceOrderMilestoneEvent';
1929
+ const origin = `${this.id}-${meth}`;
1930
+ log.trace(origin);
1931
+
1932
+ if (this.suspended && this.suspendMode === 'error') {
1933
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1934
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1935
+ return callback(null, errorObj);
1936
+ }
1937
+
1938
+ /* HERE IS WHERE YOU VALIDATE DATA */
1939
+ if (body === undefined || body === null || body === '') {
1940
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1941
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1942
+ return callback(null, errorObj);
1943
+ }
1944
+
1945
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1946
+ const queryParamsAvailable = {};
1947
+ const queryParams = {};
1948
+ const pathVars = [];
1949
+ const bodyVars = body;
1950
+
1951
+ // loop in template. long callback arg name to avoid identifier conflicts
1952
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1953
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1954
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1955
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1956
+ }
1957
+ });
1958
+
1959
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1960
+ // see adapter code documentation for more information on the request object's fields
1961
+ const reqObj = {
1962
+ payload: bodyVars,
1963
+ uriPathVars: pathVars,
1964
+ uriQuery: queryParams
1965
+ };
1966
+
1967
+ try {
1968
+ // Make the call -
1969
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1970
+ return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToServiceOrderMilestoneEvent', reqObj, true, (irReturnData, irReturnError) => {
1971
+ // if we received an error or their is no response on the results
1972
+ // return an error
1973
+ if (irReturnError) {
1974
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1975
+ return callback(null, irReturnError);
1976
+ }
1977
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1978
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToServiceOrderMilestoneEvent'], null, null, null);
1979
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1980
+ return callback(null, errorObj);
1981
+ }
1982
+
1983
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1984
+ // return the response
1985
+ return callback(irReturnData, null);
1986
+ });
1987
+ } catch (ex) {
1988
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1989
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1990
+ return callback(null, errorObj);
1991
+ }
1992
+ }
1993
+
1994
+ /**
1995
+ * @function listenToServiceOrderJeopardyEvent
1996
+ * @pronghornType method
1997
+ * @name listenToServiceOrderJeopardyEvent
1998
+ * @summary listenToServiceOrderJeopardyEvent
1999
+ *
2000
+ * @param {object} body - The event data
2001
+ * @param {getCallback} callback - a callback function to return the result
2002
+ * @return {object} results - An object containing the response of the action
2003
+ *
2004
+ * @route {POST} /listenToServiceOrderJeopardyEvent
2005
+ * @roles admin
2006
+ * @task true
2007
+ */
2008
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2009
+ listenToServiceOrderJeopardyEvent(body, callback) {
2010
+ const meth = 'adapter-listenToServiceOrderJeopardyEvent';
2011
+ const origin = `${this.id}-${meth}`;
2012
+ log.trace(origin);
2013
+
2014
+ if (this.suspended && this.suspendMode === 'error') {
2015
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2016
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2017
+ return callback(null, errorObj);
2018
+ }
2019
+
2020
+ /* HERE IS WHERE YOU VALIDATE DATA */
2021
+ if (body === undefined || body === null || body === '') {
2022
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2023
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2024
+ return callback(null, errorObj);
2025
+ }
2026
+
2027
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2028
+ const queryParamsAvailable = {};
2029
+ const queryParams = {};
2030
+ const pathVars = [];
2031
+ const bodyVars = body;
2032
+
2033
+ // loop in template. long callback arg name to avoid identifier conflicts
2034
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2035
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2036
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2037
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2038
+ }
2039
+ });
2040
+
2041
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2042
+ // see adapter code documentation for more information on the request object's fields
2043
+ const reqObj = {
2044
+ payload: bodyVars,
2045
+ uriPathVars: pathVars,
2046
+ uriQuery: queryParams
2047
+ };
2048
+
2049
+ try {
2050
+ // Make the call -
2051
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2052
+ return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToServiceOrderJeopardyEvent', reqObj, true, (irReturnData, irReturnError) => {
2053
+ // if we received an error or their is no response on the results
2054
+ // return an error
2055
+ if (irReturnError) {
2056
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2057
+ return callback(null, irReturnError);
2058
+ }
2059
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2060
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToServiceOrderJeopardyEvent'], null, null, null);
2061
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2062
+ return callback(null, errorObj);
2063
+ }
2064
+
2065
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2066
+ // return the response
2067
+ return callback(irReturnData, null);
2068
+ });
2069
+ } catch (ex) {
2070
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2071
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2072
+ return callback(null, errorObj);
2073
+ }
2074
+ }
2075
+
2076
+ /**
2077
+ * @function listenToCancelServiceOrderCreateEvent
2078
+ * @pronghornType method
2079
+ * @name listenToCancelServiceOrderCreateEvent
2080
+ * @summary listenToCancelServiceOrderCreateEvent
2081
+ *
2082
+ * @param {object} body - The event data
2083
+ * @param {getCallback} callback - a callback function to return the result
2084
+ * @return {object} results - An object containing the response of the action
2085
+ *
2086
+ * @route {POST} /listenToCancelServiceOrderCreateEvent
2087
+ * @roles admin
2088
+ * @task true
2089
+ */
2090
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2091
+ listenToCancelServiceOrderCreateEvent(body, callback) {
2092
+ const meth = 'adapter-listenToCancelServiceOrderCreateEvent';
2093
+ const origin = `${this.id}-${meth}`;
2094
+ log.trace(origin);
2095
+
2096
+ if (this.suspended && this.suspendMode === 'error') {
2097
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2098
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2099
+ return callback(null, errorObj);
2100
+ }
2101
+
2102
+ /* HERE IS WHERE YOU VALIDATE DATA */
2103
+ if (body === undefined || body === null || body === '') {
2104
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2105
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2106
+ return callback(null, errorObj);
2107
+ }
2108
+
2109
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2110
+ const queryParamsAvailable = {};
2111
+ const queryParams = {};
2112
+ const pathVars = [];
2113
+ const bodyVars = body;
2114
+
2115
+ // loop in template. long callback arg name to avoid identifier conflicts
2116
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2117
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2118
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2119
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2120
+ }
2121
+ });
2122
+
2123
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2124
+ // see adapter code documentation for more information on the request object's fields
2125
+ const reqObj = {
2126
+ payload: bodyVars,
2127
+ uriPathVars: pathVars,
2128
+ uriQuery: queryParams
2129
+ };
2130
+
2131
+ try {
2132
+ // Make the call -
2133
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2134
+ return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToCancelServiceOrderCreateEvent', reqObj, true, (irReturnData, irReturnError) => {
2135
+ // if we received an error or their is no response on the results
2136
+ // return an error
2137
+ if (irReturnError) {
2138
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2139
+ return callback(null, irReturnError);
2140
+ }
2141
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2142
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToCancelServiceOrderCreateEvent'], null, null, null);
2143
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2144
+ return callback(null, errorObj);
2145
+ }
2146
+
2147
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2148
+ // return the response
2149
+ return callback(irReturnData, null);
2150
+ });
2151
+ } catch (ex) {
2152
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2153
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2154
+ return callback(null, errorObj);
2155
+ }
2156
+ }
2157
+
2158
+ /**
2159
+ * @function listenToCancelServiceOrderStateChangeEvent
2160
+ * @pronghornType method
2161
+ * @name listenToCancelServiceOrderStateChangeEvent
2162
+ * @summary listenToCancelServiceOrderStateChangeEvent
2163
+ *
2164
+ * @param {object} body - The event data
2165
+ * @param {getCallback} callback - a callback function to return the result
2166
+ * @return {object} results - An object containing the response of the action
2167
+ *
2168
+ * @route {POST} /listenToCancelServiceOrderStateChangeEvent
2169
+ * @roles admin
2170
+ * @task true
2171
+ */
2172
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2173
+ listenToCancelServiceOrderStateChangeEvent(body, callback) {
2174
+ const meth = 'adapter-listenToCancelServiceOrderStateChangeEvent';
2175
+ const origin = `${this.id}-${meth}`;
2176
+ log.trace(origin);
2177
+
2178
+ if (this.suspended && this.suspendMode === 'error') {
2179
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2180
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2181
+ return callback(null, errorObj);
2182
+ }
2183
+
2184
+ /* HERE IS WHERE YOU VALIDATE DATA */
2185
+ if (body === undefined || body === null || body === '') {
2186
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2187
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2188
+ return callback(null, errorObj);
2189
+ }
2190
+
2191
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2192
+ const queryParamsAvailable = {};
2193
+ const queryParams = {};
2194
+ const pathVars = [];
2195
+ const bodyVars = body;
2196
+
2197
+ // loop in template. long callback arg name to avoid identifier conflicts
2198
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2199
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2200
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2201
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2202
+ }
2203
+ });
2204
+
2205
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2206
+ // see adapter code documentation for more information on the request object's fields
2207
+ const reqObj = {
2208
+ payload: bodyVars,
2209
+ uriPathVars: pathVars,
2210
+ uriQuery: queryParams
2211
+ };
2212
+
2213
+ try {
2214
+ // Make the call -
2215
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2216
+ return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToCancelServiceOrderStateChangeEvent', reqObj, true, (irReturnData, irReturnError) => {
2217
+ // if we received an error or their is no response on the results
2218
+ // return an error
2219
+ if (irReturnError) {
2220
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2221
+ return callback(null, irReturnError);
2222
+ }
2223
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2224
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToCancelServiceOrderStateChangeEvent'], null, null, null);
2225
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2226
+ return callback(null, errorObj);
2227
+ }
2228
+
2229
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2230
+ // return the response
2231
+ return callback(irReturnData, null);
2232
+ });
2233
+ } catch (ex) {
2234
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2235
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2236
+ return callback(null, errorObj);
2237
+ }
2238
+ }
2239
+
2240
+ /**
2241
+ * @function listenToCancelServiceOrderInformationRequiredEvent
2242
+ * @pronghornType method
2243
+ * @name listenToCancelServiceOrderInformationRequiredEvent
2244
+ * @summary listenToCancelServiceOrderInformationRequiredEvent
2245
+ *
2246
+ * @param {object} body - The event data
2247
+ * @param {getCallback} callback - a callback function to return the result
2248
+ * @return {object} results - An object containing the response of the action
2249
+ *
2250
+ * @route {POST} /listenToCancelServiceOrderInformationRequiredEvent
2251
+ * @roles admin
2252
+ * @task true
2253
+ */
2254
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2255
+ listenToCancelServiceOrderInformationRequiredEvent(body, callback) {
2256
+ const meth = 'adapter-listenToCancelServiceOrderInformationRequiredEvent';
2257
+ const origin = `${this.id}-${meth}`;
2258
+ log.trace(origin);
2259
+
2260
+ if (this.suspended && this.suspendMode === 'error') {
2261
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2262
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2263
+ return callback(null, errorObj);
2264
+ }
2265
+
2266
+ /* HERE IS WHERE YOU VALIDATE DATA */
2267
+ if (body === undefined || body === null || body === '') {
2268
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2269
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2270
+ return callback(null, errorObj);
2271
+ }
2272
+
2273
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2274
+ const queryParamsAvailable = {};
2275
+ const queryParams = {};
2276
+ const pathVars = [];
2277
+ const bodyVars = body;
2278
+
2279
+ // loop in template. long callback arg name to avoid identifier conflicts
2280
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2281
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2282
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2283
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2284
+ }
2285
+ });
2286
+
2287
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2288
+ // see adapter code documentation for more information on the request object's fields
2289
+ const reqObj = {
2290
+ payload: bodyVars,
2291
+ uriPathVars: pathVars,
2292
+ uriQuery: queryParams
2293
+ };
2294
+
2295
+ try {
2296
+ // Make the call -
2297
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2298
+ return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToCancelServiceOrderInformationRequiredEvent', reqObj, true, (irReturnData, irReturnError) => {
2299
+ // if we received an error or their is no response on the results
2300
+ // return an error
2301
+ if (irReturnError) {
2302
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2303
+ return callback(null, irReturnError);
2304
+ }
2305
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2306
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToCancelServiceOrderInformationRequiredEvent'], null, null, null);
2307
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2308
+ return callback(null, errorObj);
2309
+ }
2310
+
2311
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2312
+ // return the response
2313
+ return callback(irReturnData, null);
2314
+ });
2315
+ } catch (ex) {
2316
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2317
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2318
+ return callback(null, errorObj);
2319
+ }
2320
+ }
2321
+
2322
+ /**
2323
+ * @function registerListener
2324
+ * @pronghornType method
2325
+ * @name registerListener
2326
+ * @summary registerListener
2327
+ *
2328
+ * @param {object} body - Data containing the callback endpoint to deliver the information
2329
+ * @param {getCallback} callback - a callback function to return the result
2330
+ * @return {object} results - An object containing the response of the action
2331
+ *
2332
+ * @route {POST} /registerListener
2333
+ * @roles admin
2334
+ * @task true
2335
+ */
2336
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2337
+ registerListener(body, callback) {
2338
+ const meth = 'adapter-registerListener';
2339
+ const origin = `${this.id}-${meth}`;
2340
+ log.trace(origin);
2341
+
2342
+ if (this.suspended && this.suspendMode === 'error') {
2343
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2344
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2345
+ return callback(null, errorObj);
2346
+ }
2347
+
2348
+ /* HERE IS WHERE YOU VALIDATE DATA */
2349
+ if (body === undefined || body === null || body === '') {
2350
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2351
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2352
+ return callback(null, errorObj);
2353
+ }
2354
+
2355
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2356
+ const queryParamsAvailable = {};
2357
+ const queryParams = {};
2358
+ const pathVars = [];
2359
+ const bodyVars = body;
2360
+
2361
+ // loop in template. long callback arg name to avoid identifier conflicts
2362
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2363
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2364
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2365
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2366
+ }
2367
+ });
2368
+
2369
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2370
+ // see adapter code documentation for more information on the request object's fields
2371
+ const reqObj = {
2372
+ payload: bodyVars,
2373
+ uriPathVars: pathVars,
2374
+ uriQuery: queryParams
2375
+ };
2376
+
2377
+ try {
2378
+ // Make the call -
2379
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2380
+ return this.requestHandlerInst.identifyRequest('EventsSubscription', 'registerListener', reqObj, true, (irReturnData, irReturnError) => {
2381
+ // if we received an error or their is no response on the results
2382
+ // return an error
2383
+ if (irReturnError) {
2384
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2385
+ return callback(null, irReturnError);
2386
+ }
2387
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2388
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['registerListener'], null, null, null);
2389
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2390
+ return callback(null, errorObj);
2391
+ }
2392
+
2393
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2394
+ // return the response
2395
+ return callback(irReturnData, null);
2396
+ });
2397
+ } catch (ex) {
2398
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2399
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2400
+ return callback(null, errorObj);
2401
+ }
2402
+ }
2403
+
2404
+ /**
2405
+ * @function unregisterListener
2406
+ * @pronghornType method
2407
+ * @name unregisterListener
2408
+ * @summary unregisterListener
2409
+ *
2410
+ * @param {string} id - The id of the registered listener
2411
+ * @param {getCallback} callback - a callback function to return the result
2412
+ * @return {object} results - An object containing the response of the action
2413
+ *
2414
+ * @route {POST} /unregisterListener
2415
+ * @roles admin
2416
+ * @task true
2417
+ */
2418
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2419
+ unregisterListener(id, callback) {
2420
+ const meth = 'adapter-unregisterListener';
2421
+ const origin = `${this.id}-${meth}`;
2422
+ log.trace(origin);
2423
+
2424
+ if (this.suspended && this.suspendMode === 'error') {
2425
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2426
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2427
+ return callback(null, errorObj);
2428
+ }
2429
+
2430
+ /* HERE IS WHERE YOU VALIDATE DATA */
2431
+ if (id === undefined || id === null || id === '') {
2432
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
2433
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2434
+ return callback(null, errorObj);
2435
+ }
2436
+
2437
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2438
+ const queryParamsAvailable = {};
2439
+ const queryParams = {};
2440
+ const pathVars = [id];
2441
+ const bodyVars = {};
2442
+
2443
+ // loop in template. long callback arg name to avoid identifier conflicts
2444
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2445
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2446
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2447
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2448
+ }
2449
+ });
2450
+
2451
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2452
+ // see adapter code documentation for more information on the request object's fields
2453
+ const reqObj = {
2454
+ payload: bodyVars,
2455
+ uriPathVars: pathVars,
2456
+ uriQuery: queryParams
2457
+ };
2458
+
2459
+ try {
2460
+ // Make the call -
2461
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2462
+ return this.requestHandlerInst.identifyRequest('EventsSubscription', 'unregisterListener', reqObj, false, (irReturnData, irReturnError) => {
2463
+ // if we received an error or their is no response on the results
2464
+ // return an error
2465
+ if (irReturnError) {
2466
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2467
+ return callback(null, irReturnError);
2468
+ }
2469
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2470
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['unregisterListener'], null, null, null);
2471
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2472
+ return callback(null, errorObj);
2473
+ }
2474
+
2475
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2476
+ // return the response
2477
+ return callback(irReturnData, null);
2478
+ });
2479
+ } catch (ex) {
2480
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2481
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2482
+ return callback(null, errorObj);
2483
+ }
2484
+ }
2485
+ }
2486
+
2487
+ module.exports = Tmf641ServiceOrderingManagement;