@itentialopensource/adapter-att_mobility 0.1.2 → 0.2.2

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 (48) hide show
  1. package/.eslintignore +0 -1
  2. package/.jshintrc +3 -0
  3. package/AUTH.md +11 -14
  4. package/BROKER.md +3 -3
  5. package/CALLS.md +59 -23
  6. package/CHANGELOG.md +24 -0
  7. package/CONTRIBUTING.md +1 -160
  8. package/ENHANCE.md +4 -4
  9. package/PROPERTIES.md +19 -19
  10. package/README.md +45 -36
  11. package/SUMMARY.md +2 -2
  12. package/SYSTEMINFO.md +9 -4
  13. package/TROUBLESHOOT.md +6 -6
  14. package/adapter.js +159 -330
  15. package/adapterBase.js +538 -873
  16. package/changelogs/changelog.md +16 -0
  17. package/metadata.json +61 -0
  18. package/package.json +24 -26
  19. package/pronghorn.json +474 -142
  20. package/propertiesSchema.json +447 -43
  21. package/refs?service=git-upload-pack +0 -0
  22. package/report/adapter-openapi.json +149 -0
  23. package/report/adapter-openapi.yaml +133 -0
  24. package/report/adapterInfo.json +8 -8
  25. package/report/updateReport1691508426658.json +120 -0
  26. package/report/updateReport1692202905234.json +120 -0
  27. package/report/updateReport1694465385247.json +120 -0
  28. package/sampleProperties.json +64 -3
  29. package/test/integration/adapterTestBasicGet.js +1 -1
  30. package/test/integration/adapterTestConnectivity.js +91 -42
  31. package/test/integration/adapterTestIntegration.js +142 -17
  32. package/test/unit/adapterBaseTestUnit.js +388 -313
  33. package/test/unit/adapterTestUnit.js +320 -123
  34. package/utils/adapterInfo.js +1 -1
  35. package/utils/addAuth.js +1 -1
  36. package/utils/artifactize.js +1 -1
  37. package/utils/checkMigrate.js +1 -1
  38. package/utils/entitiesToDB.js +1 -0
  39. package/utils/findPath.js +1 -1
  40. package/utils/methodDocumentor.js +57 -22
  41. package/utils/modify.js +13 -15
  42. package/utils/packModificationScript.js +1 -1
  43. package/utils/taskMover.js +309 -0
  44. package/utils/tbScript.js +3 -10
  45. package/utils/tbUtils.js +2 -3
  46. package/utils/testRunner.js +1 -1
  47. package/utils/troubleshootingAdapter.js +1 -3
  48. package/workflows/README.md +0 -3
