@itentialopensource/adapter-att_mobility 0.1.1
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.
- package/.eslintignore +6 -0
- package/.eslintrc.js +18 -0
- package/.gitlab/.gitkeep +0 -0
- package/.gitlab/issue_templates/.gitkeep +0 -0
- package/.gitlab/issue_templates/Default.md +17 -0
- package/.gitlab/issue_templates/bugReportTemplate.md +76 -0
- package/.gitlab/issue_templates/featureRequestTemplate.md +14 -0
- package/.jshintrc +0 -0
- package/AUTH.md +39 -0
- package/BROKER.md +199 -0
- package/CALLS.md +206 -0
- package/CHANGELOG.md +9 -0
- package/CODE_OF_CONDUCT.md +43 -0
- package/CONTRIBUTING.md +172 -0
- package/ENHANCE.md +69 -0
- package/LICENSE +201 -0
- package/PROPERTIES.md +641 -0
- package/README.md +337 -0
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +1345 -0
- package/adapterBase.js +1787 -0
- package/entities/.generic/action.json +214 -0
- package/entities/.generic/schema.json +28 -0
- package/entities/.system/action.json +50 -0
- package/entities/.system/mockdatafiles/getToken-default.json +3 -0
- package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
- package/entities/.system/schema.json +19 -0
- package/entities/.system/schemaTokenReq.json +53 -0
- package/entities/.system/schemaTokenResp.json +53 -0
- package/entities/Mobility/action.json +24 -0
- package/entities/Mobility/schema.json +19 -0
- package/entities/Sp/action.json +107 -0
- package/entities/Sp/schema.json +23 -0
- package/error.json +190 -0
- package/package.json +86 -0
- package/pronghorn.json +876 -0
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +1248 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +10 -0
- package/report/attOpenAPI.json +149 -0
- package/report/creationReport.json +255 -0
- package/sampleProperties.json +195 -0
- package/test/integration/adapterTestBasicGet.js +83 -0
- package/test/integration/adapterTestConnectivity.js +93 -0
- package/test/integration/adapterTestIntegration.js +507 -0
- package/test/unit/adapterBaseTestUnit.js +949 -0
- package/test/unit/adapterTestUnit.js +1485 -0
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/artifactize.js +146 -0
- package/utils/basicGet.js +50 -0
- package/utils/checkMigrate.js +63 -0
- package/utils/entitiesToDB.js +178 -0
- package/utils/findPath.js +74 -0
- package/utils/methodDocumentor.js +225 -0
- package/utils/modify.js +154 -0
- package/utils/packModificationScript.js +35 -0
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +32 -0
- package/utils/removeHooks.js +20 -0
- package/utils/setup.js +33 -0
- package/utils/tbScript.js +246 -0
- package/utils/tbUtils.js +490 -0
- package/utils/testRunner.js +298 -0
- package/utils/troubleshootingAdapter.js +195 -0
- package/workflows/README.md +3 -0
package/adapter.js
ADDED
|
@@ -0,0 +1,1345 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
/* eslint-disable max-len */
|
|
3
|
+
/* eslint-disable import/no-dynamic-require */
|
|
4
|
+
/* @copyright Itential, LLC 2019 (pre-modifications) */
|
|
5
|
+
|
|
6
|
+
/* eslint import/no-dynamic-require: warn */
|
|
7
|
+
/* eslint object-curly-newline: warn */
|
|
8
|
+
|
|
9
|
+
// Set globals
|
|
10
|
+
/* global log */
|
|
11
|
+
|
|
12
|
+
/* Required libraries. */
|
|
13
|
+
const path = require('path');
|
|
14
|
+
|
|
15
|
+
/* Fetch in the other needed components for the this Adaptor */
|
|
16
|
+
const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This is the adapter/interface into AttMobility
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/* GENERAL ADAPTER FUNCTIONS */
|
|
23
|
+
class AttMobility extends AdapterBaseCl {
|
|
24
|
+
/**
|
|
25
|
+
* AttMobility Adapter
|
|
26
|
+
* @constructor
|
|
27
|
+
*/
|
|
28
|
+
/* Working on changing the way we do Emit methods due to size and time constrainsts
|
|
29
|
+
constructor(prongid, properties) {
|
|
30
|
+
// Instantiate the AdapterBase super class
|
|
31
|
+
super(prongid, properties);
|
|
32
|
+
|
|
33
|
+
const restFunctionNames = this.iapGetAdapterWorkflowFunctions();
|
|
34
|
+
|
|
35
|
+
// Dynamically bind emit functions
|
|
36
|
+
for (let i = 0; i < restFunctionNames.length; i += 1) {
|
|
37
|
+
// Bind function to have name fnNameEmit for fnName
|
|
38
|
+
const version = restFunctionNames[i].match(/__v[0-9]+/);
|
|
39
|
+
const baseFnName = restFunctionNames[i].replace(/__v[0-9]+/, '');
|
|
40
|
+
const fnNameEmit = version ? `${baseFnName}Emit${version}` : `${baseFnName}Emit`;
|
|
41
|
+
this[fnNameEmit] = function (...args) {
|
|
42
|
+
// extract the callback
|
|
43
|
+
const callback = args[args.length - 1];
|
|
44
|
+
// slice the callback from args so we can insert our own
|
|
45
|
+
const functionArgs = args.slice(0, args.length - 1);
|
|
46
|
+
// create a random name for the listener
|
|
47
|
+
const eventName = `${restFunctionNames[i]}:${Math.random().toString(36)}`;
|
|
48
|
+
// tell the calling class to start listening
|
|
49
|
+
callback({ event: eventName, status: 'received' });
|
|
50
|
+
// store parent for use of this context later
|
|
51
|
+
const parent = this;
|
|
52
|
+
// store emission function
|
|
53
|
+
const func = function (val, err) {
|
|
54
|
+
parent.removeListener(eventName, func);
|
|
55
|
+
parent.emit(eventName, val, err);
|
|
56
|
+
};
|
|
57
|
+
// Use apply to call the function in a specific context
|
|
58
|
+
this[restFunctionNames[i]].apply(this, functionArgs.concat([func])); // eslint-disable-line prefer-spread
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Uncomment if you have things to add to the constructor like using your own properties.
|
|
63
|
+
// Otherwise the constructor in the adapterBase will be used.
|
|
64
|
+
// Capture my own properties - they need to be defined in propertiesSchema.json
|
|
65
|
+
// if (this.allProps && this.allProps.myownproperty) {
|
|
66
|
+
// mypropvariable = this.allProps.myownproperty;
|
|
67
|
+
// }
|
|
68
|
+
}
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @callback healthCallback
|
|
73
|
+
* @param {Object} reqObj - the request to send into the healthcheck
|
|
74
|
+
* @param {Callback} callback - The results of the call
|
|
75
|
+
*/
|
|
76
|
+
healthCheck(reqObj, callback) {
|
|
77
|
+
// you can modify what is passed into the healthcheck by changing things in the newReq
|
|
78
|
+
let newReq = null;
|
|
79
|
+
if (reqObj) {
|
|
80
|
+
newReq = Object.assign(...reqObj);
|
|
81
|
+
}
|
|
82
|
+
super.healthCheck(newReq, callback);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @iapGetAdapterWorkflowFunctions
|
|
87
|
+
*/
|
|
88
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
89
|
+
let myIgnore = [
|
|
90
|
+
'healthCheck',
|
|
91
|
+
'iapGetAdapterWorkflowFunctions',
|
|
92
|
+
'iapHasAdapterEntity',
|
|
93
|
+
'iapVerifyAdapterCapability',
|
|
94
|
+
'iapUpdateAdapterEntityCache',
|
|
95
|
+
'hasEntities'
|
|
96
|
+
];
|
|
97
|
+
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
98
|
+
myIgnore = inIgnore;
|
|
99
|
+
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
100
|
+
myIgnore = [inIgnore];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// The generic adapter functions should already be ignored (e.g. healthCheck)
|
|
104
|
+
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
105
|
+
// myIgnore.push('myMethodNotInWorkflow');
|
|
106
|
+
|
|
107
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
112
|
+
* allows customers to make changes to adapter configuration without having to be on the
|
|
113
|
+
* file system.
|
|
114
|
+
*
|
|
115
|
+
* @function iapUpdateAdapterConfiguration
|
|
116
|
+
* @param {string} configFile - the name of the file being updated (required)
|
|
117
|
+
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
118
|
+
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
119
|
+
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
120
|
+
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
121
|
+
* @param {Callback} callback - The results of the call
|
|
122
|
+
*/
|
|
123
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
124
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
125
|
+
const origin = `${this.id}-${meth}`;
|
|
126
|
+
log.trace(origin);
|
|
127
|
+
|
|
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);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @summary Suspends adapter
|
|
148
|
+
*
|
|
149
|
+
* @function iapSuspendAdapter
|
|
150
|
+
* @param {Callback} callback - callback function
|
|
151
|
+
*/
|
|
152
|
+
iapSuspendAdapter(mode, callback) {
|
|
153
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
154
|
+
const origin = `${this.id}-${meth}`;
|
|
155
|
+
log.trace(origin);
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
log.error(`${origin}: ${error}`);
|
|
161
|
+
return callback(null, error);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @summary Unsuspends adapter
|
|
167
|
+
*
|
|
168
|
+
* @function iapUnsuspendAdapter
|
|
169
|
+
* @param {Callback} callback - callback function
|
|
170
|
+
*/
|
|
171
|
+
iapUnsuspendAdapter(callback) {
|
|
172
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
173
|
+
const origin = `${this.id}-${meth}`;
|
|
174
|
+
log.trace(origin);
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
return super.iapUnsuspendAdapter(callback);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
log.error(`${origin}: ${error}`);
|
|
180
|
+
return callback(null, error);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @summary Get the Adaoter Queue
|
|
186
|
+
*
|
|
187
|
+
* @function iapGetAdapterQueue
|
|
188
|
+
* @param {Callback} callback - callback function
|
|
189
|
+
*/
|
|
190
|
+
iapGetAdapterQueue(callback) {
|
|
191
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
192
|
+
const origin = `${this.id}-${meth}`;
|
|
193
|
+
log.trace(origin);
|
|
194
|
+
|
|
195
|
+
return super.iapGetAdapterQueue(callback);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @summary Runs troubleshoot scripts for adapter
|
|
200
|
+
*
|
|
201
|
+
* @function iapTroubleshootAdapter
|
|
202
|
+
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
203
|
+
*
|
|
204
|
+
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
205
|
+
* @param {Callback} callback - The results of the call
|
|
206
|
+
*/
|
|
207
|
+
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
208
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
|
209
|
+
const origin = `${this.id}-${meth}`;
|
|
210
|
+
log.trace(origin);
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
214
|
+
} catch (error) {
|
|
215
|
+
log.error(`${origin}: ${error}`);
|
|
216
|
+
return callback(null, error);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @summary runs healthcheck script for adapter
|
|
222
|
+
*
|
|
223
|
+
* @function iapRunAdapterHealthcheck
|
|
224
|
+
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
225
|
+
* @param {Callback} callback - callback function
|
|
226
|
+
*/
|
|
227
|
+
iapRunAdapterHealthcheck(callback) {
|
|
228
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
|
229
|
+
const origin = `${this.id}-${meth}`;
|
|
230
|
+
log.trace(origin);
|
|
231
|
+
|
|
232
|
+
try {
|
|
233
|
+
return super.iapRunAdapterHealthcheck(this, callback);
|
|
234
|
+
} catch (error) {
|
|
235
|
+
log.error(`${origin}: ${error}`);
|
|
236
|
+
return callback(null, error);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @summary runs connectivity check script for adapter
|
|
242
|
+
*
|
|
243
|
+
* @function iapRunAdapterConnectivity
|
|
244
|
+
* @param {Callback} callback - callback function
|
|
245
|
+
*/
|
|
246
|
+
iapRunAdapterConnectivity(callback) {
|
|
247
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
|
248
|
+
const origin = `${this.id}-${meth}`;
|
|
249
|
+
log.trace(origin);
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
return super.iapRunAdapterConnectivity(callback);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
log.error(`${origin}: ${error}`);
|
|
255
|
+
return callback(null, error);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* @summary runs basicGet script for adapter
|
|
261
|
+
*
|
|
262
|
+
* @function iapRunAdapterBasicGet
|
|
263
|
+
* @param {Callback} callback - callback function
|
|
264
|
+
*/
|
|
265
|
+
iapRunAdapterBasicGet(callback) {
|
|
266
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
267
|
+
const origin = `${this.id}-${meth}`;
|
|
268
|
+
log.trace(origin);
|
|
269
|
+
|
|
270
|
+
try {
|
|
271
|
+
return super.iapRunAdapterBasicGet(callback);
|
|
272
|
+
} catch (error) {
|
|
273
|
+
log.error(`${origin}: ${error}`);
|
|
274
|
+
return callback(null, error);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* @summary moves entites into Mongo DB
|
|
280
|
+
*
|
|
281
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
282
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
283
|
+
* or the error
|
|
284
|
+
*/
|
|
285
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
|
286
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
287
|
+
const origin = `${this.id}-${meth}`;
|
|
288
|
+
log.trace(origin);
|
|
289
|
+
|
|
290
|
+
try {
|
|
291
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
292
|
+
} catch (err) {
|
|
293
|
+
log.error(`${origin}: ${err}`);
|
|
294
|
+
return callback(null, err);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* BROKER CALLS */
|
|
299
|
+
/**
|
|
300
|
+
* @summary Determines if this adapter supports the specific entity
|
|
301
|
+
*
|
|
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
|
|
305
|
+
*
|
|
306
|
+
* @param {Callback} callback - An array of whether the adapter can has the
|
|
307
|
+
* desired capability or an error
|
|
308
|
+
*/
|
|
309
|
+
iapHasAdapterEntity(entityType, entityId, callback) {
|
|
310
|
+
const origin = `${this.id}-adapter-iapHasAdapterEntity`;
|
|
311
|
+
log.trace(origin);
|
|
312
|
+
|
|
313
|
+
// Make the call -
|
|
314
|
+
// iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
315
|
+
return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @summary Provides a way for the adapter to tell north bound integrations
|
|
320
|
+
* whether the adapter supports type, action and specific entity
|
|
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
|
|
326
|
+
*
|
|
327
|
+
* @param {Callback} callback - An array of whether the adapter can has the
|
|
328
|
+
* desired capability or an error
|
|
329
|
+
*/
|
|
330
|
+
iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
|
|
331
|
+
const meth = 'adapterBase-iapVerifyAdapterCapability';
|
|
332
|
+
const origin = `${this.id}-${meth}`;
|
|
333
|
+
log.trace(origin);
|
|
334
|
+
|
|
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
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
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
|
+
}
|
|
442
|
+
|
|
443
|
+
return callback(result);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* @summary Updates the cache for all entities by call the get All entity method
|
|
450
|
+
*
|
|
451
|
+
* @function iapUpdateAdapterEntityCache
|
|
452
|
+
*
|
|
453
|
+
*/
|
|
454
|
+
iapUpdateAdapterEntityCache() {
|
|
455
|
+
const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
|
|
456
|
+
log.trace(origin);
|
|
457
|
+
|
|
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
|
+
});
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* @summary Determines if this adapter supports any in a list of entities
|
|
470
|
+
*
|
|
471
|
+
* @function hasEntities
|
|
472
|
+
* @param {String} entityType - the entity type to check for
|
|
473
|
+
* @param {Array} entityList - the list of entities we are looking for
|
|
474
|
+
*
|
|
475
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
|
476
|
+
* value is true or false
|
|
477
|
+
*/
|
|
478
|
+
hasEntities(entityType, entityList, callback) {
|
|
479
|
+
const meth = 'adapter-hasEntities';
|
|
480
|
+
const origin = `${this.id}-${meth}`;
|
|
481
|
+
log.trace(origin);
|
|
482
|
+
|
|
483
|
+
try {
|
|
484
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
485
|
+
} catch (err) {
|
|
486
|
+
log.error(`${origin}: ${err}`);
|
|
487
|
+
return callback(null, err);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* @summary Get Appliance that match the deviceName
|
|
493
|
+
*
|
|
494
|
+
* @function getDevice
|
|
495
|
+
* @param {String} deviceName - the deviceName to find (required)
|
|
496
|
+
*
|
|
497
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
498
|
+
* (appliance) or the error
|
|
499
|
+
*/
|
|
500
|
+
getDevice(deviceName, callback) {
|
|
501
|
+
const meth = 'adapter-getDevice';
|
|
502
|
+
const origin = `${this.id}-${meth}`;
|
|
503
|
+
log.trace(origin);
|
|
504
|
+
|
|
505
|
+
try {
|
|
506
|
+
return super.getDevice(deviceName, callback);
|
|
507
|
+
} catch (err) {
|
|
508
|
+
log.error(`${origin}: ${err}`);
|
|
509
|
+
return callback(null, err);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* @summary Get Appliances that match the filter
|
|
515
|
+
*
|
|
516
|
+
* @function getDevicesFiltered
|
|
517
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
|
518
|
+
*
|
|
519
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
520
|
+
* (appliances) or the error
|
|
521
|
+
*/
|
|
522
|
+
getDevicesFiltered(options, callback) {
|
|
523
|
+
const meth = 'adapter-getDevicesFiltered';
|
|
524
|
+
const origin = `${this.id}-${meth}`;
|
|
525
|
+
log.trace(origin);
|
|
526
|
+
|
|
527
|
+
try {
|
|
528
|
+
return super.getDevicesFiltered(options, callback);
|
|
529
|
+
} catch (err) {
|
|
530
|
+
log.error(`${origin}: ${err}`);
|
|
531
|
+
return callback(null, err);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* @summary Gets the status for the provided appliance
|
|
537
|
+
*
|
|
538
|
+
* @function isAlive
|
|
539
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
540
|
+
*
|
|
541
|
+
* @param {configCallback} callback - callback function to return the result
|
|
542
|
+
* (appliance isAlive) or the error
|
|
543
|
+
*/
|
|
544
|
+
isAlive(deviceName, callback) {
|
|
545
|
+
const meth = 'adapter-isAlive';
|
|
546
|
+
const origin = `${this.id}-${meth}`;
|
|
547
|
+
log.trace(origin);
|
|
548
|
+
|
|
549
|
+
try {
|
|
550
|
+
return super.isAlive(deviceName, callback);
|
|
551
|
+
} catch (err) {
|
|
552
|
+
log.error(`${origin}: ${err}`);
|
|
553
|
+
return callback(null, err);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* @summary Gets a config for the provided Appliance
|
|
559
|
+
*
|
|
560
|
+
* @function getConfig
|
|
561
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
562
|
+
* @param {String} format - the desired format of the config. (optional)
|
|
563
|
+
*
|
|
564
|
+
* @param {configCallback} callback - callback function to return the result
|
|
565
|
+
* (appliance config) or the error
|
|
566
|
+
*/
|
|
567
|
+
getConfig(deviceName, format, callback) {
|
|
568
|
+
const meth = 'adapter-getConfig';
|
|
569
|
+
const origin = `${this.id}-${meth}`;
|
|
570
|
+
log.trace(origin);
|
|
571
|
+
|
|
572
|
+
try {
|
|
573
|
+
return super.getConfig(deviceName, format, callback);
|
|
574
|
+
} catch (err) {
|
|
575
|
+
log.error(`${origin}: ${err}`);
|
|
576
|
+
return callback(null, err);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @summary Gets the device count from the system
|
|
582
|
+
*
|
|
583
|
+
* @function iapGetDeviceCount
|
|
584
|
+
*
|
|
585
|
+
* @param {getCallback} callback - callback function to return the result
|
|
586
|
+
* (count) or the error
|
|
587
|
+
*/
|
|
588
|
+
iapGetDeviceCount(callback) {
|
|
589
|
+
const meth = 'adapter-iapGetDeviceCount';
|
|
590
|
+
const origin = `${this.id}-${meth}`;
|
|
591
|
+
log.trace(origin);
|
|
592
|
+
|
|
593
|
+
try {
|
|
594
|
+
return super.iapGetDeviceCount(callback);
|
|
595
|
+
} catch (err) {
|
|
596
|
+
log.error(`${origin}: ${err}`);
|
|
597
|
+
return callback(null, err);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
602
|
+
/**
|
|
603
|
+
* Makes the requested generic call
|
|
604
|
+
*
|
|
605
|
+
* @function genericAdapterRequest
|
|
606
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
607
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
608
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
609
|
+
* Can be a stringified Object.
|
|
610
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
611
|
+
* Can be a stringified Object.
|
|
612
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
613
|
+
* Can be a stringified Object.
|
|
614
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
615
|
+
* or the error
|
|
616
|
+
*/
|
|
617
|
+
genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
618
|
+
const meth = 'adapter-genericAdapterRequest';
|
|
619
|
+
const origin = `${this.id}-${meth}`;
|
|
620
|
+
log.trace(origin);
|
|
621
|
+
|
|
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
|
+
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);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Makes the requested generic call with no base path or version
|
|
714
|
+
*
|
|
715
|
+
* @function genericAdapterRequestNoBasePath
|
|
716
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
717
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
718
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
719
|
+
* Can be a stringified Object.
|
|
720
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
721
|
+
* Can be a stringified Object.
|
|
722
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
723
|
+
* Can be a stringified Object.
|
|
724
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
725
|
+
* or the error
|
|
726
|
+
*/
|
|
727
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
728
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
|
729
|
+
const origin = `${this.id}-${meth}`;
|
|
730
|
+
log.trace(origin);
|
|
731
|
+
|
|
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);
|
|
748
|
+
}
|
|
749
|
+
|
|
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;
|
|
760
|
+
|
|
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
|
+
});
|
|
768
|
+
|
|
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
|
+
}
|
|
780
|
+
|
|
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
|
+
}
|
|
794
|
+
|
|
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
|
+
}
|
|
810
|
+
|
|
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
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* @callback healthCallback
|
|
824
|
+
* @param {Object} result - the result of the get request (contains an id and a status)
|
|
825
|
+
*/
|
|
826
|
+
/**
|
|
827
|
+
* @callback getCallback
|
|
828
|
+
* @param {Object} result - the result of the get request (entity/ies)
|
|
829
|
+
* @param {String} error - any error that occurred
|
|
830
|
+
*/
|
|
831
|
+
/**
|
|
832
|
+
* @callback createCallback
|
|
833
|
+
* @param {Object} item - the newly created entity
|
|
834
|
+
* @param {String} error - any error that occurred
|
|
835
|
+
*/
|
|
836
|
+
/**
|
|
837
|
+
* @callback updateCallback
|
|
838
|
+
* @param {String} status - the status of the update action
|
|
839
|
+
* @param {String} error - any error that occurred
|
|
840
|
+
*/
|
|
841
|
+
/**
|
|
842
|
+
* @callback deleteCallback
|
|
843
|
+
* @param {String} status - the status of the delete action
|
|
844
|
+
* @param {String} error - any error that occurred
|
|
845
|
+
*/
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* @function getServiceActivationStatus
|
|
849
|
+
* @pronghornType method
|
|
850
|
+
* @name getServiceActivationStatus
|
|
851
|
+
* @summary getServiceActivationStatus
|
|
852
|
+
*
|
|
853
|
+
* @param {string} requestId - requestId param
|
|
854
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
855
|
+
* @return {object} results - An object containing the response of the action
|
|
856
|
+
*
|
|
857
|
+
* @route {POST} /getServiceActivationStatus
|
|
858
|
+
* @roles admin
|
|
859
|
+
* @task true
|
|
860
|
+
*/
|
|
861
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
862
|
+
getServiceActivationStatus(requestId, callback) {
|
|
863
|
+
const meth = 'adapter-getServiceActivationStatus';
|
|
864
|
+
const origin = `${this.id}-${meth}`;
|
|
865
|
+
log.trace(origin);
|
|
866
|
+
|
|
867
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
868
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
869
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
870
|
+
return callback(null, errorObj);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
874
|
+
if (requestId === undefined || requestId === null || requestId === '') {
|
|
875
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['requestId'], null, null, null);
|
|
876
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
877
|
+
return callback(null, errorObj);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
881
|
+
const queryParamsAvailable = {};
|
|
882
|
+
const queryParams = {};
|
|
883
|
+
const pathVars = [requestId];
|
|
884
|
+
const bodyVars = {};
|
|
885
|
+
|
|
886
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
887
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
888
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
889
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
890
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
891
|
+
}
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
895
|
+
// see adapter code documentation for more information on the request object's fields
|
|
896
|
+
const reqObj = {
|
|
897
|
+
payload: bodyVars,
|
|
898
|
+
uriPathVars: pathVars,
|
|
899
|
+
uriQuery: queryParams
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
try {
|
|
903
|
+
// Make the call -
|
|
904
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
905
|
+
return this.requestHandlerInst.identifyRequest('Sp', 'getServiceActivationStatus', reqObj, true, (irReturnData, irReturnError) => {
|
|
906
|
+
// if we received an error or their is no response on the results
|
|
907
|
+
// return an error
|
|
908
|
+
if (irReturnError) {
|
|
909
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
910
|
+
return callback(null, irReturnError);
|
|
911
|
+
}
|
|
912
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
913
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getServiceActivationStatus'], null, null, null);
|
|
914
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
915
|
+
return callback(null, errorObj);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
919
|
+
// return the response
|
|
920
|
+
return callback(irReturnData, null);
|
|
921
|
+
});
|
|
922
|
+
} catch (ex) {
|
|
923
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
924
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
925
|
+
return callback(null, errorObj);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* @function getBillingAccountDetails
|
|
931
|
+
* @pronghornType method
|
|
932
|
+
* @name getBillingAccountDetails
|
|
933
|
+
* @summary getBillingAccountDetails
|
|
934
|
+
*
|
|
935
|
+
* @param {string} billingAccountNumber - billingAccountNumber param
|
|
936
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
937
|
+
* @return {object} results - An object containing the response of the action
|
|
938
|
+
*
|
|
939
|
+
* @route {POST} /getBillingAccountDetails
|
|
940
|
+
* @roles admin
|
|
941
|
+
* @task true
|
|
942
|
+
*/
|
|
943
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
944
|
+
getBillingAccountDetails(billingAccountNumber, callback) {
|
|
945
|
+
const meth = 'adapter-getBillingAccountDetails';
|
|
946
|
+
const origin = `${this.id}-${meth}`;
|
|
947
|
+
log.trace(origin);
|
|
948
|
+
|
|
949
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
950
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
951
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
952
|
+
return callback(null, errorObj);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
956
|
+
if (billingAccountNumber === undefined || billingAccountNumber === null || billingAccountNumber === '') {
|
|
957
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['billingAccountNumber'], null, null, null);
|
|
958
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
959
|
+
return callback(null, errorObj);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
963
|
+
const queryParamsAvailable = {};
|
|
964
|
+
const queryParams = {};
|
|
965
|
+
const pathVars = [billingAccountNumber];
|
|
966
|
+
const bodyVars = {};
|
|
967
|
+
|
|
968
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
969
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
970
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
971
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
972
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
|
|
976
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
977
|
+
// see adapter code documentation for more information on the request object's fields
|
|
978
|
+
const reqObj = {
|
|
979
|
+
payload: bodyVars,
|
|
980
|
+
uriPathVars: pathVars,
|
|
981
|
+
uriQuery: queryParams
|
|
982
|
+
};
|
|
983
|
+
|
|
984
|
+
try {
|
|
985
|
+
// Make the call -
|
|
986
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
987
|
+
return this.requestHandlerInst.identifyRequest('Sp', 'getBillingAccountDetails', reqObj, true, (irReturnData, irReturnError) => {
|
|
988
|
+
// if we received an error or their is no response on the results
|
|
989
|
+
// return an error
|
|
990
|
+
if (irReturnError) {
|
|
991
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
992
|
+
return callback(null, irReturnError);
|
|
993
|
+
}
|
|
994
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
995
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getBillingAccountDetails'], null, null, null);
|
|
996
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
997
|
+
return callback(null, errorObj);
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1001
|
+
// return the response
|
|
1002
|
+
return callback(irReturnData, null);
|
|
1003
|
+
});
|
|
1004
|
+
} catch (ex) {
|
|
1005
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1006
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1007
|
+
return callback(null, errorObj);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* @function getSubscriberLineDetails
|
|
1013
|
+
* @pronghornType method
|
|
1014
|
+
* @name getSubscriberLineDetails
|
|
1015
|
+
* @summary getSubscriberLineDetails
|
|
1016
|
+
*
|
|
1017
|
+
* @param {string} subscriberLine - subscriberLine param
|
|
1018
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1019
|
+
* @return {object} results - An object containing the response of the action
|
|
1020
|
+
*
|
|
1021
|
+
* @route {POST} /getSubscriberLineDetails
|
|
1022
|
+
* @roles admin
|
|
1023
|
+
* @task true
|
|
1024
|
+
*/
|
|
1025
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1026
|
+
getSubscriberLineDetails(subscriberLine, callback) {
|
|
1027
|
+
const meth = 'adapter-getSubscriberLineDetails';
|
|
1028
|
+
const origin = `${this.id}-${meth}`;
|
|
1029
|
+
log.trace(origin);
|
|
1030
|
+
|
|
1031
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1032
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1033
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1034
|
+
return callback(null, errorObj);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1038
|
+
if (subscriberLine === undefined || subscriberLine === null || subscriberLine === '') {
|
|
1039
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['subscriberLine'], null, null, null);
|
|
1040
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1041
|
+
return callback(null, errorObj);
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1045
|
+
const queryParamsAvailable = {};
|
|
1046
|
+
const queryParams = {};
|
|
1047
|
+
const pathVars = [subscriberLine];
|
|
1048
|
+
const bodyVars = {};
|
|
1049
|
+
|
|
1050
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1051
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1052
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1053
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1054
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
|
|
1058
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1059
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1060
|
+
const reqObj = {
|
|
1061
|
+
payload: bodyVars,
|
|
1062
|
+
uriPathVars: pathVars,
|
|
1063
|
+
uriQuery: queryParams
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
try {
|
|
1067
|
+
// Make the call -
|
|
1068
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1069
|
+
return this.requestHandlerInst.identifyRequest('Sp', 'getSubscriberLineDetails', reqObj, true, (irReturnData, irReturnError) => {
|
|
1070
|
+
// if we received an error or their is no response on the results
|
|
1071
|
+
// return an error
|
|
1072
|
+
if (irReturnError) {
|
|
1073
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1074
|
+
return callback(null, irReturnError);
|
|
1075
|
+
}
|
|
1076
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1077
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSubscriberLineDetails'], null, null, null);
|
|
1078
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1079
|
+
return callback(null, errorObj);
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1083
|
+
// return the response
|
|
1084
|
+
return callback(irReturnData, null);
|
|
1085
|
+
});
|
|
1086
|
+
} catch (ex) {
|
|
1087
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1088
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1089
|
+
return callback(null, errorObj);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* @function postServiceActivation
|
|
1095
|
+
* @pronghornType method
|
|
1096
|
+
* @name postServiceActivation
|
|
1097
|
+
* @summary postServiceActivation
|
|
1098
|
+
*
|
|
1099
|
+
* @param {object} body - body param
|
|
1100
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1101
|
+
* @return {object} results - An object containing the response of the action
|
|
1102
|
+
*
|
|
1103
|
+
* @route {POST} /postServiceActivation
|
|
1104
|
+
* @roles admin
|
|
1105
|
+
* @task true
|
|
1106
|
+
*/
|
|
1107
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1108
|
+
postServiceActivation(body, callback) {
|
|
1109
|
+
const meth = 'adapter-postServiceActivation';
|
|
1110
|
+
const origin = `${this.id}-${meth}`;
|
|
1111
|
+
log.trace(origin);
|
|
1112
|
+
|
|
1113
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1114
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1115
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1116
|
+
return callback(null, errorObj);
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1120
|
+
if (body === undefined || body === null || body === '') {
|
|
1121
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1122
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1123
|
+
return callback(null, errorObj);
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1127
|
+
const queryParamsAvailable = {};
|
|
1128
|
+
const queryParams = {};
|
|
1129
|
+
const pathVars = [];
|
|
1130
|
+
const bodyVars = body;
|
|
1131
|
+
|
|
1132
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1133
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1134
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1135
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1136
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1139
|
+
|
|
1140
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1141
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1142
|
+
const reqObj = {
|
|
1143
|
+
payload: bodyVars,
|
|
1144
|
+
uriPathVars: pathVars,
|
|
1145
|
+
uriQuery: queryParams
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1148
|
+
try {
|
|
1149
|
+
// Make the call -
|
|
1150
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1151
|
+
return this.requestHandlerInst.identifyRequest('Sp', 'postServiceActivation', reqObj, true, (irReturnData, irReturnError) => {
|
|
1152
|
+
// if we received an error or their is no response on the results
|
|
1153
|
+
// return an error
|
|
1154
|
+
if (irReturnError) {
|
|
1155
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1156
|
+
return callback(null, irReturnError);
|
|
1157
|
+
}
|
|
1158
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1159
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postServiceActivation'], null, null, null);
|
|
1160
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1161
|
+
return callback(null, errorObj);
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1165
|
+
// return the response
|
|
1166
|
+
irReturnData.response = JSON.parse(irReturnData.response);
|
|
1167
|
+
return callback(irReturnData, null);
|
|
1168
|
+
});
|
|
1169
|
+
} catch (ex) {
|
|
1170
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1171
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1172
|
+
return callback(null, errorObj);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
* @function editSubscriberLineDetails
|
|
1178
|
+
* @pronghornType method
|
|
1179
|
+
* @name editSubscriberLineDetails
|
|
1180
|
+
* @summary editSubscriberLineDetails
|
|
1181
|
+
*
|
|
1182
|
+
* @param {string} subsciberLine - subsciberLine param
|
|
1183
|
+
* @param {object} body - body param
|
|
1184
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1185
|
+
* @return {object} results - An object containing the response of the action
|
|
1186
|
+
*
|
|
1187
|
+
* @route {POST} /editSubscriberLineDetails
|
|
1188
|
+
* @roles admin
|
|
1189
|
+
* @task true
|
|
1190
|
+
*/
|
|
1191
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1192
|
+
editSubscriberLineDetails(subsciberLine, body, callback) {
|
|
1193
|
+
const meth = 'adapter-editSubscriberLineDetails';
|
|
1194
|
+
const origin = `${this.id}-${meth}`;
|
|
1195
|
+
log.trace(origin);
|
|
1196
|
+
|
|
1197
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1198
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1199
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1200
|
+
return callback(null, errorObj);
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1204
|
+
if (subsciberLine === undefined || subsciberLine === null || subsciberLine === '') {
|
|
1205
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['subsciberLine'], null, null, null);
|
|
1206
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1207
|
+
return callback(null, errorObj);
|
|
1208
|
+
}
|
|
1209
|
+
if (body === undefined || body === null || body === '') {
|
|
1210
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1211
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1212
|
+
return callback(null, errorObj);
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1216
|
+
const queryParamsAvailable = {};
|
|
1217
|
+
const queryParams = {};
|
|
1218
|
+
const pathVars = [subsciberLine];
|
|
1219
|
+
const bodyVars = body;
|
|
1220
|
+
|
|
1221
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1222
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1223
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1224
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1225
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
1228
|
+
|
|
1229
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1230
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1231
|
+
const reqObj = {
|
|
1232
|
+
payload: bodyVars,
|
|
1233
|
+
uriPathVars: pathVars,
|
|
1234
|
+
uriQuery: queryParams
|
|
1235
|
+
};
|
|
1236
|
+
|
|
1237
|
+
try {
|
|
1238
|
+
// Make the call -
|
|
1239
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1240
|
+
return this.requestHandlerInst.identifyRequest('Sp', 'editSubscriberLineDetails', reqObj, false, (irReturnData, irReturnError) => {
|
|
1241
|
+
// if we received an error or their is no response on the results
|
|
1242
|
+
// return an error
|
|
1243
|
+
if (irReturnError) {
|
|
1244
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1245
|
+
return callback(null, irReturnError);
|
|
1246
|
+
}
|
|
1247
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1248
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['editSubscriberLineDetails'], null, null, null);
|
|
1249
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1250
|
+
return callback(null, errorObj);
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1254
|
+
// return the response
|
|
1255
|
+
return callback(irReturnData, null);
|
|
1256
|
+
});
|
|
1257
|
+
} catch (ex) {
|
|
1258
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1259
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1260
|
+
return callback(null, errorObj);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* @function queryDeviceByIMEI
|
|
1266
|
+
* @pronghornType method
|
|
1267
|
+
* @name queryDeviceByIMEI
|
|
1268
|
+
* @summary queryDeviceByIMEI
|
|
1269
|
+
*
|
|
1270
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1271
|
+
* @return {object} results - An object containing the response of the action
|
|
1272
|
+
*
|
|
1273
|
+
* @route {GET} /queryDeviceByIMEI
|
|
1274
|
+
* @roles admin
|
|
1275
|
+
* @task true
|
|
1276
|
+
*/
|
|
1277
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1278
|
+
queryDeviceByIMEI(imeiNumber, callback) {
|
|
1279
|
+
const meth = 'adapter-queryDeviceByIMEI';
|
|
1280
|
+
const origin = `${this.id}-${meth}`;
|
|
1281
|
+
log.trace(origin);
|
|
1282
|
+
|
|
1283
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1284
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1285
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1286
|
+
return callback(null, errorObj);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1290
|
+
|
|
1291
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1292
|
+
const queryParamsAvailable = {};
|
|
1293
|
+
const queryParams = {};
|
|
1294
|
+
const pathVars = [];
|
|
1295
|
+
const bodyVars = {};
|
|
1296
|
+
|
|
1297
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1298
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1299
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1300
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1301
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1304
|
+
|
|
1305
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1306
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1307
|
+
const reqObj = {
|
|
1308
|
+
payload: bodyVars,
|
|
1309
|
+
uriPathVars: pathVars,
|
|
1310
|
+
uriQuery: queryParams,
|
|
1311
|
+
addlHeaders: {
|
|
1312
|
+
imei: imeiNumber
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
try {
|
|
1317
|
+
// Make the call -
|
|
1318
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1319
|
+
return this.requestHandlerInst.identifyRequest('Mobility', 'queryDeviceByIMEI', reqObj, true, (irReturnData, irReturnError) => {
|
|
1320
|
+
// if we received an error or their is no response on the results
|
|
1321
|
+
// return an error
|
|
1322
|
+
if (irReturnError) {
|
|
1323
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1324
|
+
return callback(null, irReturnError);
|
|
1325
|
+
}
|
|
1326
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1327
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['queryDeviceByIMEI'], null, null, null);
|
|
1328
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1329
|
+
return callback(null, errorObj);
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1333
|
+
// return the response
|
|
1334
|
+
irReturnData.response = JSON.parse(irReturnData.response);
|
|
1335
|
+
return callback(irReturnData, null);
|
|
1336
|
+
});
|
|
1337
|
+
} catch (ex) {
|
|
1338
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1339
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1340
|
+
return callback(null, errorObj);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
module.exports = AttMobility;
|