comprodls-sdk 2.102.0-thor → 2.103.0-qa.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 +54 -109
- package/dist/comprodls-sdk.min.js +1 -1
- package/lib/config/index.js +0 -2
- package/lib/helpers/lib/errors.js +1 -3
- package/lib/services/spaces/index.js +29 -35
- package/lib/services/spacesextn/index.js +1 -46
- package/lib/services/superuser/index.js +22 -22
- package/package.json +1 -1
package/lib/config/index.js
CHANGED
|
@@ -154,7 +154,6 @@ 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',
|
|
158
157
|
provisionSpacesToStudent: '/accounts/{accountId}/student/provision-spaces',
|
|
159
158
|
provisionSpacesToTeacher: '/accounts/{accountId}/teacher/provision-spaces',
|
|
160
159
|
shadowProvision: '/org/{orgId}/shadow-provision',
|
|
@@ -237,7 +236,6 @@ exports.AUTHEXTN_API_URLS = {
|
|
|
237
236
|
|
|
238
237
|
//Space related API
|
|
239
238
|
entitleBulkUsersToProducts: '/accounts/{accountid}/entitle-users/bulk',
|
|
240
|
-
deleteUserAccount : '/accounts/{accountid}/ext-users/{ext_user_id}',
|
|
241
239
|
|
|
242
240
|
// Assigned Path APIs
|
|
243
241
|
userAssignedPaths: '/org/{orgid}/classes/{classid}/assigned-paths/{assignedpathid}/enroll-user/multi',
|
|
@@ -27,9 +27,7 @@
|
|
|
27
27
|
var ERROR_TYPES = {
|
|
28
28
|
API_ERROR: 'API_ERROR',
|
|
29
29
|
SDK_ERROR: 'SDK_ERROR',
|
|
30
|
-
CHANNEL_SUBSCRIPTION: 'CHANNEL_SUBSCRIPTION'
|
|
31
|
-
UNEXPECTED_ERROR: 'UNEXPECTED_ERROR',
|
|
32
|
-
POLLING_INITIATION: 'POLLING_INITIATION'
|
|
30
|
+
CHANNEL_SUBSCRIPTION: 'CHANNEL_SUBSCRIPTION'
|
|
33
31
|
};
|
|
34
32
|
|
|
35
33
|
var ERROR_CATEGORY = {
|
|
@@ -277,45 +277,39 @@ function changeSpaceCode(options) {
|
|
|
277
277
|
*/
|
|
278
278
|
function joinInstituteSpace(options) {
|
|
279
279
|
var self = this;
|
|
280
|
+
// Initializing promise
|
|
281
|
+
var dfd = q.defer();
|
|
280
282
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
self.config.AUTH_API_URLS.provisionStudentInInstitutionalSpace;
|
|
289
|
-
}
|
|
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 });
|
|
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 });
|
|
294
290
|
|
|
295
|
-
|
|
296
|
-
|
|
291
|
+
// Setup request with URL and Params
|
|
292
|
+
var requestAPI = request.post(url)
|
|
297
293
|
.set('Content-Type', 'application/json')
|
|
298
|
-
.set('Accept', 'application/json')
|
|
299
|
-
|
|
294
|
+
.set('Accept', 'application/json')
|
|
295
|
+
.send(options);
|
|
296
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
300
297
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
reject(err);
|
|
317
|
-
}
|
|
318
|
-
});
|
|
298
|
+
requestAPI.end(function(error, response) {
|
|
299
|
+
if(error) {
|
|
300
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
301
|
+
dfd.reject(err);
|
|
302
|
+
}
|
|
303
|
+
else { dfd.resolve(response.body); }
|
|
304
|
+
});
|
|
305
|
+
} else {
|
|
306
|
+
var err = {};
|
|
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
|
+
}
|
|
311
|
+
|
|
312
|
+
return dfd.promise;
|
|
319
313
|
}
|
|
320
314
|
|
|
321
315
|
/**
|
|
@@ -42,8 +42,7 @@ function spacesextn(accountId) {
|
|
|
42
42
|
this.accountId = accountId;
|
|
43
43
|
return {
|
|
44
44
|
entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this),
|
|
45
|
-
setupUser: setupUser.bind(this)
|
|
46
|
-
deleteUserAccount : deleteUserAccount.bind(this)
|
|
45
|
+
setupUser: setupUser.bind(this)
|
|
47
46
|
};
|
|
48
47
|
}
|
|
49
48
|
|
|
@@ -130,47 +129,3 @@ function setupUser(options) {
|
|
|
130
129
|
}
|
|
131
130
|
return deferred.promise;
|
|
132
131
|
}
|
|
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,33 @@ 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.
|
|
62
|
-
if(options.
|
|
59
|
+
if (options) {
|
|
60
|
+
if (options.lookup) { params.lookup = options.lookup; }
|
|
61
|
+
if (options.country) { params.country = options.country; }
|
|
62
|
+
if (options.cursor) { params.cursor = options.cursor; }
|
|
63
|
+
if (options.start) { params.start = options.start; }
|
|
64
|
+
if (options.end) { params.end = options.end; }
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
//
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
// Prepare request parameters & execute request
|
|
68
|
+
var reqOptions = {
|
|
69
|
+
params: params,
|
|
70
|
+
headers: { traceid: self.traceid }
|
|
71
|
+
};
|
|
72
|
+
return requestLayer.get(url, reqOptions)
|
|
73
|
+
.then(function (response) {
|
|
74
|
+
return response.body;
|
|
75
|
+
})
|
|
76
|
+
.catch(function (err) {
|
|
77
|
+
throw new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
76
78
|
});
|
|
77
|
-
|
|
78
|
-
return dfd.promise;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
package/package.json
CHANGED