package/adapter.js CHANGED
@@ -89,10 +89,8 @@ class AttMobility extends AdapterBaseCl {
89
89
  let myIgnore = [
90
90
  'healthCheck',
91
91
  'iapGetAdapterWorkflowFunctions',
92
- 'iapHasAdapterEntity',
93
- 'iapVerifyAdapterCapability',
94
- 'iapUpdateAdapterEntityCache',
95
- 'hasEntities'
92
+ 'hasEntities',
93
+ 'getAuthorization'
96
94
  ];
97
95
  if (!inIgnore && Array.isArray(inIgnore)) {
98
96
  myIgnore = inIgnore;
@@ -118,29 +116,15 @@ class AttMobility extends AdapterBaseCl {
118
116
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
119
117
  * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
120
118
  * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
119
+ * @param {boolean} replace - true to replace entire mock data, false to merge/append
121
120
  * @param {Callback} callback - The results of the call
122
121
  */
123
- iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
122
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
124
123
  const meth = 'adapter-iapUpdateAdapterConfiguration';
125
124
  const origin = `${this.id}-${meth}`;
126
125
  log.trace(origin);
127
126
 
128
- super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
129
- }
130
-
131
- /**
132
- * See if the API path provided is found in this adapter
133
- *
134
- * @function iapFindAdapterPath
135
- * @param {string} apiPath - the api path to check on
136
- * @param {Callback} callback - The results of the call
137
- */
138
- iapFindAdapterPath(apiPath, callback) {
139
- const meth = 'adapter-iapFindAdapterPath';
140
- const origin = `${this.id}-${meth}`;
141
- log.trace(origin);
142
-
143
- super.iapFindAdapterPath(apiPath, callback);
127
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
144
128
  }
145
129
 
146
130
  /**
@@ -182,7 +166,7 @@ class AttMobility extends AdapterBaseCl {
182
166
  }
183
167
 
184
168
  /**
185
- * @summary Get the Adaoter Queue
169
+ * @summary Get the Adapter Queue
186
170
  *
187
171
  * @function iapGetAdapterQueue
188
172
  * @param {Callback} callback - callback function
@@ -195,6 +179,22 @@ class AttMobility extends AdapterBaseCl {
195
179
  return super.iapGetAdapterQueue(callback);
196
180
  }
197
181
 
182
+ /* SCRIPT CALLS */
183
+ /**
184
+ * See if the API path provided is found in this adapter
185
+ *
186
+ * @function iapFindAdapterPath
187
+ * @param {string} apiPath - the api path to check on
188
+ * @param {Callback} callback - The results of the call
189
+ */
190
+ iapFindAdapterPath(apiPath, callback) {
191
+ const meth = 'adapter-iapFindAdapterPath';
192
+ const origin = `${this.id}-${meth}`;
193
+ log.trace(origin);
194
+
195
+ super.iapFindAdapterPath(apiPath, callback);
196
+ }
197
+
198
198
  /**
199
199
  * @summary Runs troubleshoot scripts for adapter
200
200
  *
@@ -295,176 +295,93 @@ class AttMobility extends AdapterBaseCl {
295
295
  }
296
296
  }
297
297
 
298
- /* BROKER CALLS */
299
298
  /**
300
- * @summary Determines if this adapter supports the specific entity
299
+ * @summary Deactivate adapter tasks
301
300
  *
302
- * @function iapHasAdapterEntity
303
- * @param {String} entityType - the entity type to check for
304
- * @param {String/Array} entityId - the specific entity we are looking for
301
+ * @function iapDeactivateTasks
305
302
  *
306
- * @param {Callback} callback - An array of whether the adapter can has the
307
- * desired capability or an error
303
+ * @param {Array} tasks - List of tasks to deactivate
304
+ * @param {Callback} callback
308
305
  */
309
- iapHasAdapterEntity(entityType, entityId, callback) {
310
- const origin = `${this.id}-adapter-iapHasAdapterEntity`;
306
+ iapDeactivateTasks(tasks, callback) {
307
+ const meth = 'adapter-iapDeactivateTasks';
308
+ const origin = `${this.id}-${meth}`;
311
309
  log.trace(origin);
312
310
 
313
- // Make the call -
314
- // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
315
- return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
311
+ try {
312
+ return super.iapDeactivateTasks(tasks, callback);
313
+ } catch (err) {
314
+ log.error(`${origin}: ${err}`);
315
+ return callback(null, err);
316
+ }
316
317
  }
317
318
 
318
319
  /**
319
- * @summary Provides a way for the adapter to tell north bound integrations
320
- * whether the adapter supports type, action and specific entity
320
+ * @summary Activate adapter tasks that have previously been deactivated
321
321
  *
322
- * @function iapVerifyAdapterCapability
323
- * @param {String} entityType - the entity type to check for
324
- * @param {String} actionType - the action type to check for
325
- * @param {String/Array} entityId - the specific entity we are looking for
322
+ * @function iapActivateTasks
326
323
  *
327
- * @param {Callback} callback - An array of whether the adapter can has the
328
- * desired capability or an error
324
+ * @param {Array} tasks - List of tasks to activate
325
+ * @param {Callback} callback
329
326
  */
330
- iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
331
- const meth = 'adapterBase-iapVerifyAdapterCapability';
327
+ iapActivateTasks(tasks, callback) {
328
+ const meth = 'adapter-iapActivateTasks';
332
329
  const origin = `${this.id}-${meth}`;
333
330
  log.trace(origin);
334
331
 
335
- // if caching
336
- if (this.caching) {
337
- // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
338
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
339
- if (error) {
340
- return callback(null, error);
341
- }
342
-
343
- // if the cache needs to be updated, update and try again
344
- if (results && results[0] === 'needupdate') {
345
- switch (entityType) {
346
- case 'template_entity': {
347
- // if the cache is invalid, update the cache
348
- return this.getEntities(null, null, null, null, (data, err) => {
349
- if (err) {
350
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
351
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
352
- return callback(null, errorObj);
353
- }
354
-
355
- // need to check the cache again since it has been updated
356
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
357
- if (verror) {
358
- return callback(null, verror);
359
- }
360
-
361
- return this.capabilityResults(vcapable, callback);
362
- });
363
- });
364
- }
365
- default: {
366
- // unsupported entity type
367
- const result = [false];
368
-
369
- // put false in array for all entities
370
- if (Array.isArray(entityId)) {
371
- for (let e = 1; e < entityId.length; e += 1) {
372
- result.push(false);
373
- }
374
- }
375
-
376
- return callback(result);
377
- }
378
- }
379
- }
380
-
381
- // return the results
382
- return this.capabilityResults(results, callback);
383
- });
384
- }
385
-
386
- // if no entity id
387
- if (!entityId) {
388
- // need to check the cache again since it has been updated
389
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
390
- if (verror) {
391
- return callback(null, verror);
392
- }
393
-
394
- return this.capabilityResults(vcapable, callback);
395
- });
332
+ try {
333
+ return super.iapActivateTasks(tasks, callback);
334
+ } catch (err) {
335
+ log.error(`${origin}: ${err}`);
336
+ return callback(null, err);
396
337
  }
