comprodls-sdk 2.107.0 → 2.108.0-thor.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/dist/comprodls-sdk.js +109 -54
- package/dist/comprodls-sdk.min.js +1 -1
- package/lib/config/index.js +2 -0
- package/lib/helpers/lib/errors.js +3 -1
- package/lib/services/spaces/index.js +36 -29
- package/lib/services/spacesextn/index.js +46 -1
- package/lib/services/superuser/index.js +21 -22
- package/package.json +1 -1
package/lib/config/index.js
CHANGED
|
@@ -154,6 +154,7 @@ exports.AUTH_API_URLS = {
|
|
|
154
154
|
validateSpaceCode: '/accounts/{accountid}/space-code/validate',
|
|
155
155
|
validateClassCode: '/accounts/{accountid}/class-code/validate',
|
|
156
156
|
joinInstituteSpace: '/accounts/{accountid}/join-institute-space',
|
|
157
|
+
provisionStudentInInstitutionalSpace: '/accounts/{accountid}/student/join-institute-space',
|
|
157
158
|
provisionSpacesToStudent: '/accounts/{accountId}/student/provision-spaces',
|
|
158
159
|
provisionSpacesToTeacher: '/accounts/{accountId}/teacher/provision-spaces',
|
|
159
160
|
shadowProvision: '/org/{orgId}/shadow-provision',
|
|
@@ -236,6 +237,7 @@ exports.AUTHEXTN_API_URLS = {
|
|
|
236
237
|
|
|
237
238
|
//Space related API
|
|
238
239
|
entitleBulkUsersToProducts: '/accounts/{accountid}/entitle-users/bulk',
|
|
240
|
+
deleteUserAccount : '/accounts/{accountid}/ext-users/{ext_user_id}',
|
|
239
241
|
|
|
240
242
|
// Assigned Path APIs
|
|
241
243
|
userAssignedPaths: '/org/{orgid}/classes/{classid}/assigned-paths/{assignedpathid}/enroll-user/multi',
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
var ERROR_TYPES = {
|
|
28
28
|
API_ERROR: 'API_ERROR',
|
|
29
29
|
SDK_ERROR: 'SDK_ERROR',
|
|
30
|
-
CHANNEL_SUBSCRIPTION: 'CHANNEL_SUBSCRIPTION'
|
|
30
|
+
CHANNEL_SUBSCRIPTION: 'CHANNEL_SUBSCRIPTION',
|
|
31
|
+
UNEXPECTED_ERROR: 'UNEXPECTED_ERROR',
|
|
32
|
+
POLLING_INITIATION: 'POLLING_INITIATION'
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
var ERROR_CATEGORY = {
|
|
@@ -277,39 +277,45 @@ function changeSpaceCode(options) {
|
|
|
277
277
|
*/
|
|
278
278
|
function joinInstituteSpace(options) {
|
|
279
279
|
var self = this;
|
|
280
|
-
// Initializing promise
|
|
281
|
-
var dfd = q.defer();
|
|
282
|
-
|
|
283
|
-
if(options && options.ext_user_id &&
|
|
284
|
-
options.ext_role && options.space_code)
|
|
285
|
-
{
|
|
286
|
-
// Passed all validations, Contruct API url
|
|
287
|
-
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
288
|
-
self.config.AUTH_API_URLS.joinInstituteSpace;
|
|
289
|
-
url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
|
|
290
280
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
.set('Accept', 'application/json')
|
|
295
|
-
.send(options);
|
|
296
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
281
|
+
return new Promise(function(resolve, reject) {
|
|
282
|
+
if (options && options.ext_user_id && options.ext_role) {
|
|
283
|
+
// Passed all validations, Contruct API url
|
|
297
284
|
|
|
298
|
-
|
|
299
|
-
if(
|
|
300
|
-
|
|
301
|
-
|
|
285
|
+
var url;
|
|
286
|
+
if (options.ext_role === 'student') {
|
|
287
|
+
url = self.config.DEFAULT_HOSTS.AUTH +
|
|
288
|
+
self.config.AUTH_API_URLS.provisionStudentInInstitutionalSpace;
|
|
302
289
|
}
|
|
303
|
-
else {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
err.message = err.description = 'ext_user_id or ext_role or space_code not found in request options.';
|
|
308
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
309
|
-
dfd.reject(err);
|
|
310
|
-
}
|
|
290
|
+
else {
|
|
291
|
+
url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.joinInstituteSpace;
|
|
292
|
+
}
|
|
293
|
+
url = helpers.api.constructAPIUrl(url, { accountid : self.accountId });
|
|
311
294
|
|
|
312
|
-
|
|
295
|
+
// Setup request with URL and Params
|
|
296
|
+
var requestAPI = request.post(url)
|
|
297
|
+
.set('Content-Type', 'application/json')
|
|
298
|
+
.set('Accept', 'application/json');
|
|
299
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
300
|
+
|
|
301
|
+
requestAPI
|
|
302
|
+
.send(options)
|
|
303
|
+
.agent(keepaliveAgent)
|
|
304
|
+
.end(function(error, response) {
|
|
305
|
+
if (error) {
|
|
306
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
307
|
+
reject(err);
|
|
308
|
+
}
|
|
309
|
+
else { resolve(response.body); }
|
|
310
|
+
});
|
|
311
|
+
} else {
|
|
312
|
+
var err = {};
|
|
313
|
+
err.message = err.description = 'ext_user_id or ext_role not found' +
|
|
314
|
+
' in request options.';
|
|
315
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
316
|
+
reject(err);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
313
319
|
}
|
|
314
320
|
|
|
315
321
|
/**
|
|
@@ -849,6 +855,7 @@ function updateUserInformation(options) {
|
|
|
849
855
|
};
|
|
850
856
|
if(options.ref_id) { bodyParams.ref_id = options.ref_id; }
|
|
851
857
|
if(options.ext_email) { bodyParams.ext_email = options.ext_email; }
|
|
858
|
+
if(options.ext_username) { bodyParams.ext_username = options.ext_username; }
|
|
852
859
|
if(options.ext_first_name) { bodyParams.ext_first_name = options.ext_first_name; }
|
|
853
860
|
if(options.ext_last_name) { bodyParams.ext_last_name = options.ext_last_name; }
|
|
854
861
|
if(options.address) { bodyParams.address = options.address; }
|
|
@@ -42,7 +42,8 @@ function spacesextn(accountId) {
|
|
|
42
42
|
this.accountId = accountId;
|
|
43
43
|
return {
|
|
44
44
|
entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this),
|
|
45
|
-
setupUser: setupUser.bind(this)
|
|
45
|
+
setupUser: setupUser.bind(this),
|
|
46
|
+
deleteUserAccount : deleteUserAccount.bind(this)
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -129,3 +130,47 @@ function setupUser(options) {
|
|
|
129
130
|
}
|
|
130
131
|
return deferred.promise;
|
|
131
132
|
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Wiki Link for SDK params
|
|
136
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/04_AUTH-Adapter#getuserprofileparams
|
|
137
|
+
*/
|
|
138
|
+
function deleteUserAccount(options) {
|
|
139
|
+
var self = this;
|
|
140
|
+
return new Promise(function(resolve, reject) {
|
|
141
|
+
|
|
142
|
+
if (options.ext_user_id && options.body) {
|
|
143
|
+
//Passed all validations, Contruct API url
|
|
144
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
145
|
+
self.config.AUTHEXTN_API_URLS.deleteUserAccount;
|
|
146
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
147
|
+
accountid: self.accountId,
|
|
148
|
+
ext_user_id: options.ext_user_id,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Setup request
|
|
152
|
+
var requestAPI = request.delete(url)
|
|
153
|
+
.set('Content-Type', 'application/json')
|
|
154
|
+
.set('Accept', 'application/json');
|
|
155
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
156
|
+
|
|
157
|
+
requestAPI
|
|
158
|
+
.send(options.body)
|
|
159
|
+
.agent(keepaliveAgent)
|
|
160
|
+
.end(function(error, response) {
|
|
161
|
+
if (error) {
|
|
162
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
163
|
+
reject(err);
|
|
164
|
+
} else {
|
|
165
|
+
resolve(response.body);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
} else {
|
|
169
|
+
var err = {};
|
|
170
|
+
err.description = 'Mandatory field \'ext_user_id\' or \'body\' in request options.';
|
|
171
|
+
err.message = err.description;
|
|
172
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
173
|
+
reject(err);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
@@ -27,6 +27,7 @@ var q = require('q');
|
|
|
27
27
|
var request = require('superagent');
|
|
28
28
|
|
|
29
29
|
var helpers = require('../../helpers');
|
|
30
|
+
var requestLayer = require('../../helpers/lib/requestLayer');
|
|
30
31
|
|
|
31
32
|
var DLSError = helpers.errors.DLSError;
|
|
32
33
|
|
|
@@ -48,34 +49,32 @@ function superuser(accountId) {
|
|
|
48
49
|
*/
|
|
49
50
|
function getAllInstitutions(options) {
|
|
50
51
|
var self = this;
|
|
51
|
-
// Initializing promise
|
|
52
|
-
var dfd = q.defer();
|
|
53
52
|
|
|
54
|
-
var url =
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
var url = helpers.api.constructAPIUrl(
|
|
54
|
+
self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.getAllInstitutions,
|
|
55
|
+
{ accountid : self.accountId }
|
|
56
|
+
);
|
|
57
57
|
|
|
58
58
|
var params = {};
|
|
59
|
-
if(options) {
|
|
60
|
-
if(options.lookup) { params.lookup = options.lookup; }
|
|
61
|
-
if(options.cursor) { params.cursor = options.cursor; }
|
|
62
|
-
if(options.
|
|
59
|
+
if (options) {
|
|
60
|
+
if (options.lookup) { params.lookup = options.lookup; }
|
|
61
|
+
if (options.cursor) { params.cursor = options.cursor; }
|
|
62
|
+
if (options.start) { params.start = options.start; }
|
|
63
|
+
if (options.end) { params.end = options.end; }
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
//
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
// Prepare request parameters & execute request
|
|
67
|
+
var reqOptions = {
|
|
68
|
+
params: params,
|
|
69
|
+
headers: { traceid: self.traceid }
|
|
70
|
+
};
|
|
71
|
+
return requestLayer.get(url, reqOptions)
|
|
72
|
+
.then(function (response) {
|
|
73
|
+
return response.body;
|
|
74
|
+
})
|
|
75
|
+
.catch(function (err) {
|
|
76
|
+
throw new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
76
77
|
});
|
|
77
|
-
|
|
78
|
-
return dfd.promise;
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
/**
|
package/package.json
CHANGED