comprodls-sdk 2.89.0 → 2.90.3-development
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 +306 -731
- package/dist/comprodls-sdk.min.js +1 -1
- package/lib/config/index.js +3 -5
- package/lib/helpers/lib/errors.js +1 -1
- package/lib/services/auth/index.js +2 -178
- package/lib/services/authextn/index.js +111 -49
- package/lib/services/product/index.js +4 -12
- package/lib/services/pub/index.js +5 -12
- package/lib/services/pushX/index.js +128 -185
- package/lib/services/pushX/pubnubClientWrapper.js +3 -230
- package/lib/services/spaces/index.js +0 -5
- package/lib/services/spacesextn/index.js +1 -45
- package/lib/services/workflows/index.js +2 -4
- package/lib/services/xapi/index.js +43 -1
- package/package.json +2 -2
- package/test.js +38 -0
package/lib/config/index.js
CHANGED
|
@@ -139,7 +139,6 @@ exports.AUTH_API_URLS = {
|
|
|
139
139
|
getParticularShadowClassAPI: '/org/{orgId}/shadow/classes/{extClassId}',
|
|
140
140
|
classProductAssociation: '/org/{orgId}/classes/{classId}/associate-product/{productcode}',
|
|
141
141
|
multiClassProductAssociations: '/org/{orgId}/classes/{classId}/associate-product/multi',
|
|
142
|
-
classMaterialAssociation: '/org/{orgId}/classes/{classId}/associate-materials/multi',
|
|
143
142
|
enrollUsertoClass: '/org/{orgId}/classes/{classId}/enroll-user/{userId}',
|
|
144
143
|
enrollSelftoClass: '/org/{orgId}/classes/{classId}/enroll-self',
|
|
145
144
|
enrollMultiUserstoClass: '/org/{orgId}/classes/{classId}/enroll-user/multi',
|
|
@@ -322,7 +321,8 @@ exports.PRODUCT_API_URLS = {
|
|
|
322
321
|
|
|
323
322
|
exports.XAPI_API_URLS = {
|
|
324
323
|
postMultiStatements: '/{orgId}/statements/multi',
|
|
325
|
-
postExternalMultiStatements: '/{orgId}/external/statements/multi'
|
|
324
|
+
postExternalMultiStatements: '/{orgId}/external/statements/multi',
|
|
325
|
+
resetUserProductProgress: '/accounts/{accountId}/progress/user/product/reset'
|
|
326
326
|
};
|
|
327
327
|
|
|
328
328
|
exports.ATTEMPTS_API_URLS = {
|
|
@@ -350,9 +350,7 @@ exports.PUB_API_URLS = {
|
|
|
350
350
|
|
|
351
351
|
exports.PUSHX_API_URLS = {
|
|
352
352
|
grantByUserOrgId: '/orgs/{orgId}/grants',
|
|
353
|
-
grantByAccountId: '/accounts/{accountId}/grants'
|
|
354
|
-
grantV2: '/ver/v2/grants',
|
|
355
|
-
getPushedEvents: '/accounts/{accountId}/pushed-events/channels'
|
|
353
|
+
grantByAccountId: '/accounts/{accountId}/grants'
|
|
356
354
|
};
|
|
357
355
|
|
|
358
356
|
exports.INTEGRATIONS_API_URLS = {
|
|
@@ -117,7 +117,7 @@ function PUSHXError(category, error) {
|
|
|
117
117
|
|
|
118
118
|
if (category === ERROR_CATEGORY.PUSHX) {
|
|
119
119
|
this.category = ERROR_CATEGORY.PUSHX;
|
|
120
|
-
this.type =
|
|
120
|
+
this.type = ERROR_TYPES.CHANNEL_SUBSCRIPTION;
|
|
121
121
|
this.status = ERROR_STATUS.ERROR;
|
|
122
122
|
this.message = error.message;
|
|
123
123
|
this.data = error;
|
|
@@ -79,8 +79,6 @@ function auth() {
|
|
|
79
79
|
createClassProductAssociation: createClassProductAssociation.bind(this),
|
|
80
80
|
removeClassProductAssociation: removeClassProductAssociation.bind(this),
|
|
81
81
|
createMultiClassProductAssociations: createMultiClassProductAssociations.bind(this),
|
|
82
|
-
associateMaterialsWithClass: associateMaterialsWithClass.bind(this),
|
|
83
|
-
unassociateMaterialsWithClass: unassociateMaterialsWithClass.bind(this),
|
|
84
82
|
addItemsToShowcaseOfAClass: addItemsToShowcaseOfAClass.bind(this),
|
|
85
83
|
deleteItemsFromShowcaseOfAClass: deleteItemsFromShowcaseOfAClass.bind(this),
|
|
86
84
|
|
|
@@ -1399,111 +1397,6 @@ function createClassProductAssociation(options) {
|
|
|
1399
1397
|
return dfd.promise;
|
|
1400
1398
|
}
|
|
1401
1399
|
|
|
1402
|
-
/**
|
|
1403
|
-
* @param {
|
|
1404
|
-
* *classId: 'string',
|
|
1405
|
-
* *body: {
|
|
1406
|
-
* productcodes: ['string'],
|
|
1407
|
-
* bundlecodes: ['string'],
|
|
1408
|
-
* }
|
|
1409
|
-
* } options
|
|
1410
|
-
*/
|
|
1411
|
-
function associateMaterialsWithClass(options) {
|
|
1412
|
-
var self = this;
|
|
1413
|
-
// Initializing promise
|
|
1414
|
-
var dfd = q.defer();
|
|
1415
|
-
// Validations
|
|
1416
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
1417
|
-
if(err) { dfd.reject(err); }
|
|
1418
|
-
else {
|
|
1419
|
-
if(options && options.classId && options.body && (options.body.productcodes
|
|
1420
|
-
|| options.body.bundlecodes)) {
|
|
1421
|
-
// Passed all validations, Contruct API url
|
|
1422
|
-
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
1423
|
-
self.config.AUTH_API_URLS.classMaterialAssociation;
|
|
1424
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
1425
|
-
orgId: self.orgId, classId: options.classId
|
|
1426
|
-
});
|
|
1427
|
-
// Setup request with URL and Params
|
|
1428
|
-
var requestAPI = request.post(url)
|
|
1429
|
-
.set('Content-Type', 'application/json')
|
|
1430
|
-
.set('Accept', 'application/json');
|
|
1431
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1432
|
-
|
|
1433
|
-
// Setup token in Authorization header
|
|
1434
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
1435
|
-
|
|
1436
|
-
requestAPI.agent(keepaliveAgent).end(function(err, response) {
|
|
1437
|
-
if(err) {
|
|
1438
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
1439
|
-
dfd.reject(err);
|
|
1440
|
-
}
|
|
1441
|
-
else { dfd.resolve(response.body); }
|
|
1442
|
-
});
|
|
1443
|
-
} else {
|
|
1444
|
-
err = {};
|
|
1445
|
-
err.message = err.description = 'classId or productcodes or bundlecodes not found in'
|
|
1446
|
-
+ 'request options.';
|
|
1447
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1448
|
-
dfd.reject(err);
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
return dfd.promise;
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
/**
|
|
1455
|
-
* @param {
|
|
1456
|
-
* *classId: string,
|
|
1457
|
-
* *body: {
|
|
1458
|
-
* 'productcodes' :['string'],
|
|
1459
|
-
* 'bundlecodes' : ['string']
|
|
1460
|
-
* }
|
|
1461
|
-
* } options
|
|
1462
|
-
*/
|
|
1463
|
-
function unassociateMaterialsWithClass(options) {
|
|
1464
|
-
var self = this;
|
|
1465
|
-
// Initializing promise
|
|
1466
|
-
var dfd = q.defer();
|
|
1467
|
-
// Validations
|
|
1468
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
1469
|
-
if(err) { dfd.reject(err); }
|
|
1470
|
-
else {
|
|
1471
|
-
if(options && options.classId && options.body &&
|
|
1472
|
-
(options.body.productcodes || options.body.bundlecodes)) {
|
|
1473
|
-
// Passed all validations, Contruct API url
|
|
1474
|
-
var url= self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.classMaterialAssociation;
|
|
1475
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
1476
|
-
orgId: self.orgId, classId: options.classId
|
|
1477
|
-
});
|
|
1478
|
-
// Setup request with URL and Params
|
|
1479
|
-
var requestAPI = request.delete(url)
|
|
1480
|
-
.set('Content-Type', 'application/json')
|
|
1481
|
-
.set('Accept', 'application/json');
|
|
1482
|
-
|
|
1483
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1484
|
-
|
|
1485
|
-
// Setup token in Authorization header
|
|
1486
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
1487
|
-
|
|
1488
|
-
requestAPI.agent(keepaliveAgent).end(function(err, response) {
|
|
1489
|
-
if(err) {
|
|
1490
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
1491
|
-
dfd.reject(err);
|
|
1492
|
-
}
|
|
1493
|
-
else { dfd.resolve(response.body); }
|
|
1494
|
-
});
|
|
1495
|
-
} else {
|
|
1496
|
-
err = {};
|
|
1497
|
-
const msg = 'classId or productcodes or bundlecodes not found in request options.';
|
|
1498
|
-
err.message = msg;
|
|
1499
|
-
err.description = msg;
|
|
1500
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1501
|
-
dfd.reject(err);
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
return dfd.promise;
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
1400
|
//options = {
|
|
1508
1401
|
// classId: 'class uuid',
|
|
1509
1402
|
// productcode: 'product code'
|
|
@@ -2195,14 +2088,6 @@ function updateClass(options) {
|
|
|
2195
2088
|
"productcode": "string", //mandatory
|
|
2196
2089
|
"title": ""
|
|
2197
2090
|
}
|
|
2198
|
-
],
|
|
2199
|
-
"bundles": [ // optional
|
|
2200
|
-
{
|
|
2201
|
-
"bundlecode": "string", //mandatory
|
|
2202
|
-
},
|
|
2203
|
-
{
|
|
2204
|
-
"bundlecode": "string", //mandatory
|
|
2205
|
-
}
|
|
2206
2091
|
]
|
|
2207
2092
|
}
|
|
2208
2093
|
],
|
|
@@ -2218,7 +2103,6 @@ function updateClass(options) {
|
|
|
2218
2103
|
"students": true,
|
|
2219
2104
|
"teachers": true,
|
|
2220
2105
|
"products": true,
|
|
2221
|
-
"bundles": true,
|
|
2222
2106
|
"groups": true,
|
|
2223
2107
|
"assigned_paths": true,
|
|
2224
2108
|
"tags": true,
|
|
@@ -2226,7 +2110,6 @@ function updateClass(options) {
|
|
|
2226
2110
|
"analytics_score_aggregation_type": true,
|
|
2227
2111
|
"ext_data": true,
|
|
2228
2112
|
"limits": true,
|
|
2229
|
-
"skip_assigned_path_create_notification": true,
|
|
2230
2113
|
"advanced": {
|
|
2231
2114
|
"students": [
|
|
2232
2115
|
{
|
|
@@ -2259,7 +2142,6 @@ function updateClass(options) {
|
|
|
2259
2142
|
}
|
|
2260
2143
|
],
|
|
2261
2144
|
"products": [ { "productcode": "string" } ],
|
|
2262
|
-
"bundles": [ { "bundlecode": "string" } ],
|
|
2263
2145
|
"analyticsharingmodel": "string" // Valid values: ['NOINHERIT_SYNCBACK']
|
|
2264
2146
|
"analytics_score_aggregation_type": "string", // Valid values: ['best', 'first', 'last']
|
|
2265
2147
|
"limits": {los: number, students: number} // Optional field
|
|
@@ -2486,12 +2368,7 @@ function deleteAssignedPath(options) {
|
|
|
2486
2368
|
item_type: 'string', //mandatory, ['dls-internal','external']
|
|
2487
2369
|
dls_product_code: 'string' //mandatory only if item_type is 'dls-internal'
|
|
2488
2370
|
}
|
|
2489
|
-
]
|
|
2490
|
-
"rules": {}, // Optional
|
|
2491
|
-
"context": { // Optional (Needed for system event only)
|
|
2492
|
-
"bundle-code": "string",
|
|
2493
|
-
"space_key": "string"
|
|
2494
|
-
}
|
|
2371
|
+
]
|
|
2495
2372
|
}
|
|
2496
2373
|
}
|
|
2497
2374
|
*/
|
|
@@ -3252,60 +3129,7 @@ function deleteItemsFromShowcaseOfAClass(options){
|
|
|
3252
3129
|
* startdate: 'Epoch(Unix) timestamp in milliseconds',
|
|
3253
3130
|
* enddate: 'Epoch(Unix) timestamp in milliseconds',
|
|
3254
3131
|
* instructor: 'user who clones the class',
|
|
3255
|
-
* clone_setting: {
|
|
3256
|
-
* "students": true,
|
|
3257
|
-
* "teachers": true,
|
|
3258
|
-
* "products": true,
|
|
3259
|
-
* "bundles": true,
|
|
3260
|
-
* "groups": true,
|
|
3261
|
-
* "assigned_paths": true,
|
|
3262
|
-
* "skip_assigned_path_create_notification": true,
|
|
3263
|
-
* "tags": true,
|
|
3264
|
-
* "analyticsharingmodel": true,
|
|
3265
|
-
* "analytics_score_aggregation_type": true,
|
|
3266
|
-
* "ext_data": true,
|
|
3267
|
-
* "limits": true,
|
|
3268
|
-
* "advanced": {
|
|
3269
|
-
* "students": [
|
|
3270
|
-
* {
|
|
3271
|
-
* "ext_user_id": "string"
|
|
3272
|
-
* }
|
|
3273
|
-
* ],
|
|
3274
|
-
* "teachers": [
|
|
3275
|
-
* {
|
|
3276
|
-
* "ext_user_id": "string"
|
|
3277
|
-
* }
|
|
3278
|
-
* ],
|
|
3279
|
-
* "groups": [
|
|
3280
|
-
* {
|
|
3281
|
-
* "groupid": "string"
|
|
3282
|
-
* }
|
|
3283
|
-
* ],
|
|
3284
|
-
* "assigned_paths": [
|
|
3285
|
-
* {
|
|
3286
|
-
* "assigned_path_id": "string",
|
|
3287
|
-
* "startdate": 0,
|
|
3288
|
-
* "duedate": 0
|
|
3289
|
-
* }
|
|
3290
|
-
* ],
|
|
3291
|
-
* "products": [
|
|
3292
|
-
* {
|
|
3293
|
-
* "productcode": "string"
|
|
3294
|
-
* }
|
|
3295
|
-
* ],
|
|
3296
|
-
* "bundles": [
|
|
3297
|
-
* {
|
|
3298
|
-
* "bundlecode": "string"
|
|
3299
|
-
* }
|
|
3300
|
-
* ],
|
|
3301
|
-
* "analyticsharingmodel": "NOINHERIT_SYNCBACK",
|
|
3302
|
-
* "analytics_score_aggregation_type": "best",
|
|
3303
|
-
* "limits": {
|
|
3304
|
-
* "los": 0,
|
|
3305
|
-
* "students": 0
|
|
3306
|
-
* }
|
|
3307
|
-
* }
|
|
3308
|
-
* },
|
|
3132
|
+
* clone_setting: {}, // Optional field
|
|
3309
3133
|
* }
|
|
3310
3134
|
*/
|
|
3311
3135
|
function cloneClass(options) {
|
|
@@ -41,7 +41,8 @@ var keepaliveAgent = new Agent({
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
//AuthExtn Adaptor Contsructor
|
|
44
|
-
function authextn() {
|
|
44
|
+
function authextn(accountId) {
|
|
45
|
+
this.accountId = accountId;
|
|
45
46
|
return {
|
|
46
47
|
// Gradeformat related APIs
|
|
47
48
|
createGradeformat: createGradeformat.bind(this),
|
|
@@ -67,7 +68,9 @@ function authextn() {
|
|
|
67
68
|
createOrgProductEntitlement: createOrgProductEntitlement.bind(this),
|
|
68
69
|
updateOrgProductEntitlement: updateOrgProductEntitlement.bind(this),
|
|
69
70
|
getParticularOrgProductEntitlement: getParticularOrgProductEntitlement.bind(this),
|
|
70
|
-
getAllOrgProductEntitlements: getAllOrgProductEntitlements.bind(this)
|
|
71
|
+
getAllOrgProductEntitlements: getAllOrgProductEntitlements.bind(this),
|
|
72
|
+
setupUser: setupUser.bind(this)
|
|
73
|
+
|
|
71
74
|
};
|
|
72
75
|
}
|
|
73
76
|
|
|
@@ -724,17 +727,14 @@ function getClassesOfAGradeformat(options) {
|
|
|
724
727
|
|
|
725
728
|
/*
|
|
726
729
|
options = {
|
|
727
|
-
assignedpathid: "string", //
|
|
730
|
+
assignedpathid: "string", //Mandatory
|
|
728
731
|
classid: "string", // Mandatory
|
|
729
|
-
body :
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
],
|
|
736
|
-
"context": {} // Optional
|
|
737
|
-
}
|
|
732
|
+
body : [ // min:1 , max: 50
|
|
733
|
+
{
|
|
734
|
+
extUserId: "string", //Mandatory
|
|
735
|
+
}.
|
|
736
|
+
....
|
|
737
|
+
]
|
|
738
738
|
}
|
|
739
739
|
*/
|
|
740
740
|
function createUserAssignedPathEnrollments(options) {
|
|
@@ -1018,7 +1018,64 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
1018
1018
|
//Initializing promise
|
|
1019
1019
|
var deferred = q.defer();
|
|
1020
1020
|
|
|
1021
|
-
|
|
1021
|
+
//Validations
|
|
1022
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
1023
|
+
if (error) {
|
|
1024
|
+
deferred.reject(error);
|
|
1025
|
+
} else {
|
|
1026
|
+
if (options && options.productcode) {
|
|
1027
|
+
// Passed all validations, Contruct the API URL
|
|
1028
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
1029
|
+
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
1030
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
1031
|
+
|
|
1032
|
+
// Setup request with URL and Query Params
|
|
1033
|
+
var params = { productcode: options.productcode };
|
|
1034
|
+
var requestAPI = request.get(url).query(params);
|
|
1035
|
+
|
|
1036
|
+
// Setup 'traceid' in request header
|
|
1037
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1038
|
+
|
|
1039
|
+
// Setup 'token' in Authorization header
|
|
1040
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
1041
|
+
|
|
1042
|
+
requestAPI.agent(keepaliveAgent).end(function (error, response) {
|
|
1043
|
+
if (error) {
|
|
1044
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
1045
|
+
deferred.reject(error);
|
|
1046
|
+
} else {
|
|
1047
|
+
deferred.resolve(response.body);
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1050
|
+
} else {
|
|
1051
|
+
error = {};
|
|
1052
|
+
error.message = error.description = 'Mandatory field \'productcode\' not found '+
|
|
1053
|
+
'in request options.';
|
|
1054
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
1055
|
+
deferred.reject(error);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
return deferred.promise;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* @param {
|
|
1064
|
+
* status: "string" // ['active', 'revoked']
|
|
1065
|
+
* expired: <boolean>,
|
|
1066
|
+
* cursor: <epoch>
|
|
1067
|
+
* } options
|
|
1068
|
+
*/
|
|
1069
|
+
function getAllOrgProductEntitlements(options) {
|
|
1070
|
+
var self = this;
|
|
1071
|
+
//Initializing promise
|
|
1072
|
+
var deferred = q.defer();
|
|
1073
|
+
|
|
1074
|
+
//Validations
|
|
1075
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
1076
|
+
if (error) {
|
|
1077
|
+
deferred.reject(error);
|
|
1078
|
+
} else {
|
|
1022
1079
|
// Passed all validations, Contruct the API URL
|
|
1023
1080
|
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
1024
1081
|
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
@@ -1026,11 +1083,19 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
1026
1083
|
|
|
1027
1084
|
// Setup request with URL and Query Params
|
|
1028
1085
|
var params = { productcode: options.productcode };
|
|
1086
|
+
|
|
1087
|
+
if (options.status) { params.status = options.status; }
|
|
1088
|
+
if (options.hasOwnProperty('expired')) { params.expired = options.expired; }
|
|
1089
|
+
if (options.cursor) { params.cursor = options.cursor; }
|
|
1090
|
+
|
|
1029
1091
|
var requestAPI = request.get(url).query(params);
|
|
1030
1092
|
|
|
1031
1093
|
// Setup 'traceid' in request header
|
|
1032
1094
|
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1033
1095
|
|
|
1096
|
+
// Setup 'token' in Authorization header
|
|
1097
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
1098
|
+
|
|
1034
1099
|
requestAPI.agent(keepaliveAgent).end(function (error, response) {
|
|
1035
1100
|
if (error) {
|
|
1036
1101
|
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
@@ -1039,12 +1104,6 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
1039
1104
|
deferred.resolve(response.body);
|
|
1040
1105
|
}
|
|
1041
1106
|
});
|
|
1042
|
-
} else {
|
|
1043
|
-
var error = {};
|
|
1044
|
-
error.message = error.description = 'Mandatory field \'productcode\' not found '+
|
|
1045
|
-
'in request options.';
|
|
1046
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
1047
|
-
deferred.reject(error);
|
|
1048
1107
|
}
|
|
1049
1108
|
|
|
1050
1109
|
return deferred.promise;
|
|
@@ -1052,41 +1111,44 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
1052
1111
|
|
|
1053
1112
|
/**
|
|
1054
1113
|
* @param {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
function
|
|
1114
|
+
* ext_user_id: "string", // mandatory
|
|
1115
|
+
* workflow_type: "string", // mandatory
|
|
1116
|
+
* <workflow_type>: {} // mandatory
|
|
1117
|
+
* } options
|
|
1118
|
+
*/
|
|
1119
|
+
function setupUser(options) {
|
|
1061
1120
|
var self = this;
|
|
1062
1121
|
//Initializing promise
|
|
1063
1122
|
var deferred = q.defer();
|
|
1064
1123
|
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
self.config.AUTHEXTN_API_URLS.
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
// Setup request with URL and Query Params
|
|
1071
|
-
var params = { productcode: options.productcode };
|
|
1124
|
+
if(options && options.ext_user_id && options.workflow_type) {
|
|
1125
|
+
//Passed all validations, Contruct API url
|
|
1126
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN + self.config.AUTHEXTN_API_URLS.setupUser;
|
|
1127
|
+
url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
|
|
1072
1128
|
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1129
|
+
var requestAPI = request.post(url)
|
|
1130
|
+
.set('Content-Type', 'application/json')
|
|
1131
|
+
.set('Accept', 'application/json')
|
|
1132
|
+
.send(options);
|
|
1076
1133
|
|
|
1077
|
-
|
|
1134
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1078
1135
|
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1136
|
+
requestAPI
|
|
1137
|
+
.agent(keepaliveAgent)
|
|
1138
|
+
.end(function(err, res) {
|
|
1139
|
+
if(err) {
|
|
1140
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
1141
|
+
deferred.reject(err);
|
|
1142
|
+
} else {
|
|
1143
|
+
deferred.resolve(res.body);
|
|
1144
|
+
}
|
|
1145
|
+
});
|
|
1146
|
+
} else {
|
|
1147
|
+
err = {};
|
|
1148
|
+
err.message = err.description = 'Mandatory field \'ext_user_id\' or \'workflow_type\' not found '+
|
|
1149
|
+
'in the request options.';
|
|
1150
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1151
|
+
deferred.reject(err);
|
|
1152
|
+
}
|
|
1153
|
+
return deferred.promise;
|
|
1092
1154
|
}
|
|
@@ -195,10 +195,9 @@ function getMicroEntitlementsForAUser(options) {
|
|
|
195
195
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
stage: "
|
|
200
|
-
|
|
201
|
-
} */
|
|
198
|
+
// options= {
|
|
199
|
+
// stage: "", //stage number or version
|
|
200
|
+
// }
|
|
202
201
|
function getAllBundles(options) {
|
|
203
202
|
var self = this;
|
|
204
203
|
var dfd = q.defer();
|
|
@@ -209,14 +208,7 @@ function getAllBundles(options) {
|
|
|
209
208
|
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
210
209
|
//Contruct parameters
|
|
211
210
|
var params = {};
|
|
212
|
-
if(options) {
|
|
213
|
-
if(options.stage){
|
|
214
|
-
params.stage = options.stage;
|
|
215
|
-
}
|
|
216
|
-
if(options.target_role){
|
|
217
|
-
params.target_role = options.target_role;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
211
|
+
if(options && options.stage) { params.stage = options.stage; }
|
|
220
212
|
|
|
221
213
|
//Setup request with URL and Post data
|
|
222
214
|
var requestAPI = request.get(url).query(params);
|
|
@@ -335,10 +335,10 @@ function updateBundle(options) {
|
|
|
335
335
|
return dfd.promise;
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
|
|
339
|
-
stage: "
|
|
340
|
-
|
|
341
|
-
|
|
338
|
+
// options= {
|
|
339
|
+
// stage: "", //stage number or version
|
|
340
|
+
// }
|
|
341
|
+
|
|
342
342
|
function getAllBundles(options) {
|
|
343
343
|
var self = this;
|
|
344
344
|
//Initializing promise
|
|
@@ -350,14 +350,7 @@ function getAllBundles(options) {
|
|
|
350
350
|
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, });
|
|
351
351
|
//Contruct parameters
|
|
352
352
|
var params = {};
|
|
353
|
-
if(options) {
|
|
354
|
-
if(options.stage){
|
|
355
|
-
params.stage = options.stage;
|
|
356
|
-
}
|
|
357
|
-
if(options.target_role){
|
|
358
|
-
params.target_role = options.target_role;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
353
|
+
if(options && options.stage) { params.stage = options.stage; }
|
|
361
354
|
|
|
362
355
|
//Setup request with URL and Post data
|
|
363
356
|
var requestAPI = request.get(url).query(params);
|