338
+ }
397
339
 
398
- // if not caching
399
- switch (entityType) {
400
- case 'template_entity': {
401
- // need to get the entities to check
402
- return this.getEntities(null, null, null, null, (data, err) => {
403
- if (err) {
404
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
405
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
406
- return callback(null, errorObj);
407
- }
408
-
409
- // need to check the cache again since it has been updated
410
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
411
- if (verror) {
412
- return callback(null, verror);
413
- }
414
-
415
- // is the entity in the list?
416
- const isEntity = this.entityInList(entityId, data.response, callback);
417
- const res = [];
418
-
419
- // not found
420
- for (let i = 0; i < isEntity.length; i += 1) {
421
- if (vcapable) {
422
- res.push(isEntity[i]);
423
- } else {
424
- res.push(false);
425
- }
426
- }
427
-
428
- return callback(res);
429
- });
430
- });
431
- }
432
- default: {
433
- // unsupported entity type
434
- const result = [false];
435
-
436
- // put false in array for all entities
437
- if (Array.isArray(entityId)) {
438
- for (let e = 1; e < entityId.length; e += 1) {
439
- result.push(false);
440
- }
441
- }
340
+ /* CACHE CALLS */
341
+ /**
342
+ * @summary Populate the cache for the given entities
343
+ *
344
+ * @function iapPopulateEntityCache
345
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
346
+ * @param {Callback} callback - whether the cache was updated or not for each entity type
347
+ *
348
+ * @returns status of the populate
349
+ */
350
+ iapPopulateEntityCache(entityTypes, callback) {
351
+ const meth = 'adapter-iapPopulateEntityCache';
352
+ const origin = `${this.id}-${meth}`;
353
+ log.trace(origin);
442
354
 
443
- return callback(result);
444
- }
355
+ try {
356
+ return super.iapPopulateEntityCache(entityTypes, callback);
357
+ } catch (err) {
358
+ log.error(`${origin}: ${err}`);
359
+ return callback(null, err);
445
360
  }
446
361
  }
447
362
 
448
363
  /**
449
- * @summary Updates the cache for all entities by call the get All entity method
450
- *
451
- * @function iapUpdateAdapterEntityCache
364
+ * @summary Retrieves data from cache for specified entity type
452
365
  *
366
+ * @function iapRetrieveEntitiesCache
367
+ * @param {String} entityType - entity of which to retrieve
368
+ * @param {Object} options - settings of which data to return and how to return it
369
+ * @param {Callback} callback - the data if it was retrieved
453
370
  */
