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,313 +1,313 @@
|
|
|
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 AUTH API Adaptor
|
|
23
|
-
* Functions for calling AUTH API.
|
|
24
|
-
************************************************************/
|
|
25
|
-
|
|
26
|
-
var q = require('q');
|
|
27
|
-
var request = require('superagent');
|
|
28
|
-
|
|
29
|
-
var helpers = require('../../helpers');
|
|
30
|
-
|
|
31
|
-
var DLSError = helpers.errors.DLSError;
|
|
32
|
-
|
|
33
|
-
/*********************************
|
|
34
|
-
* Setting Up Module Entry Point
|
|
35
|
-
**********************************/
|
|
36
|
-
module.exports = invitations;
|
|
37
|
-
|
|
38
|
-
//Invitations Adaptor Constructor
|
|
39
|
-
function invitations() {
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
sendInvitations: sendInvitations.bind(this),
|
|
43
|
-
getMultiInvitations: getMultiInvitations.bind(this),
|
|
44
|
-
revokeSingleInvitation: revokeSingleInvitation.bind(this),
|
|
45
|
-
completeSingleInvitation: completeSingleInvitation.bind(this),
|
|
46
|
-
resendSingleInvitation: resendSingleInvitation.bind(this)
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/*options = {
|
|
51
|
-
context: 'string', // required
|
|
52
|
-
created: 'string', // required
|
|
53
|
-
space_title: 'string',
|
|
54
|
-
class_enrollment: { classid: 'string },
|
|
55
|
-
invitation_data: [
|
|
56
|
-
{
|
|
57
|
-
email: 'string', // required
|
|
58
|
-
dls_account_status: 'string',
|
|
59
|
-
ext_account_status: 'string',
|
|
60
|
-
userid: 'string',
|
|
61
|
-
ext_user_id: 'string',
|
|
62
|
-
first_name: 'string', // required
|
|
63
|
-
last_name: 'string', // required
|
|
64
|
-
rowId: 'string', // required
|
|
65
|
-
role: 'string' /// required
|
|
66
|
-
},...
|
|
67
|
-
]
|
|
68
|
-
}*/
|
|
69
|
-
function sendInvitations(options) {
|
|
70
|
-
var self = this;
|
|
71
|
-
var dfd = q.defer();
|
|
72
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
73
|
-
if(err) { dfd.reject(err); }
|
|
74
|
-
else {
|
|
75
|
-
if (options && options.context && options.created && options['invitation_data']) {
|
|
76
|
-
// Passed all validations, Contruct API url
|
|
77
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.sendInvitations;
|
|
78
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
79
|
-
// Setup request with URL and Params
|
|
80
|
-
var requestAPI = request.post(url)
|
|
81
|
-
.set('Content-Type', 'application/json')
|
|
82
|
-
.set('Accept', 'application/json')
|
|
83
|
-
.send(options);
|
|
84
|
-
|
|
85
|
-
//Setup token in Authorization header
|
|
86
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
87
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
88
|
-
|
|
89
|
-
requestAPI.end(function (error, response) {
|
|
90
|
-
if (error) {
|
|
91
|
-
err = {};
|
|
92
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
93
|
-
dfd.reject(err);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
dfd.resolve(response.body);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
err = {};
|
|
102
|
-
err.message = err.description = 'One or more required field(s) missing: context, created or '+
|
|
103
|
-
'invitation_data';
|
|
104
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
105
|
-
dfd.reject(err);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return dfd.promise;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/* options = {
|
|
112
|
-
"context_id": "string", // required
|
|
113
|
-
"context" : "string", //context for invitation e.g. class_enrollment -required
|
|
114
|
-
"status" : "string", // ['pending','complete','revoke'] -required
|
|
115
|
-
"cursor" : "string", // optional
|
|
116
|
-
};
|
|
117
|
-
*/
|
|
118
|
-
function getMultiInvitations(options) {
|
|
119
|
-
var self = this;
|
|
120
|
-
// Initializing promise
|
|
121
|
-
var dfd = q.defer();
|
|
122
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
123
|
-
if(err) { dfd.reject(err); }
|
|
124
|
-
else {
|
|
125
|
-
if (options && options.context_id) {
|
|
126
|
-
|
|
127
|
-
// Passed all validations, Contruct API url
|
|
128
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getMultiInvitations;
|
|
129
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
130
|
-
|
|
131
|
-
var queryParam = { context_id: options.context_id };
|
|
132
|
-
if (options.context) { queryParam.context = options.context; }
|
|
133
|
-
if (options.status) { queryParam.status = options.status; }
|
|
134
|
-
if (options.cursor) { queryParam.cursor = options.cursor; }
|
|
135
|
-
|
|
136
|
-
// Setup request with URL and Params
|
|
137
|
-
var requestAPI = request.get(url).query(queryParam);
|
|
138
|
-
|
|
139
|
-
//Setup token in Authorization header
|
|
140
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
141
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
142
|
-
|
|
143
|
-
requestAPI.end(function (error, response) {
|
|
144
|
-
if (error) {
|
|
145
|
-
err = {};
|
|
146
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
147
|
-
dfd.reject(err);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
dfd.resolve(response.body);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
err = {};
|
|
156
|
-
err.message = err.description = 'context_id not found in request options.';
|
|
157
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
158
|
-
dfd.reject(err);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return dfd.promise;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/* options = {
|
|
165
|
-
"context_id": "string", //class id to be to be revoked invitation -required
|
|
166
|
-
"invitationid" : "string", //unique invitation id which is to be fetched -required
|
|
167
|
-
"context" : "string", //context for revoking invitation e.g. class_enrollment -required
|
|
168
|
-
};
|
|
169
|
-
*/
|
|
170
|
-
function revokeSingleInvitation(options) {
|
|
171
|
-
var self = this;
|
|
172
|
-
// Initializing promise
|
|
173
|
-
var dfd = q.defer();
|
|
174
|
-
|
|
175
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
176
|
-
if(err) { dfd.reject(err); }
|
|
177
|
-
else {
|
|
178
|
-
if (options && options.context_id && options.invitationid && options.context) {
|
|
179
|
-
// Passed all validations, Contruct API url
|
|
180
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.revokeSingleInvitation;
|
|
181
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
182
|
-
|
|
183
|
-
var queryParam = { context: options.context, context_id: options.context_id };
|
|
184
|
-
|
|
185
|
-
// Setup request with URL and Params
|
|
186
|
-
var requestAPI = request.delete(url).query(queryParam);
|
|
187
|
-
|
|
188
|
-
//Setup token in Authorization header
|
|
189
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
190
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
191
|
-
|
|
192
|
-
requestAPI.end(function (error, response) {
|
|
193
|
-
if (error) {
|
|
194
|
-
err = {};
|
|
195
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
196
|
-
dfd.reject(err);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
dfd.resolve(response.body);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
err = {};
|
|
205
|
-
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
206
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
207
|
-
dfd.reject(err);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return dfd.promise;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/* options= {
|
|
214
|
-
"context_id": "string", //class id tocomplete an invitation -required
|
|
215
|
-
"invitationid" : "string", //unique invitation id which is to be fetched -required
|
|
216
|
-
"context" : "string", //context of the invitation to be completed e.g. class_enrollment -required
|
|
217
|
-
};
|
|
218
|
-
*/
|
|
219
|
-
function completeSingleInvitation(options) {
|
|
220
|
-
var self = this;
|
|
221
|
-
// Initializing promise
|
|
222
|
-
var dfd = q.defer();
|
|
223
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
224
|
-
if(err) { dfd.reject(err); }
|
|
225
|
-
else {
|
|
226
|
-
if (options && options.context_id && options.invitationid && options.context) {
|
|
227
|
-
// Passed all validations, Contruct API url
|
|
228
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.completeSingleInvitation;
|
|
229
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
230
|
-
|
|
231
|
-
var queryParam = { context: options.context, context_id: options.context_id };
|
|
232
|
-
// Setup request with URL and Params
|
|
233
|
-
var requestAPI = request.put(url).query(queryParam)
|
|
234
|
-
.set('Content-Type', 'application/json')
|
|
235
|
-
.set('Accept', 'application/json')
|
|
236
|
-
.send({});
|
|
237
|
-
|
|
238
|
-
//Setup token in Authorization header
|
|
239
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
240
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
241
|
-
|
|
242
|
-
requestAPI.end(function (error, response) {
|
|
243
|
-
if (error) {
|
|
244
|
-
err = {};
|
|
245
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
246
|
-
dfd.reject(err);
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
dfd.resolve(response.body);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
err = {};
|
|
255
|
-
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
256
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
257
|
-
dfd.reject(err);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
return dfd.promise;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/* options = {
|
|
264
|
-
"context_id": "string", //class id to be resent invition -required
|
|
265
|
-
"invitationid" : "string", //unique invitation id which is to be fetched -required
|
|
266
|
-
"context" : "string", //context for the invitation to be resent e.g. class_enrollment -required
|
|
267
|
-
"space_title" : "string" //optional
|
|
268
|
-
};
|
|
269
|
-
*/
|
|
270
|
-
function resendSingleInvitation(options) {
|
|
271
|
-
var self = this;
|
|
272
|
-
// Initializing promise
|
|
273
|
-
var dfd = q.defer();
|
|
274
|
-
|
|
275
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
276
|
-
if(err) { dfd.reject(err); }
|
|
277
|
-
else {
|
|
278
|
-
if (options && options.invitationid && options.context && options.context_id) {
|
|
279
|
-
// Passed all validations, Contruct API url
|
|
280
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.resendSingleInvitation;
|
|
281
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
282
|
-
var queryParam = { context: options.context, context_id: options.context_id };
|
|
283
|
-
var body = {};
|
|
284
|
-
if(options.space_title) { body.space_title = options.space_title; }
|
|
285
|
-
|
|
286
|
-
// Setup request with URL and Params
|
|
287
|
-
var requestAPI = request.put(url).query(queryParam)
|
|
288
|
-
.set('Content-Type', 'application/json')
|
|
289
|
-
.set('Accept', 'application/json')
|
|
290
|
-
.send(body);
|
|
291
|
-
|
|
292
|
-
//Setup token in Authorization header
|
|
293
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
294
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
295
|
-
|
|
296
|
-
requestAPI.end(function (error, response) {
|
|
297
|
-
if (error) {
|
|
298
|
-
err = {};
|
|
299
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
300
|
-
dfd.reject(err);
|
|
301
|
-
}
|
|
302
|
-
else { dfd.resolve(response.body); }
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
err = {};
|
|
307
|
-
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
308
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
309
|
-
dfd.reject(err);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return dfd.promise;
|
|
313
|
-
}
|
|
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 AUTH API Adaptor
|
|
23
|
+
* Functions for calling AUTH API.
|
|
24
|
+
************************************************************/
|
|
25
|
+
|
|
26
|
+
var q = require('q');
|
|
27
|
+
var request = require('superagent');
|
|
28
|
+
|
|
29
|
+
var helpers = require('../../helpers');
|
|
30
|
+
|
|
31
|
+
var DLSError = helpers.errors.DLSError;
|
|
32
|
+
|
|
33
|
+
/*********************************
|
|
34
|
+
* Setting Up Module Entry Point
|
|
35
|
+
**********************************/
|
|
36
|
+
module.exports = invitations;
|
|
37
|
+
|
|
38
|
+
//Invitations Adaptor Constructor
|
|
39
|
+
function invitations() {
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
sendInvitations: sendInvitations.bind(this),
|
|
43
|
+
getMultiInvitations: getMultiInvitations.bind(this),
|
|
44
|
+
revokeSingleInvitation: revokeSingleInvitation.bind(this),
|
|
45
|
+
completeSingleInvitation: completeSingleInvitation.bind(this),
|
|
46
|
+
resendSingleInvitation: resendSingleInvitation.bind(this)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*options = {
|
|
51
|
+
context: 'string', // required
|
|
52
|
+
created: 'string', // required
|
|
53
|
+
space_title: 'string',
|
|
54
|
+
class_enrollment: { classid: 'string },
|
|
55
|
+
invitation_data: [
|
|
56
|
+
{
|
|
57
|
+
email: 'string', // required
|
|
58
|
+
dls_account_status: 'string',
|
|
59
|
+
ext_account_status: 'string',
|
|
60
|
+
userid: 'string',
|
|
61
|
+
ext_user_id: 'string',
|
|
62
|
+
first_name: 'string', // required
|
|
63
|
+
last_name: 'string', // required
|
|
64
|
+
rowId: 'string', // required
|
|
65
|
+
role: 'string' /// required
|
|
66
|
+
},...
|
|
67
|
+
]
|
|
68
|
+
}*/
|
|
69
|
+
function sendInvitations(options) {
|
|
70
|
+
var self = this;
|
|
71
|
+
var dfd = q.defer();
|
|
72
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
73
|
+
if(err) { dfd.reject(err); }
|
|
74
|
+
else {
|
|
75
|
+
if (options && options.context && options.created && options['invitation_data']) {
|
|
76
|
+
// Passed all validations, Contruct API url
|
|
77
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.sendInvitations;
|
|
78
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
79
|
+
// Setup request with URL and Params
|
|
80
|
+
var requestAPI = request.post(url)
|
|
81
|
+
.set('Content-Type', 'application/json')
|
|
82
|
+
.set('Accept', 'application/json')
|
|
83
|
+
.send(options);
|
|
84
|
+
|
|
85
|
+
//Setup token in Authorization header
|
|
86
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
87
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
88
|
+
|
|
89
|
+
requestAPI.end(function (error, response) {
|
|
90
|
+
if (error) {
|
|
91
|
+
err = {};
|
|
92
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
93
|
+
dfd.reject(err);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
dfd.resolve(response.body);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
err = {};
|
|
102
|
+
err.message = err.description = 'One or more required field(s) missing: context, created or '+
|
|
103
|
+
'invitation_data';
|
|
104
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
105
|
+
dfd.reject(err);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return dfd.promise;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* options = {
|
|
112
|
+
"context_id": "string", // required
|
|
113
|
+
"context" : "string", //context for invitation e.g. class_enrollment -required
|
|
114
|
+
"status" : "string", // ['pending','complete','revoke'] -required
|
|
115
|
+
"cursor" : "string", // optional
|
|
116
|
+
};
|
|
117
|
+
*/
|
|
118
|
+
function getMultiInvitations(options) {
|
|
119
|
+
var self = this;
|
|
120
|
+
// Initializing promise
|
|
121
|
+
var dfd = q.defer();
|
|
122
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
123
|
+
if(err) { dfd.reject(err); }
|
|
124
|
+
else {
|
|
125
|
+
if (options && options.context_id) {
|
|
126
|
+
|
|
127
|
+
// Passed all validations, Contruct API url
|
|
128
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getMultiInvitations;
|
|
129
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
130
|
+
|
|
131
|
+
var queryParam = { context_id: options.context_id };
|
|
132
|
+
if (options.context) { queryParam.context = options.context; }
|
|
133
|
+
if (options.status) { queryParam.status = options.status; }
|
|
134
|
+
if (options.cursor) { queryParam.cursor = options.cursor; }
|
|
135
|
+
|
|
136
|
+
// Setup request with URL and Params
|
|
137
|
+
var requestAPI = request.get(url).query(queryParam);
|
|
138
|
+
|
|
139
|
+
//Setup token in Authorization header
|
|
140
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
141
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
142
|
+
|
|
143
|
+
requestAPI.end(function (error, response) {
|
|
144
|
+
if (error) {
|
|
145
|
+
err = {};
|
|
146
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
147
|
+
dfd.reject(err);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
dfd.resolve(response.body);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
err = {};
|
|
156
|
+
err.message = err.description = 'context_id not found in request options.';
|
|
157
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
158
|
+
dfd.reject(err);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return dfd.promise;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* options = {
|
|
165
|
+
"context_id": "string", //class id to be to be revoked invitation -required
|
|
166
|
+
"invitationid" : "string", //unique invitation id which is to be fetched -required
|
|
167
|
+
"context" : "string", //context for revoking invitation e.g. class_enrollment -required
|
|
168
|
+
};
|
|
169
|
+
*/
|
|
170
|
+
function revokeSingleInvitation(options) {
|
|
171
|
+
var self = this;
|
|
172
|
+
// Initializing promise
|
|
173
|
+
var dfd = q.defer();
|
|
174
|
+
|
|
175
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
176
|
+
if(err) { dfd.reject(err); }
|
|
177
|
+
else {
|
|
178
|
+
if (options && options.context_id && options.invitationid && options.context) {
|
|
179
|
+
// Passed all validations, Contruct API url
|
|
180
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.revokeSingleInvitation;
|
|
181
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
182
|
+
|
|
183
|
+
var queryParam = { context: options.context, context_id: options.context_id };
|
|
184
|
+
|
|
185
|
+
// Setup request with URL and Params
|
|
186
|
+
var requestAPI = request.delete(url).query(queryParam);
|
|
187
|
+
|
|
188
|
+
//Setup token in Authorization header
|
|
189
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
190
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
191
|
+
|
|
192
|
+
requestAPI.end(function (error, response) {
|
|
193
|
+
if (error) {
|
|
194
|
+
err = {};
|
|
195
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
196
|
+
dfd.reject(err);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
dfd.resolve(response.body);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
err = {};
|
|
205
|
+
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
206
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
207
|
+
dfd.reject(err);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return dfd.promise;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* options= {
|
|
214
|
+
"context_id": "string", //class id tocomplete an invitation -required
|
|
215
|
+
"invitationid" : "string", //unique invitation id which is to be fetched -required
|
|
216
|
+
"context" : "string", //context of the invitation to be completed e.g. class_enrollment -required
|
|
217
|
+
};
|
|
218
|
+
*/
|
|
219
|
+
function completeSingleInvitation(options) {
|
|
220
|
+
var self = this;
|
|
221
|
+
// Initializing promise
|
|
222
|
+
var dfd = q.defer();
|
|
223
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
224
|
+
if(err) { dfd.reject(err); }
|
|
225
|
+
else {
|
|
226
|
+
if (options && options.context_id && options.invitationid && options.context) {
|
|
227
|
+
// Passed all validations, Contruct API url
|
|
228
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.completeSingleInvitation;
|
|
229
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
230
|
+
|
|
231
|
+
var queryParam = { context: options.context, context_id: options.context_id };
|
|
232
|
+
// Setup request with URL and Params
|
|
233
|
+
var requestAPI = request.put(url).query(queryParam)
|
|
234
|
+
.set('Content-Type', 'application/json')
|
|
235
|
+
.set('Accept', 'application/json')
|
|
236
|
+
.send({});
|
|
237
|
+
|
|
238
|
+
//Setup token in Authorization header
|
|
239
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
240
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
241
|
+
|
|
242
|
+
requestAPI.end(function (error, response) {
|
|
243
|
+
if (error) {
|
|
244
|
+
err = {};
|
|
245
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
246
|
+
dfd.reject(err);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
dfd.resolve(response.body);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
err = {};
|
|
255
|
+
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
256
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
257
|
+
dfd.reject(err);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return dfd.promise;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* options = {
|
|
264
|
+
"context_id": "string", //class id to be resent invition -required
|
|
265
|
+
"invitationid" : "string", //unique invitation id which is to be fetched -required
|
|
266
|
+
"context" : "string", //context for the invitation to be resent e.g. class_enrollment -required
|
|
267
|
+
"space_title" : "string" //optional
|
|
268
|
+
};
|
|
269
|
+
*/
|
|
270
|
+
function resendSingleInvitation(options) {
|
|
271
|
+
var self = this;
|
|
272
|
+
// Initializing promise
|
|
273
|
+
var dfd = q.defer();
|
|
274
|
+
|
|
275
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
276
|
+
if(err) { dfd.reject(err); }
|
|
277
|
+
else {
|
|
278
|
+
if (options && options.invitationid && options.context && options.context_id) {
|
|
279
|
+
// Passed all validations, Contruct API url
|
|
280
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.resendSingleInvitation;
|
|
281
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, invitationid: options.invitationid });
|
|
282
|
+
var queryParam = { context: options.context, context_id: options.context_id };
|
|
283
|
+
var body = {};
|
|
284
|
+
if(options.space_title) { body.space_title = options.space_title; }
|
|
285
|
+
|
|
286
|
+
// Setup request with URL and Params
|
|
287
|
+
var requestAPI = request.put(url).query(queryParam)
|
|
288
|
+
.set('Content-Type', 'application/json')
|
|
289
|
+
.set('Accept', 'application/json')
|
|
290
|
+
.send(body);
|
|
291
|
+
|
|
292
|
+
//Setup token in Authorization header
|
|
293
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
294
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
295
|
+
|
|
296
|
+
requestAPI.end(function (error, response) {
|
|
297
|
+
if (error) {
|
|
298
|
+
err = {};
|
|
299
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
300
|
+
dfd.reject(err);
|
|
301
|
+
}
|
|
302
|
+
else { dfd.resolve(response.body); }
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
err = {};
|
|
307
|
+
err.message = err.description = 'context_id or context or invitationid not found in request options.';
|
|
308
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
309
|
+
dfd.reject(err);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return dfd.promise;
|
|
313
|
+
}
|