comprodls-sdk 2.64.1 → 2.67.0
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 +262 -3
- package/dist/comprodls-sdk.min.js +15 -15
- package/lib/config/index.js +5 -1
- package/lib/services/authextn/index.js +257 -2
- package/package.json +3 -3
- package/test.js +38 -0
package/lib/config/index.js
CHANGED
|
@@ -243,7 +243,11 @@ exports.AUTHEXTN_API_URLS = {
|
|
|
243
243
|
userAssignedPaths: '/org/{orgid}/classes/{classid}/assigned-paths/{assignedpathid}/enroll-user/multi',
|
|
244
244
|
|
|
245
245
|
// Class related APIs
|
|
246
|
-
particularClass: '/org/{orgId}/classes/{classId}'
|
|
246
|
+
particularClass: '/org/{orgId}/classes/{classId}',
|
|
247
|
+
|
|
248
|
+
// Org Entitlement related APIs
|
|
249
|
+
orgProductEntitlement: '/org/{orgid}/org-entitlements',
|
|
250
|
+
setupUser: '/accounts/{accountId}/user/setup'
|
|
247
251
|
|
|
248
252
|
};
|
|
249
253
|
|
|
@@ -41,8 +41,10 @@ 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 {
|
|
47
|
+
// Gradeformat related APIs
|
|
46
48
|
createGradeformat: createGradeformat.bind(this),
|
|
47
49
|
updateGradeformat: updateGradeformat.bind(this),
|
|
48
50
|
deleteGradeformat: deleteGradeformat.bind(this),
|
|
@@ -54,9 +56,21 @@ function authextn() {
|
|
|
54
56
|
getParticularGradeformatOfAClass: getParticularGradeformatOfAClass.bind(this),
|
|
55
57
|
getAllGradeformatsOfAClass: getAllGradeformatsOfAClass.bind(this),
|
|
56
58
|
getClassesOfAGradeformat: getClassesOfAGradeformat.bind(this),
|
|
59
|
+
|
|
60
|
+
// Assigned-path related APIs
|
|
57
61
|
createUserAssignedPathEnrollments: createUserAssignedPathEnrollments.bind(this),
|
|
58
62
|
deleteUserAssignedPathEnrollments: deleteUserAssignedPathEnrollments.bind(this),
|
|
59
|
-
|
|
63
|
+
|
|
64
|
+
// Class related APIs
|
|
65
|
+
getParticularClassV2: getParticularClassV2.bind(this),
|
|
66
|
+
|
|
67
|
+
// Org Entitlement related APIs
|
|
68
|
+
createOrgProductEntitlement: createOrgProductEntitlement.bind(this),
|
|
69
|
+
updateOrgProductEntitlement: updateOrgProductEntitlement.bind(this),
|
|
70
|
+
getParticularOrgProductEntitlement: getParticularOrgProductEntitlement.bind(this),
|
|
71
|
+
getAllOrgProductEntitlements: getAllOrgProductEntitlements.bind(this),
|
|
72
|
+
setupUser: setupUser.bind(this)
|
|
73
|
+
|
|
60
74
|
};
|
|
61
75
|
}
|
|
62
76
|
|
|
@@ -883,3 +897,244 @@ function getParticularClassV2(options) {
|
|
|
883
897
|
|
|
884
898
|
return deferred.promise;
|
|
885
899
|
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* @param {
|
|
903
|
+
* *productcode: "string",
|
|
904
|
+
* status: "string" // ['active', 'revoked'] - default: 'active'
|
|
905
|
+
* expired: <boolean>, // default: false
|
|
906
|
+
* startdate: <epoch>,
|
|
907
|
+
* enddate: <epoch>,
|
|
908
|
+
* audit: <boolean> // [true] - default: true
|
|
909
|
+
* ext_data: {...},
|
|
910
|
+
* } options
|
|
911
|
+
*/
|
|
912
|
+
function createOrgProductEntitlement(options) {
|
|
913
|
+
var self = this;
|
|
914
|
+
// Initializing promise
|
|
915
|
+
var dfd = q.defer();
|
|
916
|
+
|
|
917
|
+
if (options && options.productcode) {
|
|
918
|
+
// Passed all validations, Contruct API url
|
|
919
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
920
|
+
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
921
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
922
|
+
|
|
923
|
+
var requestAPI = request.post(url)
|
|
924
|
+
.set('Content-Type', 'application/json')
|
|
925
|
+
.set('Accept', 'application/json')
|
|
926
|
+
.send(options);
|
|
927
|
+
|
|
928
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
929
|
+
|
|
930
|
+
requestAPI
|
|
931
|
+
.agent(keepaliveAgent)
|
|
932
|
+
.end(function(error, response) {
|
|
933
|
+
if (error) {
|
|
934
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
935
|
+
dfd.reject(err);
|
|
936
|
+
}
|
|
937
|
+
else { dfd.resolve(response.body); }
|
|
938
|
+
});
|
|
939
|
+
} else {
|
|
940
|
+
var err = {};
|
|
941
|
+
err.message = err.description = 'Mandatory param: productcode not found in request options.';
|
|
942
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
943
|
+
dfd.reject(err);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
return dfd.promise;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* @param {
|
|
951
|
+
* *productcode: "string",
|
|
952
|
+
* status: "string" // ['active', 'revoked']
|
|
953
|
+
* expired: <boolean>,
|
|
954
|
+
* startdate: <epoch>,
|
|
955
|
+
* enddate: <epoch>,
|
|
956
|
+
* audit: <boolean> // [true] - default: true
|
|
957
|
+
* ext_data: {...},
|
|
958
|
+
* } options
|
|
959
|
+
*/
|
|
960
|
+
function updateOrgProductEntitlement(options) {
|
|
961
|
+
var self = this;
|
|
962
|
+
// Initializing promise
|
|
963
|
+
var dfd = q.defer();
|
|
964
|
+
|
|
965
|
+
if (options && options.productcode) {
|
|
966
|
+
// Passed all validations, Contruct API url
|
|
967
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
968
|
+
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
969
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
970
|
+
|
|
971
|
+
var requestAPI = request.put(url)
|
|
972
|
+
.set('Content-Type', 'application/json')
|
|
973
|
+
.set('Accept', 'application/json')
|
|
974
|
+
.send(options);
|
|
975
|
+
|
|
976
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
977
|
+
|
|
978
|
+
requestAPI
|
|
979
|
+
.agent(keepaliveAgent)
|
|
980
|
+
.end(function(error, response) {
|
|
981
|
+
if (error) {
|
|
982
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
983
|
+
dfd.reject(err);
|
|
984
|
+
}
|
|
985
|
+
else { dfd.resolve(response.body); }
|
|
986
|
+
});
|
|
987
|
+
} else {
|
|
988
|
+
var err = {};
|
|
989
|
+
err.message = err.description = 'Mandatory param: productcode not found in request options.';
|
|
990
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
991
|
+
dfd.reject(err);
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
return dfd.promise;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* @param {
|
|
999
|
+
* *productcode: "string"
|
|
1000
|
+
* } options
|
|
1001
|
+
*/
|
|
1002
|
+
function getParticularOrgProductEntitlement(options) {
|
|
1003
|
+
var self = this;
|
|
1004
|
+
//Initializing promise
|
|
1005
|
+
var deferred = q.defer();
|
|
1006
|
+
|
|
1007
|
+
//Validations
|
|
1008
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
1009
|
+
if (error) {
|
|
1010
|
+
deferred.reject(error);
|
|
1011
|
+
} else {
|
|
1012
|
+
if (options && options.productcode) {
|
|
1013
|
+
// Passed all validations, Contruct the API URL
|
|
1014
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
1015
|
+
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
1016
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
1017
|
+
|
|
1018
|
+
// Setup request with URL and Query Params
|
|
1019
|
+
var params = { productcode: options.productcode };
|
|
1020
|
+
var requestAPI = request.get(url).query(params);
|
|
1021
|
+
|
|
1022
|
+
// Setup 'traceid' in request header
|
|
1023
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1024
|
+
|
|
1025
|
+
// Setup 'token' in Authorization header
|
|
1026
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
1027
|
+
|
|
1028
|
+
requestAPI.agent(keepaliveAgent).end(function (error, response) {
|
|
1029
|
+
if (error) {
|
|
1030
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
1031
|
+
deferred.reject(error);
|
|
1032
|
+
} else {
|
|
1033
|
+
deferred.resolve(response.body);
|
|
1034
|
+
}
|
|
1035
|
+
});
|
|
1036
|
+
} else {
|
|
1037
|
+
error = {};
|
|
1038
|
+
error.message = error.description = 'Mandatory field \'productcode\' not found '+
|
|
1039
|
+
'in request options.';
|
|
1040
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
1041
|
+
deferred.reject(error);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
return deferred.promise;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* @param {
|
|
1050
|
+
* status: "string" // ['active', 'revoked']
|
|
1051
|
+
* expired: <boolean>,
|
|
1052
|
+
* cursor: <epoch>
|
|
1053
|
+
* } options
|
|
1054
|
+
*/
|
|
1055
|
+
function getAllOrgProductEntitlements(options) {
|
|
1056
|
+
var self = this;
|
|
1057
|
+
//Initializing promise
|
|
1058
|
+
var deferred = q.defer();
|
|
1059
|
+
|
|
1060
|
+
//Validations
|
|
1061
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
1062
|
+
if (error) {
|
|
1063
|
+
deferred.reject(error);
|
|
1064
|
+
} else {
|
|
1065
|
+
// Passed all validations, Contruct the API URL
|
|
1066
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
1067
|
+
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
1068
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
1069
|
+
|
|
1070
|
+
// Setup request with URL and Query Params
|
|
1071
|
+
var params = { productcode: options.productcode };
|
|
1072
|
+
|
|
1073
|
+
if (options.status) { params.status = options.status; }
|
|
1074
|
+
if (options.hasOwnProperty('expired')) { params.expired = options.expired; }
|
|
1075
|
+
if (options.cursor) { params.cursor = options.cursor; }
|
|
1076
|
+
|
|
1077
|
+
var requestAPI = request.get(url).query(params);
|
|
1078
|
+
|
|
1079
|
+
// Setup 'traceid' in request header
|
|
1080
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1081
|
+
|
|
1082
|
+
// Setup 'token' in Authorization header
|
|
1083
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
1084
|
+
|
|
1085
|
+
requestAPI.agent(keepaliveAgent).end(function (error, response) {
|
|
1086
|
+
if (error) {
|
|
1087
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
1088
|
+
deferred.reject(error);
|
|
1089
|
+
} else {
|
|
1090
|
+
deferred.resolve(response.body);
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
return deferred.promise;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* @param {
|
|
1100
|
+
* ext_user_id: "string", // mandatory
|
|
1101
|
+
* workflow_type: "string", // mandatory
|
|
1102
|
+
* <workflow_type>: {} // mandatory
|
|
1103
|
+
* } options
|
|
1104
|
+
*/
|
|
1105
|
+
function setupUser(options) {
|
|
1106
|
+
var self = this;
|
|
1107
|
+
//Initializing promise
|
|
1108
|
+
var deferred = q.defer();
|
|
1109
|
+
|
|
1110
|
+
if(options && options.ext_user_id && options.workflow_type) {
|
|
1111
|
+
//Passed all validations, Contruct API url
|
|
1112
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN + self.config.AUTHEXTN_API_URLS.setupUser;
|
|
1113
|
+
url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
|
|
1114
|
+
|
|
1115
|
+
var requestAPI = request.post(url)
|
|
1116
|
+
.set('Content-Type', 'application/json')
|
|
1117
|
+
.set('Accept', 'application/json')
|
|
1118
|
+
.send(options);
|
|
1119
|
+
|
|
1120
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1121
|
+
|
|
1122
|
+
requestAPI
|
|
1123
|
+
.agent(keepaliveAgent)
|
|
1124
|
+
.end(function(err, res) {
|
|
1125
|
+
if(err) {
|
|
1126
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
1127
|
+
deferred.reject(err);
|
|
1128
|
+
} else {
|
|
1129
|
+
deferred.resolve(res.body);
|
|
1130
|
+
}
|
|
1131
|
+
});
|
|
1132
|
+
} else {
|
|
1133
|
+
err = {};
|
|
1134
|
+
err.message = err.description = 'Mandatory field \'ext_user_id\' or \'workflow_type\' not found '+
|
|
1135
|
+
'in the request options.';
|
|
1136
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1137
|
+
deferred.reject(err);
|
|
1138
|
+
}
|
|
1139
|
+
return deferred.promise;
|
|
1140
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comprodls-sdk",
|
|
3
3
|
"description": "comproDLS SDK for JavaScript",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.67.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Compro Technologies Private Limited",
|
|
7
7
|
"url": "http://www.comprotechnologies.com/"
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"agentkeepalive": "4.2.0",
|
|
16
16
|
"extend": "3.0.2",
|
|
17
|
-
"pubnub": "7.
|
|
17
|
+
"pubnub": "7.5.0",
|
|
18
18
|
"q": "~1.4.1",
|
|
19
19
|
"string-template": "^1.0.0",
|
|
20
|
-
"superagent": "
|
|
20
|
+
"superagent": "3.8.3",
|
|
21
21
|
"validate.js": "^0.9.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
package/test.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
var orgId = 'dev1';
|
|
3
|
+
|
|
4
|
+
var ComproDLS = require('../comprodls-sdk-js/lib/comprodls.js').init('DEVELOPMENT','GLOBAL');
|
|
5
|
+
|
|
6
|
+
var accountId = 'compro';
|
|
7
|
+
var tokenObj = {
|
|
8
|
+
// "access_token": "71a2d361-16b4-40b4-9a73-2499f808d7fe",
|
|
9
|
+
//"access_token" : "YWMtb2nasMuyEemJvL3ph9UnmAAAAW0KQNb1ziRGuAkJ_n6LweFX9KOhYaSQeKg~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e", //student //YWMtw4m3tmsMEem5x6kSLL2ajAAAAWqQ3dJz4CkidQEwcm1LDszgrThOUuDLCkA~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e
|
|
10
|
+
// "access_token" : "YWMtQAfQGHfCEemdBmGZgYqIcgAAAWrkJ96wsnysSc8M5ilW1ZI1jOeLo226vn8~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e", //admin
|
|
11
|
+
// "expires_in": 604800,
|
|
12
|
+
// "refresh_token": "c002d2710236789e3f36d0b8670a07b684f44b4a43e9c4a322260c11390d37826a889053c876df0dc3ae49f4701cc27bdc42d77b62ec3735eaaf9ea35cc433f208aeb1d7003eddf38ec9ab418e40caa2fefb9fda6454a3b98daf9d911db4a4e8ca285a2dfbb395b7"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var self = this;
|
|
17
|
+
var Adapter = ComproDLS.AuthExtn(accountId);
|
|
18
|
+
|
|
19
|
+
var Options = {
|
|
20
|
+
"ext_user_id": "11jan_07",
|
|
21
|
+
"workflow_type": "org_entitlement",
|
|
22
|
+
"org_entitlement": {
|
|
23
|
+
"productcode": "evolve_l1",
|
|
24
|
+
"orgid": "dev1",
|
|
25
|
+
"dls_user_id": "71a2d361-16b4-40b4-9a73-2499f808d7fe",
|
|
26
|
+
"ext_role": "student"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Adapter.setupUser(Options)
|
|
31
|
+
.then(function (res) {
|
|
32
|
+
console.log("^^^^^^^^^^^^^", res);
|
|
33
|
+
})
|
|
34
|
+
.catch(function (err) {
|
|
35
|
+
console.log("ERR CATCG", err);
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
|