454
- iapUpdateAdapterEntityCache() {
455
- const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
371
+ iapRetrieveEntitiesCache(entityType, options, callback) {
372
+ const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
373
+ const origin = `${this.id}-${meth}`;
456
374
  log.trace(origin);
457
375
 
458
- if (this.caching) {
459
- // if the cache is invalid, update the cache
460
- this.getEntities(null, null, null, null, (data, err) => {
461
- if (err) {
462
- log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
463
- }
464
- });
376
+ try {
377
+ return super.iapRetrieveEntitiesCache(entityType, options, callback);
378
+ } catch (err) {
379
+ log.error(`${origin}: ${err}`);
380
+ return callback(null, err);
465
381
  }
466
382
  }
467
383
 
384
+ /* BROKER CALLS */
468
385
  /**
469
386
  * @summary Determines if this adapter supports any in a list of entities
470
387
  *
@@ -599,6 +516,38 @@ class AttMobility extends AdapterBaseCl {
599
516
  }
600
517
 
601
518
  /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
519
+ /**
520
+ * Makes the requested generic call
521
+ *
522
+ * @function iapExpandedGenericAdapterRequest
523
+ * @param {Object} metadata - metadata for the call (optional).
524
+ * Can be a stringified Object.
525
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
526
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
527
+ * @param {Object} pathVars - the parameters to be put within the url path (optional).
528
+ * Can be a stringified Object.
529
+ * @param {Object} queryData - the parameters to be put on the url (optional).
530
+ * Can be a stringified Object.
531
+ * @param {Object} requestBody - the body to add to the request (optional).
532
+ * Can be a stringified Object.
533
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
534
+ * Can be a stringified Object.
535
+ * @param {getCallback} callback - a callback function to return the result (Generics)
536
+ * or the error
537
+ */
538
+ iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
539
+ const meth = 'adapter-iapExpandedGenericAdapterRequest';
540
+ const origin = `${this.id}-${meth}`;
541
+ log.trace(origin);
542
+
543
+ try {
544
+ return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
545
+ } catch (err) {
546
+ log.error(`${origin}: ${err}`);
547
+ return callback(null, err);
548
+ }
549
+ }
550
+
602
551
  /**
603
552
  * Makes the requested generic call
604
553
  *
@@ -619,93 +568,11 @@ class AttMobility extends AdapterBaseCl {
619
568
  const origin = `${this.id}-${meth}`;
620
569
  log.trace(origin);
621
570
 
622
- if (this.suspended && this.suspendMode === 'error') {
623
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
624
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
625
- return callback(null, errorObj);
626
- }
627
-
628
- /* HERE IS WHERE YOU VALIDATE DATA */
629
- if (uriPath === undefined || uriPath === null || uriPath === '') {
630
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
631
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
632
- return callback(null, errorObj);
633
- }
634
- if (restMethod === undefined || restMethod === null || restMethod === '') {
635
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
636
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
637
- return callback(null, errorObj);
638
- }
639
-
640
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
641
- // remove any leading / and split the uripath into path variables
642
- let myPath = uriPath;
643
- while (myPath.indexOf('/') === 0) {
644
- myPath = myPath.substring(1);
645
- }
646
- const pathVars = myPath.split('/');
647
- const queryParamsAvailable = queryData;
648
- const queryParams = {};
649
- const bodyVars = requestBody;
650
-
651
- // loop in template. long callback arg name to avoid identifier conflicts
652
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
653
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
654
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
655
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
656
- }
657
- });
658
-
659
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
660
- const reqObj = {
661
- payload: bodyVars,
662
- uriPathVars: pathVars,
663
- uriQuery: queryParams,
664
- uriOptions: {}
665
- };
666
- // add headers if provided
667
- if (addlHeaders) {
668
- reqObj.addlHeaders = addlHeaders;
669
- }
670
-
671
- // determine the call and return flag
672
- let action = 'getGenerics';
673
- let returnF = true;
674
- if (restMethod.toUpperCase() === 'POST') {
675
- action = 'createGeneric';
676
- } else if (restMethod.toUpperCase() === 'PUT') {
677
- action = 'updateGeneric';
678
- } else if (restMethod.toUpperCase() === 'PATCH') {
679
- action = 'patchGeneric';
680
- } else if (restMethod.toUpperCase() === 'DELETE') {
681
- action = 'deleteGeneric';
682
- returnF = false;
683
- }
684
-
685
571
  try {
686
- // Make the call -
687
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
688
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
689
- // if we received an error or their is no response on the results
690
- // return an error
691
- if (irReturnError) {
692
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
693
- return callback(null, irReturnError);
694
- }
695
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
696
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
697
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
698
- return callback(null, errorObj);
699
- }
700
-
701
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
702
- // return the response
703
- return callback(irReturnData, null);
704
- });
705
- } catch (ex) {
706
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
707
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
708
- return callback(null, errorObj);
572
+ return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
573
+ } catch (err) {
574
+ log.error(`${origin}: ${err}`);
575
+ return callback(null, err);
709
576
  }
710
577
  }
711
578
 
