comprodls-sdk 2.12.0 → 2.12.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.
Files changed (48) hide show
  1. package/.eslintrc +28 -28
  2. package/.npmignore +5 -0
  3. package/README.md +371 -371
  4. package/dist/comprodls-sdk.js +11493 -11471
  5. package/dist/comprodls-sdk.min.js +14 -14
  6. package/grunt/publish.js +148 -148
  7. package/lib/comprodls.js +146 -146
  8. package/lib/config/index.js +337 -337
  9. package/lib/helpers/index.js +29 -29
  10. package/lib/helpers/lib/api/converter.js +119 -119
  11. package/lib/helpers/lib/api/index.js +120 -120
  12. package/lib/helpers/lib/api/validations.js +72 -72
  13. package/lib/helpers/lib/errors.js +129 -129
  14. package/lib/helpers/lib/utils.js +23 -23
  15. package/lib/helpers/lib/validator.js +100 -100
  16. package/lib/open_access/index.js +121 -121
  17. package/lib/services/activity/activity.js +209 -209
  18. package/lib/services/activity/attempt.js +431 -431
  19. package/lib/services/activity/index.js +28 -28
  20. package/lib/services/analytics/index.js +1555 -1555
  21. package/lib/services/attempts/index.js +342 -342
  22. package/lib/services/auth/classProduct.js +37 -37
  23. package/lib/services/auth/index.js +2541 -2541
  24. package/lib/services/collab/index.js +468 -468
  25. package/lib/services/drive/index.js +144 -144
  26. package/lib/services/integrations/index.js +279 -279
  27. package/lib/services/invitations/index.js +313 -313
  28. package/lib/services/lrs/index.js +459 -459
  29. package/lib/services/product/index.js +267 -267
  30. package/lib/services/pub/index.js +407 -407
  31. package/lib/services/push/index.js +187 -187
  32. package/lib/services/push/pubnubClientWrapper.js +557 -557
  33. package/lib/services/push/sessionStorage.js +64 -64
  34. package/lib/services/pushX/index.js +190 -190
  35. package/lib/services/pushX/pubnubClientWrapper.js +211 -211
  36. package/lib/services/sisevents/index.js +113 -113
  37. package/lib/services/spaces/index.js +976 -929
  38. package/lib/services/superuser/index.js +175 -175
  39. package/lib/services/workflows/index.js +464 -464
  40. package/lib/services/xapi/index.js +232 -232
  41. package/lib/token/index.js +114 -114
  42. package/lib/token/validations.js +88 -88
  43. package/package-lock.json +5095 -0
  44. package/package.json +1 -1
  45. package/test.js +50 -50
  46. package/.vscode/launch.json +0 -23
  47. package/npm-debug.log.189866131 +0 -0
  48. package/npm-debug.log.712840116 +0 -26
