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.
- package/.eslintrc +28 -28
- package/.npmignore +5 -0
- package/README.md +371 -371
- package/dist/comprodls-sdk.js +11493 -11471
- package/dist/comprodls-sdk.min.js +14 -14
- package/grunt/publish.js +148 -148
- package/lib/comprodls.js +146 -146
- package/lib/config/index.js +337 -337
- package/lib/helpers/index.js +29 -29
- package/lib/helpers/lib/api/converter.js +119 -119
- package/lib/helpers/lib/api/index.js +120 -120
- package/lib/helpers/lib/api/validations.js +72 -72
- package/lib/helpers/lib/errors.js +129 -129
- package/lib/helpers/lib/utils.js +23 -23
- package/lib/helpers/lib/validator.js +100 -100
- package/lib/open_access/index.js +121 -121
- package/lib/services/activity/activity.js +209 -209
- package/lib/services/activity/attempt.js +431 -431
- package/lib/services/activity/index.js +28 -28
- package/lib/services/analytics/index.js +1555 -1555
- package/lib/services/attempts/index.js +342 -342
- package/lib/services/auth/classProduct.js +37 -37
- package/lib/services/auth/index.js +2541 -2541
- package/lib/services/collab/index.js +468 -468
- package/lib/services/drive/index.js +144 -144
- package/lib/services/integrations/index.js +279 -279
- package/lib/services/invitations/index.js +313 -313
- package/lib/services/lrs/index.js +459 -459
- package/lib/services/product/index.js +267 -267
- package/lib/services/pub/index.js +407 -407
- package/lib/services/push/index.js +187 -187
- package/lib/services/push/pubnubClientWrapper.js +557 -557
- package/lib/services/push/sessionStorage.js +64 -64
- package/lib/services/pushX/index.js +190 -190
- package/lib/services/pushX/pubnubClientWrapper.js +211 -211
- package/lib/services/sisevents/index.js +113 -113
- package/lib/services/spaces/index.js +976 -929
- package/lib/services/superuser/index.js +175 -175
- package/lib/services/workflows/index.js +464 -464
- package/lib/services/xapi/index.js +232 -232
- package/lib/token/index.js +114 -114
- package/lib/token/validations.js +88 -88
- package/package-lock.json +5095 -0
- package/package.json +1 -1
- package/test.js +50 -50
- package/.vscode/launch.json +0 -23
- package/npm-debug.log.189866131 +0 -0
- package/npm-debug.log.712840116 +0 -26
|
@@ -1,232 +1,232 @@
|
|
|
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
|
-
/***********************************************************
|
|
22
|
-
* comproDLS SDK xAPI Adaptor
|
|
23
|
-
* Functions for calling xAPI.
|
|
24
|
-
************************************************************/
|
|
25
|
-
|
|
26
|
-
/*********************************
|
|
27
|
-
* Setting Up Module Entry Point
|
|
28
|
-
**********************************/
|
|
29
|
-
|
|
30
|
-
var q = require('q');
|
|
31
|
-
var request = require('superagent');
|
|
32
|
-
|
|
33
|
-
var helpers = require('../../helpers');
|
|
34
|
-
var DLSError = helpers.errors.DLSError;
|
|
35
|
-
|
|
36
|
-
module.exports = xapi;
|
|
37
|
-
|
|
38
|
-
/*********************************
|
|
39
|
-
* Public Function definitions
|
|
40
|
-
**********************************/
|
|
41
|
-
function xapi() {
|
|
42
|
-
return {
|
|
43
|
-
postStatement: postStatements.bind(this),
|
|
44
|
-
postExternalStatements: postExternalStatements.bind(this)
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/*
|
|
49
|
-
options = {
|
|
50
|
-
actor: {
|
|
51
|
-
uuid: 'string', // userid of user posting statement / 'me'
|
|
52
|
-
group: 'string' // (optional)
|
|
53
|
-
},
|
|
54
|
-
product: { // optional
|
|
55
|
-
code: 'string',
|
|
56
|
-
title: 'string' // (optional)
|
|
57
|
-
ext-item: boolean // (optional, all items in entities will be treated as external items, hence no progress JSON update for them)
|
|
58
|
-
},
|
|
59
|
-
classid: 'string', // (optional) Specify if posting via class,
|
|
60
|
-
space_key: 'string'// (optional)
|
|
61
|
-
|
|
62
|
-
entities: [{
|
|
63
|
-
assigned_path_id: 'string' //optional, assigned-path of a class
|
|
64
|
-
timestamp: 0,
|
|
65
|
-
verb: 'string', // [redo | evaluated | launched | interacted | completed | answered | attempted | scored | submitted']
|
|
66
|
-
//('redo' verb can only be sent by teacher, admin and superadmin )
|
|
67
|
-
model: 'string', // (optional) model hierarchy of resource if available
|
|
68
|
-
item-code: 'string', // item-code of resource(optional)
|
|
69
|
-
user_data: {
|
|
70
|
-
documentid: 'string',
|
|
71
|
-
folderid: 'string',
|
|
72
|
-
action: 'create/update/delete',
|
|
73
|
-
type: 'string',
|
|
74
|
-
payload: 'string'
|
|
75
|
-
},
|
|
76
|
-
timespent: 0, // (optional)
|
|
77
|
-
activity_status: 'string', // (optional) ['in_process', 'timed_out', 'completed']
|
|
78
|
-
result: { // (optional)
|
|
79
|
-
response: {
|
|
80
|
-
audioPath: 'string',
|
|
81
|
-
text: 'string',
|
|
82
|
-
link: [
|
|
83
|
-
{
|
|
84
|
-
url: 'string',
|
|
85
|
-
title: 'string',
|
|
86
|
-
description: 'string'
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
attribs: {}
|
|
90
|
-
},
|
|
91
|
-
score: { // optional
|
|
92
|
-
min: 0,
|
|
93
|
-
scaled: 0,
|
|
94
|
-
max: 0,
|
|
95
|
-
raw: 0
|
|
96
|
-
},
|
|
97
|
-
comment: 'string', // optional
|
|
98
|
-
questions: [{ // optional
|
|
99
|
-
question-code: 'string',
|
|
100
|
-
status-progress: 'string', // [not_attempted | in_progress]
|
|
101
|
-
status-evaluation: 'string' // [not_applicable | partially_correct | correct | incorrect]
|
|
102
|
-
}]
|
|
103
|
-
},
|
|
104
|
-
link-statementid: 'string' // required in case of verb = evaluated
|
|
105
|
-
}],
|
|
106
|
-
platform: {
|
|
107
|
-
ua: 'string',
|
|
108
|
-
sessionid: 'string'
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
*/
|
|
112
|
-
function postStatements(options) {
|
|
113
|
-
var self = this;
|
|
114
|
-
|
|
115
|
-
//Initializing promise
|
|
116
|
-
var dfd = q.defer();
|
|
117
|
-
//Validations
|
|
118
|
-
var err = {}, url;
|
|
119
|
-
|
|
120
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
121
|
-
if(err) { dfd.reject(err); }
|
|
122
|
-
else {
|
|
123
|
-
url = self.config.DEFAULT_HOSTS.XAPI +
|
|
124
|
-
self.config.XAPI_API_URLS.postMultiStatements;
|
|
125
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
126
|
-
//Passed all validations, Construct API url
|
|
127
|
-
|
|
128
|
-
var params = options;
|
|
129
|
-
|
|
130
|
-
//Setup request with URL and Params
|
|
131
|
-
var requestAPI = request.post(url).send(params);
|
|
132
|
-
|
|
133
|
-
//Setup token in Authorization header
|
|
134
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
135
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
136
|
-
|
|
137
|
-
//Call Product Timespent Api
|
|
138
|
-
|
|
139
|
-
requestAPI.end(function(err, response) {
|
|
140
|
-
if(err) {
|
|
141
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
142
|
-
dfd.reject(err);
|
|
143
|
-
}
|
|
144
|
-
else { dfd.resolve(response.body); }
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return dfd.promise;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/*
|
|
151
|
-
options = {
|
|
152
|
-
actor: {
|
|
153
|
-
ext_user_id: 'string', // (optional) who triggered the action - EXTERNAL_SYSTEM in case of verb = evaluated_external
|
|
154
|
-
uuid: 'string' // who triggered the action - EXTERNAL_SYSTEM in case of verb = evaluated_external
|
|
155
|
-
},
|
|
156
|
-
product: {
|
|
157
|
-
code: 'string',
|
|
158
|
-
title: 'string' // (optional)
|
|
159
|
-
ext-item: boolean // (optional, all items in entities will be treated as external items, hence no progress JSON update for them)
|
|
160
|
-
},
|
|
161
|
-
student_userid: "string", // (optional when verb = submitted_external) ON whom is the action taking place
|
|
162
|
-
student_ext_user_id: "string", // (optional when verb = submitted_external) ON whom is the action taking place
|
|
163
|
-
classid: 'string', // (optional) Specify if posting via class
|
|
164
|
-
space_key: 'string', // (optional)
|
|
165
|
-
platform: {
|
|
166
|
-
ua: "string"
|
|
167
|
-
},
|
|
168
|
-
group: { // (optional)
|
|
169
|
-
id: "string"
|
|
170
|
-
}
|
|
171
|
-
entities: [{
|
|
172
|
-
assigned_path_id: 'string' //(optional) assigned-path of a class
|
|
173
|
-
timestamp: 0,
|
|
174
|
-
verb: 'string', // [evaluated_external, submitted_external]
|
|
175
|
-
model: 'string', // (optional) model hierarchy of resource if available
|
|
176
|
-
item-code: 'string', // item-code of resource
|
|
177
|
-
timespent: 0, // (optional)
|
|
178
|
-
part: integer, // (mandatory only for verb = evaluated_external)
|
|
179
|
-
submission_order: integer, // [1, 2, 3]
|
|
180
|
-
result: { // (optional)
|
|
181
|
-
"response": {
|
|
182
|
-
"text": "string",
|
|
183
|
-
"audioPath": "string",
|
|
184
|
-
"link": [
|
|
185
|
-
{
|
|
186
|
-
"url": "string",
|
|
187
|
-
"title": "string",
|
|
188
|
-
"description": "string"
|
|
189
|
-
}
|
|
190
|
-
]
|
|
191
|
-
},
|
|
192
|
-
"score": {
|
|
193
|
-
"min": 0,
|
|
194
|
-
"scaled": 0,
|
|
195
|
-
"max": 0,
|
|
196
|
-
"raw": 0
|
|
197
|
-
},
|
|
198
|
-
"comment": "string", // (optional)
|
|
199
|
-
"ext_data": "string", // (optional)
|
|
200
|
-
questions: [{ // (optional)
|
|
201
|
-
question-code: 'string',
|
|
202
|
-
status-progress: 'string', // [not_attempted | in_progress]
|
|
203
|
-
status-evaluation: 'string' // [not_applicable | partially_correct | correct | incorrect]
|
|
204
|
-
}]
|
|
205
|
-
}
|
|
206
|
-
}]
|
|
207
|
-
}
|
|
208
|
-
*/
|
|
209
|
-
function postExternalStatements(options) {
|
|
210
|
-
var self = this;
|
|
211
|
-
var dfd = q.defer();
|
|
212
|
-
|
|
213
|
-
var url = self.config.DEFAULT_HOSTS.XAPI + self.config.XAPI_API_URLS.postExternalMultiStatements;
|
|
214
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
215
|
-
//Passed all validations, Construct API url
|
|
216
|
-
|
|
217
|
-
//Setup request with URL and Params
|
|
218
|
-
var requestAPI = request.post(url).send(options);
|
|
219
|
-
|
|
220
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
221
|
-
|
|
222
|
-
//Call Product Timespent Api
|
|
223
|
-
|
|
224
|
-
requestAPI.end(function(err, response) {
|
|
225
|
-
if(err) {
|
|
226
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
227
|
-
dfd.reject(err);
|
|
228
|
-
}
|
|
229
|
-
else { dfd.resolve(response.body); }
|
|
230
|
-
});
|
|
231
|
-
return dfd.promise;
|
|
232
|
-
}
|
|
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
|
+
/***********************************************************
|
|
22
|
+
* comproDLS SDK xAPI Adaptor
|
|
23
|
+
* Functions for calling xAPI.
|
|
24
|
+
************************************************************/
|
|
25
|
+
|
|
26
|
+
/*********************************
|
|
27
|
+
* Setting Up Module Entry Point
|
|
28
|
+
**********************************/
|
|
29
|
+
|
|
30
|
+
var q = require('q');
|
|
31
|
+
var request = require('superagent');
|
|
32
|
+
|
|
33
|
+
var helpers = require('../../helpers');
|
|
34
|
+
var DLSError = helpers.errors.DLSError;
|
|
35
|
+
|
|
36
|
+
module.exports = xapi;
|
|
37
|
+
|
|
38
|
+
/*********************************
|
|
39
|
+
* Public Function definitions
|
|
40
|
+
**********************************/
|
|
41
|
+
function xapi() {
|
|
42
|
+
return {
|
|
43
|
+
postStatement: postStatements.bind(this),
|
|
44
|
+
postExternalStatements: postExternalStatements.bind(this)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
options = {
|
|
50
|
+
actor: {
|
|
51
|
+
uuid: 'string', // userid of user posting statement / 'me'
|
|
52
|
+
group: 'string' // (optional)
|
|
53
|
+
},
|
|
54
|
+
product: { // optional
|
|
55
|
+
code: 'string',
|
|
56
|
+
title: 'string' // (optional)
|
|
57
|
+
ext-item: boolean // (optional, all items in entities will be treated as external items, hence no progress JSON update for them)
|
|
58
|
+
},
|
|
59
|
+
classid: 'string', // (optional) Specify if posting via class,
|
|
60
|
+
space_key: 'string'// (optional)
|
|
61
|
+
|
|
62
|
+
entities: [{
|
|
63
|
+
assigned_path_id: 'string' //optional, assigned-path of a class
|
|
64
|
+
timestamp: 0,
|
|
65
|
+
verb: 'string', // [redo | evaluated | launched | interacted | completed | answered | attempted | scored | submitted']
|
|
66
|
+
//('redo' verb can only be sent by teacher, admin and superadmin )
|
|
67
|
+
model: 'string', // (optional) model hierarchy of resource if available
|
|
68
|
+
item-code: 'string', // item-code of resource(optional)
|
|
69
|
+
user_data: {
|
|
70
|
+
documentid: 'string',
|
|
71
|
+
folderid: 'string',
|
|
72
|
+
action: 'create/update/delete',
|
|
73
|
+
type: 'string',
|
|
74
|
+
payload: 'string'
|
|
75
|
+
},
|
|
76
|
+
timespent: 0, // (optional)
|
|
77
|
+
activity_status: 'string', // (optional) ['in_process', 'timed_out', 'completed']
|
|
78
|
+
result: { // (optional)
|
|
79
|
+
response: {
|
|
80
|
+
audioPath: 'string',
|
|
81
|
+
text: 'string',
|
|
82
|
+
link: [
|
|
83
|
+
{
|
|
84
|
+
url: 'string',
|
|
85
|
+
title: 'string',
|
|
86
|
+
description: 'string'
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
attribs: {}
|
|
90
|
+
},
|
|
91
|
+
score: { // optional
|
|
92
|
+
min: 0,
|
|
93
|
+
scaled: 0,
|
|
94
|
+
max: 0,
|
|
95
|
+
raw: 0
|
|
96
|
+
},
|
|
97
|
+
comment: 'string', // optional
|
|
98
|
+
questions: [{ // optional
|
|
99
|
+
question-code: 'string',
|
|
100
|
+
status-progress: 'string', // [not_attempted | in_progress]
|
|
101
|
+
status-evaluation: 'string' // [not_applicable | partially_correct | correct | incorrect]
|
|
102
|
+
}]
|
|
103
|
+
},
|
|
104
|
+
link-statementid: 'string' // required in case of verb = evaluated
|
|
105
|
+
}],
|
|
106
|
+
platform: {
|
|
107
|
+
ua: 'string',
|
|
108
|
+
sessionid: 'string'
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
*/
|
|
112
|
+
function postStatements(options) {
|
|
113
|
+
var self = this;
|
|
114
|
+
|
|
115
|
+
//Initializing promise
|
|
116
|
+
var dfd = q.defer();
|
|
117
|
+
//Validations
|
|
118
|
+
var err = {}, url;
|
|
119
|
+
|
|
120
|
+
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
121
|
+
if(err) { dfd.reject(err); }
|
|
122
|
+
else {
|
|
123
|
+
url = self.config.DEFAULT_HOSTS.XAPI +
|
|
124
|
+
self.config.XAPI_API_URLS.postMultiStatements;
|
|
125
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
126
|
+
//Passed all validations, Construct API url
|
|
127
|
+
|
|
128
|
+
var params = options;
|
|
129
|
+
|
|
130
|
+
//Setup request with URL and Params
|
|
131
|
+
var requestAPI = request.post(url).send(params);
|
|
132
|
+
|
|
133
|
+
//Setup token in Authorization header
|
|
134
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
135
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
136
|
+
|
|
137
|
+
//Call Product Timespent Api
|
|
138
|
+
|
|
139
|
+
requestAPI.end(function(err, response) {
|
|
140
|
+
if(err) {
|
|
141
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
142
|
+
dfd.reject(err);
|
|
143
|
+
}
|
|
144
|
+
else { dfd.resolve(response.body); }
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return dfd.promise;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/*
|
|
151
|
+
options = {
|
|
152
|
+
actor: {
|
|
153
|
+
ext_user_id: 'string', // (optional) who triggered the action - EXTERNAL_SYSTEM in case of verb = evaluated_external
|
|
154
|
+
uuid: 'string' // who triggered the action - EXTERNAL_SYSTEM in case of verb = evaluated_external
|
|
155
|
+
},
|
|
156
|
+
product: {
|
|
157
|
+
code: 'string',
|
|
158
|
+
title: 'string' // (optional)
|
|
159
|
+
ext-item: boolean // (optional, all items in entities will be treated as external items, hence no progress JSON update for them)
|
|
160
|
+
},
|
|
161
|
+
student_userid: "string", // (optional when verb = submitted_external) ON whom is the action taking place
|
|
162
|
+
student_ext_user_id: "string", // (optional when verb = submitted_external) ON whom is the action taking place
|
|
163
|
+
classid: 'string', // (optional) Specify if posting via class
|
|
164
|
+
space_key: 'string', // (optional)
|
|
165
|
+
platform: {
|
|
166
|
+
ua: "string"
|
|
167
|
+
},
|
|
168
|
+
group: { // (optional)
|
|
169
|
+
id: "string"
|
|
170
|
+
}
|
|
171
|
+
entities: [{
|
|
172
|
+
assigned_path_id: 'string' //(optional) assigned-path of a class
|
|
173
|
+
timestamp: 0,
|
|
174
|
+
verb: 'string', // [evaluated_external, submitted_external]
|
|
175
|
+
model: 'string', // (optional) model hierarchy of resource if available
|
|
176
|
+
item-code: 'string', // item-code of resource
|
|
177
|
+
timespent: 0, // (optional)
|
|
178
|
+
part: integer, // (mandatory only for verb = evaluated_external)
|
|
179
|
+
submission_order: integer, // [1, 2, 3]
|
|
180
|
+
result: { // (optional)
|
|
181
|
+
"response": {
|
|
182
|
+
"text": "string",
|
|
183
|
+
"audioPath": "string",
|
|
184
|
+
"link": [
|
|
185
|
+
{
|
|
186
|
+
"url": "string",
|
|
187
|
+
"title": "string",
|
|
188
|
+
"description": "string"
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
"score": {
|
|
193
|
+
"min": 0,
|
|
194
|
+
"scaled": 0,
|
|
195
|
+
"max": 0,
|
|
196
|
+
"raw": 0
|
|
197
|
+
},
|
|
198
|
+
"comment": "string", // (optional)
|
|
199
|
+
"ext_data": "string", // (optional)
|
|
200
|
+
questions: [{ // (optional)
|
|
201
|
+
question-code: 'string',
|
|
202
|
+
status-progress: 'string', // [not_attempted | in_progress]
|
|
203
|
+
status-evaluation: 'string' // [not_applicable | partially_correct | correct | incorrect]
|
|
204
|
+
}]
|
|
205
|
+
}
|
|
206
|
+
}]
|
|
207
|
+
}
|
|
208
|
+
*/
|
|
209
|
+
function postExternalStatements(options) {
|
|
210
|
+
var self = this;
|
|
211
|
+
var dfd = q.defer();
|
|
212
|
+
|
|
213
|
+
var url = self.config.DEFAULT_HOSTS.XAPI + self.config.XAPI_API_URLS.postExternalMultiStatements;
|
|
214
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
215
|
+
//Passed all validations, Construct API url
|
|
216
|
+
|
|
217
|
+
//Setup request with URL and Params
|
|
218
|
+
var requestAPI = request.post(url).send(options);
|
|
219
|
+
|
|
220
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
221
|
+
|
|
222
|
+
//Call Product Timespent Api
|
|
223
|
+
|
|
224
|
+
requestAPI.end(function(err, response) {
|
|
225
|
+
if(err) {
|
|
226
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
227
|
+
dfd.reject(err);
|
|
228
|
+
}
|
|
229
|
+
else { dfd.resolve(response.body); }
|
|
230
|
+
});
|
|
231
|
+
return dfd.promise;
|
|
232
|
+
}
|