@@ -729,94 +596,56 @@ class AttMobility extends AdapterBaseCl {
729
596
  const origin = `${this.id}-${meth}`;
730
597
  log.trace(origin);
731
598
 
732
- if (this.suspended && this.suspendMode === 'error') {
733
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
734
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
735
- return callback(null, errorObj);
736
- }
737
-
738
- /* HERE IS WHERE YOU VALIDATE DATA */
739
- if (uriPath === undefined || uriPath === null || uriPath === '') {
740
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
741
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
742
- return callback(null, errorObj);
743
- }
744
- if (restMethod === undefined || restMethod === null || restMethod === '') {
745
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
746
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
747
- return callback(null, errorObj);
599
+ try {
600
+ return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
601
+ } catch (err) {
602
+ log.error(`${origin}: ${err}`);
603
+ return callback(null, err);
748
604
  }
605
+ }
749
606
 
750
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
751
- // remove any leading / and split the uripath into path variables
752
- let myPath = uriPath;
753
- while (myPath.indexOf('/') === 0) {
754
- myPath = myPath.substring(1);
755
- }
756
- const pathVars = myPath.split('/');
757
- const queryParamsAvailable = queryData;
758
- const queryParams = {};
759
- const bodyVars = requestBody;
607
+ /* INVENTORY CALLS */
608
+ /**
609
+ * @summary run the adapter lint script to return the results.
610
+ *
611
+ * @function iapRunAdapterLint
612
+ * @param {Callback} callback - callback function
613
+ */
614
+ iapRunAdapterLint(callback) {
615
+ const meth = 'adapter-iapRunAdapterLint';
616
+ const origin = `${this.id}-${meth}`;
617
+ log.trace(origin);
760
618
 
761
- // loop in template. long callback arg name to avoid identifier conflicts
762
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
763
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
764
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
765
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
766
- }
767
- });
619
+ return super.iapRunAdapterLint(callback);
620
+ }
768
621
 
769
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
770
- const reqObj = {
771
- payload: bodyVars,
772
- uriPathVars: pathVars,
773
- uriQuery: queryParams,
774
- uriOptions: {}
775
- };
776
- // add headers if provided
777
- if (addlHeaders) {
778
- reqObj.addlHeaders = addlHeaders;
779
- }
622
+ /**
623
+ * @summary run the adapter test scripts (baseunit and unit) to return the results.
624
+ * can not run integration as there can be implications with that.
625
+ *
626
+ * @function iapRunAdapterTests
627
+ * @param {Callback} callback - callback function
628
+ */
629
+ iapRunAdapterTests(callback) {
630
+ const meth = 'adapter-iapRunAdapterTests';
631
+ const origin = `${this.id}-${meth}`;
632
+ log.trace(origin);
780
633
 
781
- // determine the call and return flag
782
- let action = 'getGenericsNoBase';
783
- let returnF = true;
784
- if (restMethod.toUpperCase() === 'POST') {
785
- action = 'createGenericNoBase';
786
- } else if (restMethod.toUpperCase() === 'PUT') {
787
- action = 'updateGenericNoBase';
788
- } else if (restMethod.toUpperCase() === 'PATCH') {
789
- action = 'patchGenericNoBase';
790
- } else if (restMethod.toUpperCase() === 'DELETE') {
791
- action = 'deleteGenericNoBase';
792
- returnF = false;
793
- }
634
+ return super.iapRunAdapterTests(callback);
635
+ }
794
636
 
795
- try {
796
- // Make the call -
797
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
798
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
799
- // if we received an error or their is no response on the results
800
- // return an error
801
- if (irReturnError) {
802
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
803
- return callback(null, irReturnError);
804
- }
805
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
806
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
807
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
808
- return callback(null, errorObj);
809
- }
637
+ /**
638
+ * @summary provide inventory information abbout the adapter
639
+ *
640
+ * @function iapGetAdapterInventory
641
+ * @param {Callback} callback - callback function
642
+ */
643
+ iapGetAdapterInventory(callback) {
644
+ const meth = 'adapter-iapGetAdapterInventory';
645
+ const origin = `${this.id}-${meth}`;
646
+ log.trace(origin);
810
647
 
811
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
812
- // return the response
813
- return callback(irReturnData, null);
814
- });
815
- } catch (ex) {
816
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
817
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
818
- return callback(null, errorObj);
819
- }
648
+ return super.iapGetAdapterInventory(callback);
820
649
  }
821
650
 
822
651
  /**