@@ -1,211 +1,211 @@
1
- var pubNub = require("pubnub");
2
- var EventEmitter = require("events").EventEmitter;
3
- var helpers = require('../../helpers');
4
-
5
- var PUSHXError = helpers.errors.PUSHXError;
6
-
7
- var CHANNEL_DELIMITER = '$';
8
-
9
- /**
10
- * Clientwrapper module.
11
- * Purpose - Wrapper around the Saas client SDK (PubNub). Abstracts the provider/vendor (PubNun) specific
12
- * implementation details - allowing future switch (to a different Saas provider).
13
- */
14
- module.exports = function () {
15
- "use strict";
16
-
17
- /** ====== MODULE GLOBALS */
18
- var _pubnubClient; //SAAS provider client SDK (PubNub).
19
- var _eventEmitter = new EventEmitter();
20
- var _userOptions;
21
- var _globalSubscription = [];
22
- var _globalSubscriptionStatus = {};
23
- var bStatusSubscribed = false;
24
-
25
- /** ###### END OF MODULE GLOBALS */
26
-
27
- /** ====== UTILITY FUNCTIONS */
28
-
29
-
30
- /**
31
- * Call this function to make a new client adaptor.
32
- This adapter exposes functions to send message, update user state etc.
33
- * @return (object) : client adapter.
34
- */
35
- var _constructClientAdaptor = function () {
36
- //Returning the adaptor (Plain Javascript object)
37
- return {
38
- "on": function (channelObj, handler) {
39
- var pubNubChannel;
40
- var channelContext = [];
41
-
42
- if((channelObj.orgid || channelObj.userid) || channelObj.accountid ||
43
- channelObj.productid || channelObj.classid)
44
- {
45
- if(channelObj.accountid) { channelContext.push('a-' + channelObj.accountid); }
46
- else {
47
- if(channelObj.orgid) { channelContext.push('o-' + channelObj.orgid); }
48
- if(channelObj.userid) { channelContext.push('u-' + channelObj.userid); }
49
- if(channelObj.productid) { channelContext.push('p-' + channelObj.productid); }
50
- if(channelObj.classid) { channelContext.push('c-' + channelObj.classid); }
51
- }
52
- pubNubChannel = channelContext.join(CHANNEL_DELIMITER) + CHANNEL_DELIMITER +
53
- channelObj.channel;
54
- if(!_globalSubscription.includes(pubNubChannel)) {
55
- _globalSubscription.push(pubNubChannel);
56
- _globalSubscriptionStatus[pubNubChannel] = {
57
- status: 'pending'
58
- };
59
- _eventEmitter.on(pubNubChannel, handler);
60
- _subscribeToPubNubChannels(pubNubChannel);
61
- }
62
- }
63
- else if(channelObj.channel === 'pushx_status' && ! bStatusSubscribed) {
64
- _eventEmitter.on(channelObj.channel, handler);
65
- bStatusSubscribed = true;
66
- }
67
- },
68
- "getMySubscriptionStatus": __getMySubscriptionStatus
69
- };
70
- };
71
-
72
- var _translatePubnubMessage = function (pubNubEventData) {
73
- var subscribedChannel = pubNubEventData.subscribedChannel;
74
- var message = pubNubEventData.message;
75
- _eventEmitter.emit(subscribedChannel, message);
76
- };
77
-
78
- var _translatePubnubStatus = function(status) {
79
- var channels = [], error, successObj;
80
- switch (status.category) {
81
- case "PNConnectedCategory":
82
- if(status.operation === "PNSubscribeOperation") {
83
- channels = status.subscribedChannels;
84
- for(var i in channels) {
85
- if(_globalSubscriptionStatus[channels[i]]) {
86
- _globalSubscriptionStatus[channels[i]].status = 'subscribed';
87
- }
88
- }
89
- successObj = {
90
- category: 'PUSHX',
91
- type: 'CHANNEL_SUBSCRIPTION',
92
- status: 'SUCCESS',
93
- message: 'Success: Subscribed successfully.',
94
- httpcode: 200,
95
- data: {
96
- payload: {
97
- channels: status.subscribedChannels
98
- },
99
- message: 'Success: Subscribed successfully.'
100
- }
101
- };
102
- _eventEmitter.emit('pushx_status', successObj);
103
- }
104
- break;
105
- case "PNAccessDeniedCategory":
106
- if(status.operation === "PNSubscribeOperation") {
107
- var errorData = {
108
- payload: JSON.parse(status.errorData.response.text).payload,
109
- message: 'Forbidden: Subscription failed.',
110
- errorDetails: {
111
- operation: status.operation,
112
- category: status.category,
113
- statusCode: status.statusCode
114
- }
115
- };
116
- channels = errorData.payload.channels;
117
- for(var j in channels) {
118
- if(_globalSubscriptionStatus[channels[j]]) {
119
- _globalSubscriptionStatus[channels[j]].status = 'error';
120
- _globalSubscriptionStatus[channels[j]].error = error;
121
- }
122
- }
123
- error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, errorData);
124
- _eventEmitter.emit('pushx_status', error);
125
- }
126
- break;
127
- case "PNBadRequestCategory":
128
- case "PNNetworkDownCategory":
129
- case "PNNetworkUpCategory":
130
- error = {
131
- message: "PushX Error", status: status.statusCode,
132
- pushXError: status
133
- };
134
- error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
135
- _eventEmitter.emit('pushx_status', error);
136
- break;
137
- }
138
- };
139
-
140
- var __getMySubscriptionStatus = function() {
141
- return JSON.parse(JSON.stringify(_globalSubscriptionStatus));
142
- };
143
-
144
- /**
145
- * Sets up necessary subscriptions (Pub/Sub) to PUSH channels. To a large extent, subscriptions are
146
- * driven the student's (instructor's) roster.
147
- * @param {object} groups - Roster information, provided during initialization, wrapper.setup().
148
- */
149
- var _subscribeToPubNubChannels = function (channel) {
150
- _pubnubClient.subscribe({ // Calling Pubnub SDK
151
- "channels": [channel]
152
- });
153
- };
154
-
155
- /** ###### END OF UTILITY FUNCTIONS ############ */
156
-
157
- /** ====== Client Wrapper Member functions ==> Mapped to Public Methods */
158
-
159
- /**
160
- * Initializes the library, and established a connection with the Saas/PUSH provider.
161
- * Setup should be called only once i.e. ONE CONNECTION (on a page/tab) is allowed
162
- * at a time. If called again, it will throw an error (failure callback).
163
- *
164
- * @param {object} userOptions - User auth key and pubnub credentials
165
- * @returns PROMISE.
166
- */
167
- var __setup = function (userOptions) {
168
- var pubnubConfig = userOptions.pubnub;
169
- pubnubConfig.uuid = userOptions.userid;
170
-
171
- if (!_pubnubClient && pubnubConfig) {
172
- _pubnubClient = new pubNub(pubnubConfig); //Connect with PubNub SDK
173
- processSetup();
174
- } else {
175
- return new Error('Already Initialized');
176
- }
177
-
178
- /**
179
- * SYNC Function
180
- */
181
- function processSetup() {
182
- _userOptions = userOptions;
183
- _pubnubClient.addListener({ //Setup Listeners (events will shows up after subscription)
184
- "message": function (data) {
185
- _translatePubnubMessage(data);
186
- },
187
- "status": function (status) {
188
- _translatePubnubStatus(status);
189
- }
190
- });
191
- }
192
- return _constructClientAdaptor();
193
- }; //End of _setup()
194
-
195
- var __cleanup = function () {
196
- if (_pubnubClient) { //Skip cleanup if setup() was not called.
197
- _pubnubClient.unsubscribeAll();
198
- _pubnubClient.stop();
199
- _globalSubscription = [];
200
- bStatusSubscribed = false;
201
- _globalSubscriptionStatus = {};
202
- }
203
- _pubnubClient = undefined;
204
- };
205
-
206
- return { // Return public methods for the wrapper
207
- "setup": __setup,
208
- "cleanup": __cleanup
209
- };
210
-
211
- }; //End of Client Wrapper module
1
+ var pubNub = require("pubnub");
2
+ var EventEmitter = require("events").EventEmitter;
3
+ var helpers = require('../../helpers');
4
+
5
+ var PUSHXError = helpers.errors.PUSHXError;
6
+
7
+ var CHANNEL_DELIMITER = '$';
8
+
9
+ /**
10
+ * Clientwrapper module.
11
+ * Purpose - Wrapper around the Saas client SDK (PubNub). Abstracts the provider/vendor (PubNun) specific
12
+ * implementation details - allowing future switch (to a different Saas provider).
13
+ */
14
+ module.exports = function () {
15
+ "use strict";
16
+
17
+ /** ====== MODULE GLOBALS */
18
+ var _pubnubClient; //SAAS provider client SDK (PubNub).
19
+ var _eventEmitter = new EventEmitter();
20
+ var _userOptions;
21
+ var _globalSubscription = [];
22
+ var _globalSubscriptionStatus = {};
23
+ var bStatusSubscribed = false;
24
+
25
+ /** ###### END OF MODULE GLOBALS */
26
+
27
+ /** ====== UTILITY FUNCTIONS */
28
+
29
+
30
+ /**
31
+ * Call this function to make a new client adaptor.
32
+ This adapter exposes functions to send message, update user state etc.
33
+ * @return (object) : client adapter.
34
+ */
35
+ var _constructClientAdaptor = function () {
36
+ //Returning the adaptor (Plain Javascript object)
37
+ return {
38
+ "on": function (channelObj, handler) {
39
+ var pubNubChannel;
40
+ var channelContext = [];
41
+
42
+ if((channelObj.orgid || channelObj.userid) || channelObj.accountid ||
43
+ channelObj.productid || channelObj.classid)
44
+ {
45
+ if(channelObj.accountid) { channelContext.push('a-' + channelObj.accountid); }
46
+ else {
47
+ if(channelObj.orgid) { channelContext.push('o-' + channelObj.orgid); }
48
+ if(channelObj.userid) { channelContext.push('u-' + channelObj.userid); }
49
+ if(channelObj.productid) { channelContext.push('p-' + channelObj.productid); }
50
+ if(channelObj.classid) { channelContext.push('c-' + channelObj.classid); }
51
+ }
52
+ pubNubChannel = channelContext.join(CHANNEL_DELIMITER) + CHANNEL_DELIMITER +
53
+ channelObj.channel;
54
+ if(!_globalSubscription.includes(pubNubChannel)) {
55
+ _globalSubscription.push(pubNubChannel);
56
+ _globalSubscriptionStatus[pubNubChannel] = {
57
+ status: 'pending'
58
+ };
59
+ _eventEmitter.on(pubNubChannel, handler);
60
+ _subscribeToPubNubChannels(pubNubChannel);
61
+ }
62
+ }
63
+ else if(channelObj.channel === 'pushx_status' && ! bStatusSubscribed) {
64
+ _eventEmitter.on(channelObj.channel, handler);
65
+ bStatusSubscribed = true;
66
+ }
67
+ },
68
+ "getMySubscriptionStatus": __getMySubscriptionStatus
69
+ };
70
+ };
71
+
72
+ var _translatePubnubMessage = function (pubNubEventData) {
73
+ var subscribedChannel = pubNubEventData.subscribedChannel;
74
+ var message = pubNubEventData.message;
75
+ _eventEmitter.emit(subscribedChannel, message);
76
+ };
77
+
78
+ var _translatePubnubStatus = function(status) {
79
+ var channels = [], error, successObj;
80
+ switch (status.category) {
81
+ case "PNConnectedCategory":
82
+ if(status.operation === "PNSubscribeOperation") {
83
+ channels = status.subscribedChannels;
84
+ for(var i in channels) {
85
+ if(_globalSubscriptionStatus[channels[i]]) {
86
+ _globalSubscriptionStatus[channels[i]].status = 'subscribed';
87
+ }
88
+ }
89
+ successObj = {
90
+ category: 'PUSHX',
91
+ type: 'CHANNEL_SUBSCRIPTION',
92
+ status: 'SUCCESS',
93
+ message: 'Success: Subscribed successfully.',
94
+ httpcode: 200,
95
+ data: {
96
+ payload: {
97
+ channels: status.subscribedChannels
98
+ },
99
+ message: 'Success: Subscribed successfully.'
100
+ }
101
+ };
102
+ _eventEmitter.emit('pushx_status', successObj);
103
+ }
104
+ break;
105
+ case "PNAccessDeniedCategory":
106
+ if(status.operation === "PNSubscribeOperation") {
107
+ var errorData = {
108
+ payload: JSON.parse(status.errorData.response.text).payload,
109
+ message: 'Forbidden: Subscription failed.',
110
+ errorDetails: {
111
+ operation: status.operation,
112
+ category: status.category,
113
+ statusCode: status.statusCode
114
+ }
115
+ };
116
+ channels = errorData.payload.channels;
117
+ for(var j in channels) {
118
+ if(_globalSubscriptionStatus[channels[j]]) {
119
+ _globalSubscriptionStatus[channels[j]].status = 'error';
120
+ _globalSubscriptionStatus[channels[j]].error = error;
121
+ }
122
+ }
123
+ error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, errorData);
124
+ _eventEmitter.emit('pushx_status', error);
125
+ }
126
+ break;
127
+ case "PNBadRequestCategory":
128
+ case "PNNetworkDownCategory":
129
+ case "PNNetworkUpCategory":
130
+ error = {
131
+ message: "PushX Error", status: status.statusCode,
132
+ pushXError: status
133
+ };
134
+ error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
135
+ _eventEmitter.emit('pushx_status', error);
136
+ break;
137
+ }
138
+ };
139
+
140
+ var __getMySubscriptionStatus = function() {
141
+ return JSON.parse(JSON.stringify(_globalSubscriptionStatus));
142
+ };
143
+
144
+ /**
145
+ * Sets up necessary subscriptions (Pub/Sub) to PUSH channels. To a large extent, subscriptions are
146
+ * driven the student's (instructor's) roster.
147
+ * @param {object} groups - Roster information, provided during initialization, wrapper.setup().
148
+ */
149
+ var _subscribeToPubNubChannels = function (channel) {
150
+ _pubnubClient.subscribe({ // Calling Pubnub SDK
151
+ "channels": [channel]
152
+ });
153
+ };
154
+
155
+ /** ###### END OF UTILITY FUNCTIONS ############ */
156
+
157
+ /** ====== Client Wrapper Member functions ==> Mapped to Public Methods */
158
+
159
+ /**
160
+ * Initializes the library, and established a connection with the Saas/PUSH provider.
161
+ * Setup should be called only once i.e. ONE CONNECTION (on a page/tab) is allowed
162
+ * at a time. If called again, it will throw an error (failure callback).
163
+ *
164
+ * @param {object} userOptions - User auth key and pubnub credentials
165
+ * @returns PROMISE.
166
+ */
167
+ var __setup = function (userOptions) {
168
+ var pubnubConfig = userOptions.pubnub;
169
+ pubnubConfig.uuid = userOptions.userid;
170
+
171
+ if (!_pubnubClient && pubnubConfig) {
172
+ _pubnubClient = new pubNub(pubnubConfig); //Connect with PubNub SDK
173
+ processSetup();
174
+ } else {
175
+ return new Error('Already Initialized');
176
+ }
177
+
178
+ /**
179
+ * SYNC Function
180
+ */
181
+ function processSetup() {
182
+ _userOptions = userOptions;
183
+ _pubnubClient.addListener({ //Setup Listeners (events will shows up after subscription)
184
+ "message": function (data) {
185
+ _translatePubnubMessage(data);
186
+ },
187
+ "status": function (status) {
188
+ _translatePubnubStatus(status);
189
+ }
190
+ });
191
+ }
192
+ return _constructClientAdaptor();
193
+ }; //End of _setup()
194
+
195
+ var __cleanup = function () {
196
+ if (_pubnubClient) { //Skip cleanup if setup() was not called.
197
+ _pubnubClient.unsubscribeAll();
198
+ _pubnubClient.stop();
199
+ _globalSubscription = [];
200
+ bStatusSubscribed = false;
201
+ _globalSubscriptionStatus = {};
202
+ }
203
+ _pubnubClient = undefined;
204
+ };
205
+
206
+ return { // Return public methods for the wrapper
207
+ "setup": __setup,
208
+ "cleanup": __cleanup
209
+ };
210
+
211
+ }; //End of Client Wrapper module
@@ -1,113 +1,113 @@
1
- /*************************************************************************
2
- *
3
- * COMPRO CONFIDENTIAL
4
- * __________________
5
- *
6
- * [2015] - [2020] Compro Technologies Private Limited
7
- * All Rights Reserved.
8
- *
9
- * NOTICE: All information contained herein is, and remains
10
- * the property of Compro Technologies Private Limited. The
11
- * intellectual and technical concepts contained herein are
12
- * proprietary to Compro Technologies Private Limited and may
13
- * be covered by U.S. and Foreign Patents, patents in process,
14
- * and are protected by trade secret or copyright law.
15
- *
16
- * Dissemination of this information or reproduction of this material
17
- * is strictly forbidden unless prior written permission is obtained
18
- * from Compro Technologies Pvt. Ltd..
19
- ***************************************************************************/
20
- /***********************************************************
21
- * comproDLS SDK sisevents Adaptor
22
- * Functions for calling sisevents.
23
- ************************************************************/
24
- /*********************************
25
- * Setting Up Module Entry Point
26
- **********************************/
27
-
28
- var request = require('superagent');
29
- var q = require('q');
30
- var _und = require('underscore');
31
-
32
- var helpers = require('../../helpers');
33
- var DLSError = helpers.errors.DLSError;
34
-
35
- module.exports = sisevents;
36
-
37
- /*********************************
38
- * Public Function definitions
39
- **********************************/
40
- function sisevents() {
41
- return {
42
- "postSISEvent": postSISEvent.bind(this)
43
- };
44
- }
45
-
46
- //options = {
47
- // "actor": {
48
- // "uuid": "string", // userid of user posting statements
49
- // },
50
- // "target": {
51
- // "uuid": "string", // userid of user posting statement
52
- // },
53
- // "product": {
54
- // "uuid": "string", // productid
55
- // "code": "string", // (optional)
56
- // },
57
- // "entities": [{
58
- // "verb": "string", // ['plan-responsibility-signoff', 'plan-status', 'plan-comment', 'item-responsibility', 'item-signoff', 'item-comment', 'item-assets', 'item-status'] currently only one verb is supported
59
- // "task": "string", // task-code of resource
60
- // "model": "string", // (optional) model hierarchy of resource if available
61
- // [verb] : {
62
- // "value": "string"
63
- // }
64
- // }]
65
- //};
66
-
67
- function postSISEvent(options) {
68
- var self = this;
69
-
70
- //Initializing promise
71
- var dfd = q.defer();
72
- //Validations
73
- var err = {}, url;
74
-
75
- if(_und.isArray(options.entities)) {
76
- err = helpers.validations.isAuthenticated(self.orgId, self.token);
77
- if (err) {
78
- dfd.reject(err);
79
- } else {
80
-
81
- url = self.config.DEFAULT_HOSTS['SISEVENTS'] +
82
- self.config.SISEVENTS_API_URLS.postMultiSISEvent;
83
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
84
-
85
- //Passed all validations, Construct API url
86
-
87
- var params = options;
88
-
89
- //Setup request with URL and Params
90
- var requestAPI = request.post(url).send(params);
91
-
92
- //Setup token in Authorization header
93
- requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
94
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
95
-
96
- //Call Product Timespent Api
97
- requestAPI.end(function(err, response) {
98
- if (err) {
99
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
100
- dfd.reject(err);
101
- } else {
102
- dfd.resolve(response.body);
103
- }
104
- });
105
- }
106
- } else {
107
- err.message = err.description = 'Mandatory parameter entities not present in options';
108
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
109
- dfd.reject(err);
110
- }
111
-
112
- return dfd.promise;
113
- }
1
+ /*************************************************************************
2
+ *
3
+ * COMPRO CONFIDENTIAL
4
+ * __________________
5
+ *
6
+ * [2015] - [2020] Compro Technologies Private Limited
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Compro Technologies Private Limited. The
11
+ * intellectual and technical concepts contained herein are
12
+ * proprietary to Compro Technologies Private Limited and may
13
+ * be covered by U.S. and Foreign Patents, patents in process,
14
+ * and are protected by trade secret or copyright law.
15
+ *
16
+ * Dissemination of this information or reproduction of this material
17
+ * is strictly forbidden unless prior written permission is obtained
18
+ * from Compro Technologies Pvt. Ltd..
19
+ ***************************************************************************/
20
+ /***********************************************************
21
+ * comproDLS SDK sisevents Adaptor
22
+ * Functions for calling sisevents.
23
+ ************************************************************/
24
+ /*********************************
25
+ * Setting Up Module Entry Point
26
+ **********************************/
27
+
28
+ var request = require('superagent');
29
+ var q = require('q');
30
+ var _und = require('underscore');
31
+
32
+ var helpers = require('../../helpers');
33
+ var DLSError = helpers.errors.DLSError;
34
+
35
+ module.exports = sisevents;
36
+
37
+ /*********************************
38
+ * Public Function definitions
39
+ **********************************/
40
+ function sisevents() {
41
+ return {
42
+ "postSISEvent": postSISEvent.bind(this)
43
+ };
44
+ }
45
+
46
+ //options = {
47
+ // "actor": {
48
+ // "uuid": "string", // userid of user posting statements
49
+ // },
50
+ // "target": {
51
+ // "uuid": "string", // userid of user posting statement
52
+ // },
53
+ // "product": {
54
+ // "uuid": "string", // productid
55
+ // "code": "string", // (optional)
56
+ // },
57
+ // "entities": [{
58
+ // "verb": "string", // ['plan-responsibility-signoff', 'plan-status', 'plan-comment', 'item-responsibility', 'item-signoff', 'item-comment', 'item-assets', 'item-status'] currently only one verb is supported
59
+ // "task": "string", // task-code of resource
60
+ // "model": "string", // (optional) model hierarchy of resource if available
61
+ // [verb] : {
62
+ // "value": "string"
63
+ // }
64
+ // }]
65
+ //};
66
+
67
+ function postSISEvent(options) {
68
+ var self = this;
69
+
70
+ //Initializing promise
71
+ var dfd = q.defer();
72
+ //Validations
73
+ var err = {}, url;
74
+
75
+ if(_und.isArray(options.entities)) {
76
+ err = helpers.validations.isAuthenticated(self.orgId, self.token);
77
+ if (err) {
78
+ dfd.reject(err);
79
+ } else {
80
+
81
+ url = self.config.DEFAULT_HOSTS['SISEVENTS'] +
82
+ self.config.SISEVENTS_API_URLS.postMultiSISEvent;
83
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
84
+
85
+ //Passed all validations, Construct API url
86
+
87
+ var params = options;
88
+
89
+ //Setup request with URL and Params
90
+ var requestAPI = request.post(url).send(params);
91
+
92
+ //Setup token in Authorization header
93
+ requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
94
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
95
+
96
+ //Call Product Timespent Api
97
+ requestAPI.end(function(err, response) {
98
+ if (err) {
99
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
100
+ dfd.reject(err);
101
+ } else {
102
+ dfd.resolve(response.body);
103
+ }
104
+ });
105
+ }
106
+ } else {
107
+ err.message = err.description = 'Mandatory parameter entities not present in options';
108
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
109
+ dfd.reject(err);
110
+ }
111
+
112
+ return dfd.promise;
113
+ }