comprodls-sdk 2.86.2-valky → 2.90.2
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 +303 -558
- package/dist/comprodls-sdk.min.js +1 -1
- package/lib/config/index.js +3 -17
- package/lib/helpers/lib/errors.js +2 -4
- 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 +127 -181
- package/lib/services/pushX/pubnubClientWrapper.js +3 -49
- 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/dist/comprodls-sdk.js
CHANGED
|
@@ -207,18 +207,6 @@ exports.REALM_HOSTS = {
|
|
|
207
207
|
ANALYTICS: 'http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-analytics',
|
|
208
208
|
INTEGRATION: 'http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-integrations',
|
|
209
209
|
DRIVE: 'http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-drive'
|
|
210
|
-
},
|
|
211
|
-
VALKY: {
|
|
212
|
-
PUB: 'http://internal-dls-asgard-valky-1830585247.us-west-2.elb.amazonaws.com/lb-pub',
|
|
213
|
-
AUTH: 'http://internal-dls-asgard-valky-1830585247.us-west-2.elb.amazonaws.com/lb-auth',
|
|
214
|
-
AUTHEXTN: 'http://internal-dls-asgard-valky-1830585247.us-west-2.elb.amazonaws.com/lb-authextn',
|
|
215
|
-
PUSHX: 'http://internal-dls-asgard-valky-1830585247.us-west-2.elb.amazonaws.com/lb-pushx',
|
|
216
|
-
XAPI: 'http://internal-dls-asgard-valky-1830585247.us-west-2.elb.amazonaws.com/lb-xapi',
|
|
217
|
-
ATTEMPTS: 'http://internal-dls-asgard-valky-1830585247.us-west-2.elb.amazonaws.com/lb-attempts',
|
|
218
|
-
PRODUCT: 'http://internal-dls-asgard-valky-1830585247.us-west-2.elb.amazonaws.com/lb-product',
|
|
219
|
-
ANALYTICS: 'http://internal-dls-asgard-valky-1830585247.us-west-2.elb.amazonaws.com/lb-analytics',
|
|
220
|
-
INTEGRATION: 'http://internal-dls-asgard-valky-1830585247.us-west-2.elb.amazonaws.com/lb-integrations',
|
|
221
|
-
DRIVE: 'http://internal-dls-asgard-valky-1830585247.us-west-2.elb.amazonaws.com/lb-drive'
|
|
222
210
|
}
|
|
223
211
|
},
|
|
224
212
|
CUP: {
|
|
@@ -304,7 +292,6 @@ exports.AUTH_API_URLS = {
|
|
|
304
292
|
getParticularShadowClassAPI: '/org/{orgId}/shadow/classes/{extClassId}',
|
|
305
293
|
classProductAssociation: '/org/{orgId}/classes/{classId}/associate-product/{productcode}',
|
|
306
294
|
multiClassProductAssociations: '/org/{orgId}/classes/{classId}/associate-product/multi',
|
|
307
|
-
classMaterialAssociation: '/org/{orgId}/classes/{classId}/associate-materials/multi',
|
|
308
295
|
enrollUsertoClass: '/org/{orgId}/classes/{classId}/enroll-user/{userId}',
|
|
309
296
|
enrollSelftoClass: '/org/{orgId}/classes/{classId}/enroll-self',
|
|
310
297
|
enrollMultiUserstoClass: '/org/{orgId}/classes/{classId}/enroll-user/multi',
|
|
@@ -487,7 +474,8 @@ exports.PRODUCT_API_URLS = {
|
|
|
487
474
|
|
|
488
475
|
exports.XAPI_API_URLS = {
|
|
489
476
|
postMultiStatements: '/{orgId}/statements/multi',
|
|
490
|
-
postExternalMultiStatements: '/{orgId}/external/statements/multi'
|
|
477
|
+
postExternalMultiStatements: '/{orgId}/external/statements/multi',
|
|
478
|
+
resetUserProductProgress: '/accounts/{accountId}/progress/user/product/reset'
|
|
491
479
|
};
|
|
492
480
|
|
|
493
481
|
exports.ATTEMPTS_API_URLS = {
|
|
@@ -515,9 +503,7 @@ exports.PUB_API_URLS = {
|
|
|
515
503
|
|
|
516
504
|
exports.PUSHX_API_URLS = {
|
|
517
505
|
grantByUserOrgId: '/orgs/{orgId}/grants',
|
|
518
|
-
grantByAccountId: '/accounts/{accountId}/grants'
|
|
519
|
-
grantV2: '/ver/v2/grants',
|
|
520
|
-
getPushedEvents: '/accounts/{accountId}/pushed-events/channels'
|
|
506
|
+
grantByAccountId: '/accounts/{accountId}/grants'
|
|
521
507
|
};
|
|
522
508
|
|
|
523
509
|
exports.INTEGRATIONS_API_URLS = {
|
|
@@ -935,9 +921,7 @@ function validateGenericAPICaller(apiName, method, url, params) {
|
|
|
935
921
|
var ERROR_TYPES = {
|
|
936
922
|
"API_ERROR": "API_ERROR",
|
|
937
923
|
"SDK_ERROR": "SDK_ERROR",
|
|
938
|
-
"CHANNEL_SUBSCRIPTION": "CHANNEL_SUBSCRIPTION"
|
|
939
|
-
"UNEXPECTED_ERROR": "UNEXPECTED_ERROR",
|
|
940
|
-
"POLLING_INITIATION": "POLLING_INITIATION"
|
|
924
|
+
"CHANNEL_SUBSCRIPTION": "CHANNEL_SUBSCRIPTION"
|
|
941
925
|
};
|
|
942
926
|
|
|
943
927
|
var ERROR_CATEGORY = {
|
|
@@ -1028,7 +1012,7 @@ function PUSHXError(category, error) {
|
|
|
1028
1012
|
|
|
1029
1013
|
if (category === ERROR_CATEGORY.PUSHX) {
|
|
1030
1014
|
this.category = ERROR_CATEGORY.PUSHX;
|
|
1031
|
-
this.type =
|
|
1015
|
+
this.type = ERROR_TYPES.CHANNEL_SUBSCRIPTION;
|
|
1032
1016
|
this.status = ERROR_STATUS.ERROR;
|
|
1033
1017
|
this.message = error.message;
|
|
1034
1018
|
this.data = error;
|
|
@@ -4580,8 +4564,6 @@ function auth() {
|
|
|
4580
4564
|
createClassProductAssociation: createClassProductAssociation.bind(this),
|
|
4581
4565
|
removeClassProductAssociation: removeClassProductAssociation.bind(this),
|
|
4582
4566
|
createMultiClassProductAssociations: createMultiClassProductAssociations.bind(this),
|
|
4583
|
-
associateMaterialsWithClass: associateMaterialsWithClass.bind(this),
|
|
4584
|
-
unassociateMaterialsWithClass: unassociateMaterialsWithClass.bind(this),
|
|
4585
4567
|
addItemsToShowcaseOfAClass: addItemsToShowcaseOfAClass.bind(this),
|
|
4586
4568
|
deleteItemsFromShowcaseOfAClass: deleteItemsFromShowcaseOfAClass.bind(this),
|
|
4587
4569
|
|
|
@@ -5900,111 +5882,6 @@ function createClassProductAssociation(options) {
|
|
|
5900
5882
|
return dfd.promise;
|
|
5901
5883
|
}
|
|
5902
5884
|
|
|
5903
|
-
/**
|
|
5904
|
-
* @param {
|
|
5905
|
-
* *classId: 'string',
|
|
5906
|
-
* *body: {
|
|
5907
|
-
* productcodes: ['string'],
|
|
5908
|
-
* bundlecodes: ['string'],
|
|
5909
|
-
* }
|
|
5910
|
-
* } options
|
|
5911
|
-
*/
|
|
5912
|
-
function associateMaterialsWithClass(options) {
|
|
5913
|
-
var self = this;
|
|
5914
|
-
// Initializing promise
|
|
5915
|
-
var dfd = q.defer();
|
|
5916
|
-
// Validations
|
|
5917
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
5918
|
-
if(err) { dfd.reject(err); }
|
|
5919
|
-
else {
|
|
5920
|
-
if(options && options.classId && options.body && (options.body.productcodes
|
|
5921
|
-
|| options.body.bundlecodes)) {
|
|
5922
|
-
// Passed all validations, Contruct API url
|
|
5923
|
-
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
5924
|
-
self.config.AUTH_API_URLS.classMaterialAssociation;
|
|
5925
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
5926
|
-
orgId: self.orgId, classId: options.classId
|
|
5927
|
-
});
|
|
5928
|
-
// Setup request with URL and Params
|
|
5929
|
-
var requestAPI = request.post(url)
|
|
5930
|
-
.set('Content-Type', 'application/json')
|
|
5931
|
-
.set('Accept', 'application/json');
|
|
5932
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
5933
|
-
|
|
5934
|
-
// Setup token in Authorization header
|
|
5935
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
5936
|
-
|
|
5937
|
-
requestAPI.agent(keepaliveAgent).end(function(err, response) {
|
|
5938
|
-
if(err) {
|
|
5939
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
5940
|
-
dfd.reject(err);
|
|
5941
|
-
}
|
|
5942
|
-
else { dfd.resolve(response.body); }
|
|
5943
|
-
});
|
|
5944
|
-
} else {
|
|
5945
|
-
err = {};
|
|
5946
|
-
err.message = err.description = 'classId or productcodes or bundlecodes not found in'
|
|
5947
|
-
+ 'request options.';
|
|
5948
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
5949
|
-
dfd.reject(err);
|
|
5950
|
-
}
|
|
5951
|
-
}
|
|
5952
|
-
return dfd.promise;
|
|
5953
|
-
}
|
|
5954
|
-
|
|
5955
|
-
/**
|
|
5956
|
-
* @param {
|
|
5957
|
-
* *classId: string,
|
|
5958
|
-
* *body: {
|
|
5959
|
-
* 'productcodes' :['string'],
|
|
5960
|
-
* 'bundlecodes' : ['string']
|
|
5961
|
-
* }
|
|
5962
|
-
* } options
|
|
5963
|
-
*/
|
|
5964
|
-
function unassociateMaterialsWithClass(options) {
|
|
5965
|
-
var self = this;
|
|
5966
|
-
// Initializing promise
|
|
5967
|
-
var dfd = q.defer();
|
|
5968
|
-
// Validations
|
|
5969
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
5970
|
-
if(err) { dfd.reject(err); }
|
|
5971
|
-
else {
|
|
5972
|
-
if(options && options.classId && options.body &&
|
|
5973
|
-
(options.body.productcodes || options.body.bundlecodes)) {
|
|
5974
|
-
// Passed all validations, Contruct API url
|
|
5975
|
-
var url= self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.classMaterialAssociation;
|
|
5976
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
5977
|
-
orgId: self.orgId, classId: options.classId
|
|
5978
|
-
});
|
|
5979
|
-
// Setup request with URL and Params
|
|
5980
|
-
var requestAPI = request.delete(url)
|
|
5981
|
-
.set('Content-Type', 'application/json')
|
|
5982
|
-
.set('Accept', 'application/json');
|
|
5983
|
-
|
|
5984
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
5985
|
-
|
|
5986
|
-
// Setup token in Authorization header
|
|
5987
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
5988
|
-
|
|
5989
|
-
requestAPI.agent(keepaliveAgent).end(function(err, response) {
|
|
5990
|
-
if(err) {
|
|
5991
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
5992
|
-
dfd.reject(err);
|
|
5993
|
-
}
|
|
5994
|
-
else { dfd.resolve(response.body); }
|
|
5995
|
-
});
|
|
5996
|
-
} else {
|
|
5997
|
-
err = {};
|
|
5998
|
-
const msg = 'classId or productcodes or bundlecodes not found in request options.';
|
|
5999
|
-
err.message = msg;
|
|
6000
|
-
err.description = msg;
|
|
6001
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
6002
|
-
dfd.reject(err);
|
|
6003
|
-
}
|
|
6004
|
-
}
|
|
6005
|
-
return dfd.promise;
|
|
6006
|
-
}
|
|
6007
|
-
|
|
6008
5885
|
//options = {
|
|
6009
5886
|
// classId: 'class uuid',
|
|
6010
5887
|
// productcode: 'product code'
|
|
@@ -6696,14 +6573,6 @@ function updateClass(options) {
|
|
|
6696
6573
|
"productcode": "string", //mandatory
|
|
6697
6574
|
"title": ""
|
|
6698
6575
|
}
|
|
6699
|
-
],
|
|
6700
|
-
"bundles": [ // optional
|
|
6701
|
-
{
|
|
6702
|
-
"bundlecode": "string", //mandatory
|
|
6703
|
-
},
|
|
6704
|
-
{
|
|
6705
|
-
"bundlecode": "string", //mandatory
|
|
6706
|
-
}
|
|
6707
6576
|
]
|
|
6708
6577
|
}
|
|
6709
6578
|
],
|
|
@@ -6719,7 +6588,6 @@ function updateClass(options) {
|
|
|
6719
6588
|
"students": true,
|
|
6720
6589
|
"teachers": true,
|
|
6721
6590
|
"products": true,
|
|
6722
|
-
"bundles": true,
|
|
6723
6591
|
"groups": true,
|
|
6724
6592
|
"assigned_paths": true,
|
|
6725
6593
|
"tags": true,
|
|
@@ -6727,7 +6595,6 @@ function updateClass(options) {
|
|
|
6727
6595
|
"analytics_score_aggregation_type": true,
|
|
6728
6596
|
"ext_data": true,
|
|
6729
6597
|
"limits": true,
|
|
6730
|
-
"skip_assigned_path_create_notification": true,
|
|
6731
6598
|
"advanced": {
|
|
6732
6599
|
"students": [
|
|
6733
6600
|
{
|
|
@@ -6760,7 +6627,6 @@ function updateClass(options) {
|
|
|
6760
6627
|
}
|
|
6761
6628
|
],
|
|
6762
6629
|
"products": [ { "productcode": "string" } ],
|
|
6763
|
-
"bundles": [ { "bundlecode": "string" } ],
|
|
6764
6630
|
"analyticsharingmodel": "string" // Valid values: ['NOINHERIT_SYNCBACK']
|
|
6765
6631
|
"analytics_score_aggregation_type": "string", // Valid values: ['best', 'first', 'last']
|
|
6766
6632
|
"limits": {los: number, students: number} // Optional field
|
|
@@ -6987,12 +6853,7 @@ function deleteAssignedPath(options) {
|
|
|
6987
6853
|
item_type: 'string', //mandatory, ['dls-internal','external']
|
|
6988
6854
|
dls_product_code: 'string' //mandatory only if item_type is 'dls-internal'
|
|
6989
6855
|
}
|
|
6990
|
-
]
|
|
6991
|
-
"rules": {}, // Optional
|
|
6992
|
-
"context": { // Optional (Needed for system event only)
|
|
6993
|
-
"bundle-code": "string",
|
|
6994
|
-
"space_key": "string"
|
|
6995
|
-
}
|
|
6856
|
+
]
|
|
6996
6857
|
}
|
|
6997
6858
|
}
|
|
6998
6859
|
*/
|
|
@@ -7753,60 +7614,7 @@ function deleteItemsFromShowcaseOfAClass(options){
|
|
|
7753
7614
|
* startdate: 'Epoch(Unix) timestamp in milliseconds',
|
|
7754
7615
|
* enddate: 'Epoch(Unix) timestamp in milliseconds',
|
|
7755
7616
|
* instructor: 'user who clones the class',
|
|
7756
|
-
* clone_setting: {
|
|
7757
|
-
* "students": true,
|
|
7758
|
-
* "teachers": true,
|
|
7759
|
-
* "products": true,
|
|
7760
|
-
* "bundles": true,
|
|
7761
|
-
* "groups": true,
|
|
7762
|
-
* "assigned_paths": true,
|
|
7763
|
-
* "skip_assigned_path_create_notification": true,
|
|
7764
|
-
* "tags": true,
|
|
7765
|
-
* "analyticsharingmodel": true,
|
|
7766
|
-
* "analytics_score_aggregation_type": true,
|
|
7767
|
-
* "ext_data": true,
|
|
7768
|
-
* "limits": true,
|
|
7769
|
-
* "advanced": {
|
|
7770
|
-
* "students": [
|
|
7771
|
-
* {
|
|
7772
|
-
* "ext_user_id": "string"
|
|
7773
|
-
* }
|
|
7774
|
-
* ],
|
|
7775
|
-
* "teachers": [
|
|
7776
|
-
* {
|
|
7777
|
-
* "ext_user_id": "string"
|
|
7778
|
-
* }
|
|
7779
|
-
* ],
|
|
7780
|
-
* "groups": [
|
|
7781
|
-
* {
|
|
7782
|
-
* "groupid": "string"
|
|
7783
|
-
* }
|
|
7784
|
-
* ],
|
|
7785
|
-
* "assigned_paths": [
|
|
7786
|
-
* {
|
|
7787
|
-
* "assigned_path_id": "string",
|
|
7788
|
-
* "startdate": 0,
|
|
7789
|
-
* "duedate": 0
|
|
7790
|
-
* }
|
|
7791
|
-
* ],
|
|
7792
|
-
* "products": [
|
|
7793
|
-
* {
|
|
7794
|
-
* "productcode": "string"
|
|
7795
|
-
* }
|
|
7796
|
-
* ],
|
|
7797
|
-
* "bundles": [
|
|
7798
|
-
* {
|
|
7799
|
-
* "bundlecode": "string"
|
|
7800
|
-
* }
|
|
7801
|
-
* ],
|
|
7802
|
-
* "analyticsharingmodel": "NOINHERIT_SYNCBACK",
|
|
7803
|
-
* "analytics_score_aggregation_type": "best",
|
|
7804
|
-
* "limits": {
|
|
7805
|
-
* "los": 0,
|
|
7806
|
-
* "students": 0
|
|
7807
|
-
* }
|
|
7808
|
-
* }
|
|
7809
|
-
* },
|
|
7617
|
+
* clone_setting: {}, // Optional field
|
|
7810
7618
|
* }
|
|
7811
7619
|
*/
|
|
7812
7620
|
function cloneClass(options) {
|
|
@@ -8910,7 +8718,8 @@ var keepaliveAgent = new Agent({
|
|
|
8910
8718
|
});
|
|
8911
8719
|
|
|
8912
8720
|
//AuthExtn Adaptor Contsructor
|
|
8913
|
-
function authextn() {
|
|
8721
|
+
function authextn(accountId) {
|
|
8722
|
+
this.accountId = accountId;
|
|
8914
8723
|
return {
|
|
8915
8724
|
// Gradeformat related APIs
|
|
8916
8725
|
createGradeformat: createGradeformat.bind(this),
|
|
@@ -8936,7 +8745,9 @@ function authextn() {
|
|
|
8936
8745
|
createOrgProductEntitlement: createOrgProductEntitlement.bind(this),
|
|
8937
8746
|
updateOrgProductEntitlement: updateOrgProductEntitlement.bind(this),
|
|
8938
8747
|
getParticularOrgProductEntitlement: getParticularOrgProductEntitlement.bind(this),
|
|
8939
|
-
getAllOrgProductEntitlements: getAllOrgProductEntitlements.bind(this)
|
|
8748
|
+
getAllOrgProductEntitlements: getAllOrgProductEntitlements.bind(this),
|
|
8749
|
+
setupUser: setupUser.bind(this)
|
|
8750
|
+
|
|
8940
8751
|
};
|
|
8941
8752
|
}
|
|
8942
8753
|
|
|
@@ -9593,17 +9404,14 @@ function getClassesOfAGradeformat(options) {
|
|
|
9593
9404
|
|
|
9594
9405
|
/*
|
|
9595
9406
|
options = {
|
|
9596
|
-
assignedpathid: "string", //
|
|
9407
|
+
assignedpathid: "string", //Mandatory
|
|
9597
9408
|
classid: "string", // Mandatory
|
|
9598
|
-
body :
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
],
|
|
9605
|
-
"context": {} // Optional
|
|
9606
|
-
}
|
|
9409
|
+
body : [ // min:1 , max: 50
|
|
9410
|
+
{
|
|
9411
|
+
extUserId: "string", //Mandatory
|
|
9412
|
+
}.
|
|
9413
|
+
....
|
|
9414
|
+
]
|
|
9607
9415
|
}
|
|
9608
9416
|
*/
|
|
9609
9417
|
function createUserAssignedPathEnrollments(options) {
|
|
@@ -9887,7 +9695,64 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
9887
9695
|
//Initializing promise
|
|
9888
9696
|
var deferred = q.defer();
|
|
9889
9697
|
|
|
9890
|
-
|
|
9698
|
+
//Validations
|
|
9699
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
9700
|
+
if (error) {
|
|
9701
|
+
deferred.reject(error);
|
|
9702
|
+
} else {
|
|
9703
|
+
if (options && options.productcode) {
|
|
9704
|
+
// Passed all validations, Contruct the API URL
|
|
9705
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
9706
|
+
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
9707
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
9708
|
+
|
|
9709
|
+
// Setup request with URL and Query Params
|
|
9710
|
+
var params = { productcode: options.productcode };
|
|
9711
|
+
var requestAPI = request.get(url).query(params);
|
|
9712
|
+
|
|
9713
|
+
// Setup 'traceid' in request header
|
|
9714
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
9715
|
+
|
|
9716
|
+
// Setup 'token' in Authorization header
|
|
9717
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
9718
|
+
|
|
9719
|
+
requestAPI.agent(keepaliveAgent).end(function (error, response) {
|
|
9720
|
+
if (error) {
|
|
9721
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
9722
|
+
deferred.reject(error);
|
|
9723
|
+
} else {
|
|
9724
|
+
deferred.resolve(response.body);
|
|
9725
|
+
}
|
|
9726
|
+
});
|
|
9727
|
+
} else {
|
|
9728
|
+
error = {};
|
|
9729
|
+
error.message = error.description = 'Mandatory field \'productcode\' not found '+
|
|
9730
|
+
'in request options.';
|
|
9731
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
9732
|
+
deferred.reject(error);
|
|
9733
|
+
}
|
|
9734
|
+
}
|
|
9735
|
+
|
|
9736
|
+
return deferred.promise;
|
|
9737
|
+
}
|
|
9738
|
+
|
|
9739
|
+
/**
|
|
9740
|
+
* @param {
|
|
9741
|
+
* status: "string" // ['active', 'revoked']
|
|
9742
|
+
* expired: <boolean>,
|
|
9743
|
+
* cursor: <epoch>
|
|
9744
|
+
* } options
|
|
9745
|
+
*/
|
|
9746
|
+
function getAllOrgProductEntitlements(options) {
|
|
9747
|
+
var self = this;
|
|
9748
|
+
//Initializing promise
|
|
9749
|
+
var deferred = q.defer();
|
|
9750
|
+
|
|
9751
|
+
//Validations
|
|
9752
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
9753
|
+
if (error) {
|
|
9754
|
+
deferred.reject(error);
|
|
9755
|
+
} else {
|
|
9891
9756
|
// Passed all validations, Contruct the API URL
|
|
9892
9757
|
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
9893
9758
|
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
@@ -9895,11 +9760,19 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
9895
9760
|
|
|
9896
9761
|
// Setup request with URL and Query Params
|
|
9897
9762
|
var params = { productcode: options.productcode };
|
|
9763
|
+
|
|
9764
|
+
if (options.status) { params.status = options.status; }
|
|
9765
|
+
if (options.hasOwnProperty('expired')) { params.expired = options.expired; }
|
|
9766
|
+
if (options.cursor) { params.cursor = options.cursor; }
|
|
9767
|
+
|
|
9898
9768
|
var requestAPI = request.get(url).query(params);
|
|
9899
9769
|
|
|
9900
9770
|
// Setup 'traceid' in request header
|
|
9901
9771
|
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
9902
9772
|
|
|
9773
|
+
// Setup 'token' in Authorization header
|
|
9774
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
9775
|
+
|
|
9903
9776
|
requestAPI.agent(keepaliveAgent).end(function (error, response) {
|
|
9904
9777
|
if (error) {
|
|
9905
9778
|
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
@@ -9908,12 +9781,6 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
9908
9781
|
deferred.resolve(response.body);
|
|
9909
9782
|
}
|
|
9910
9783
|
});
|
|
9911
|
-
} else {
|
|
9912
|
-
var error = {};
|
|
9913
|
-
error.message = error.description = 'Mandatory field \'productcode\' not found '+
|
|
9914
|
-
'in request options.';
|
|
9915
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
9916
|
-
deferred.reject(error);
|
|
9917
9784
|
}
|
|
9918
9785
|
|
|
9919
9786
|
return deferred.promise;
|
|
@@ -9921,43 +9788,46 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
9921
9788
|
|
|
9922
9789
|
/**
|
|
9923
9790
|
* @param {
|
|
9924
|
-
|
|
9925
|
-
|
|
9926
|
-
|
|
9927
|
-
|
|
9928
|
-
|
|
9929
|
-
function
|
|
9791
|
+
* ext_user_id: "string", // mandatory
|
|
9792
|
+
* workflow_type: "string", // mandatory
|
|
9793
|
+
* <workflow_type>: {} // mandatory
|
|
9794
|
+
* } options
|
|
9795
|
+
*/
|
|
9796
|
+
function setupUser(options) {
|
|
9930
9797
|
var self = this;
|
|
9931
9798
|
//Initializing promise
|
|
9932
9799
|
var deferred = q.defer();
|
|
9933
9800
|
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
self.config.AUTHEXTN_API_URLS.
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
// Setup request with URL and Query Params
|
|
9940
|
-
var params = { productcode: options.productcode };
|
|
9941
|
-
|
|
9942
|
-
if (options.status) { params.status = options.status; }
|
|
9943
|
-
if (options.hasOwnProperty('expired')) { params.expired = options.expired; }
|
|
9944
|
-
if (options.cursor) { params.cursor = options.cursor; }
|
|
9945
|
-
|
|
9946
|
-
var requestAPI = request.get(url).query(params);
|
|
9801
|
+
if(options && options.ext_user_id && options.workflow_type) {
|
|
9802
|
+
//Passed all validations, Contruct API url
|
|
9803
|
+
var url = self.config.DEFAULT_HOSTS.AUTHEXTN + self.config.AUTHEXTN_API_URLS.setupUser;
|
|
9804
|
+
url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
|
|
9947
9805
|
|
|
9948
|
-
|
|
9949
|
-
|
|
9806
|
+
var requestAPI = request.post(url)
|
|
9807
|
+
.set('Content-Type', 'application/json')
|
|
9808
|
+
.set('Accept', 'application/json')
|
|
9809
|
+
.send(options);
|
|
9950
9810
|
|
|
9951
|
-
|
|
9952
|
-
if (error) {
|
|
9953
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
9954
|
-
deferred.reject(error);
|
|
9955
|
-
} else {
|
|
9956
|
-
deferred.resolve(response.body);
|
|
9957
|
-
}
|
|
9958
|
-
});
|
|
9811
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
9959
9812
|
|
|
9960
|
-
|
|
9813
|
+
requestAPI
|
|
9814
|
+
.agent(keepaliveAgent)
|
|
9815
|
+
.end(function(err, res) {
|
|
9816
|
+
if(err) {
|
|
9817
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
9818
|
+
deferred.reject(err);
|
|
9819
|
+
} else {
|
|
9820
|
+
deferred.resolve(res.body);
|
|
9821
|
+
}
|
|
9822
|
+
});
|
|
9823
|
+
} else {
|
|
9824
|
+
err = {};
|
|
9825
|
+
err.message = err.description = 'Mandatory field \'ext_user_id\' or \'workflow_type\' not found '+
|
|
9826
|
+
'in the request options.';
|
|
9827
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
9828
|
+
deferred.reject(err);
|
|
9829
|
+
}
|
|
9830
|
+
return deferred.promise;
|
|
9961
9831
|
}
|
|
9962
9832
|
|
|
9963
9833
|
},{"../../helpers":3,"agentkeepalive":36,"q":42,"superagent":45}],18:[function(require,module,exports){
|
|
@@ -12157,10 +12027,9 @@ function getMicroEntitlementsForAUser(options) {
|
|
|
12157
12027
|
|
|
12158
12028
|
}
|
|
12159
12029
|
|
|
12160
|
-
|
|
12161
|
-
stage: "
|
|
12162
|
-
|
|
12163
|
-
} */
|
|
12030
|
+
// options= {
|
|
12031
|
+
// stage: "", //stage number or version
|
|
12032
|
+
// }
|
|
12164
12033
|
function getAllBundles(options) {
|
|
12165
12034
|
var self = this;
|
|
12166
12035
|
var dfd = q.defer();
|
|
@@ -12171,14 +12040,7 @@ function getAllBundles(options) {
|
|
|
12171
12040
|
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
12172
12041
|
//Contruct parameters
|
|
12173
12042
|
var params = {};
|
|
12174
|
-
if(options) {
|
|
12175
|
-
if(options.stage){
|
|
12176
|
-
params.stage = options.stage;
|
|
12177
|
-
}
|
|
12178
|
-
if(options.target_role){
|
|
12179
|
-
params.target_role = options.target_role;
|
|
12180
|
-
}
|
|
12181
|
-
}
|
|
12043
|
+
if(options && options.stage) { params.stage = options.stage; }
|
|
12182
12044
|
|
|
12183
12045
|
//Setup request with URL and Post data
|
|
12184
12046
|
var requestAPI = request.get(url).query(params);
|
|
@@ -12653,10 +12515,10 @@ function updateBundle(options) {
|
|
|
12653
12515
|
return dfd.promise;
|
|
12654
12516
|
}
|
|
12655
12517
|
|
|
12656
|
-
|
|
12657
|
-
stage: "
|
|
12658
|
-
|
|
12659
|
-
|
|
12518
|
+
// options= {
|
|
12519
|
+
// stage: "", //stage number or version
|
|
12520
|
+
// }
|
|
12521
|
+
|
|
12660
12522
|
function getAllBundles(options) {
|
|
12661
12523
|
var self = this;
|
|
12662
12524
|
//Initializing promise
|
|
@@ -12668,14 +12530,7 @@ function getAllBundles(options) {
|
|
|
12668
12530
|
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, });
|
|
12669
12531
|
//Contruct parameters
|
|
12670
12532
|
var params = {};
|
|
12671
|
-
if(options) {
|
|
12672
|
-
if(options.stage){
|
|
12673
|
-
params.stage = options.stage;
|
|
12674
|
-
}
|
|
12675
|
-
if(options.target_role){
|
|
12676
|
-
params.target_role = options.target_role;
|
|
12677
|
-
}
|
|
12678
|
-
}
|
|
12533
|
+
if(options && options.stage) { params.stage = options.stage; }
|
|
12679
12534
|
|
|
12680
12535
|
//Setup request with URL and Post data
|
|
12681
12536
|
var requestAPI = request.get(url).query(params);
|
|
@@ -12951,7 +12806,6 @@ function getAllProductFamilies(options) {
|
|
|
12951
12806
|
|
|
12952
12807
|
var q = require('q');
|
|
12953
12808
|
var request = require('superagent');
|
|
12954
|
-
var Agent = require('agentkeepalive');
|
|
12955
12809
|
|
|
12956
12810
|
var helpers = require('../../helpers');
|
|
12957
12811
|
var pubnubClientWrapper = require('./pubnubClientWrapper');
|
|
@@ -12962,25 +12816,18 @@ var DLSError = helpers.errors.DLSError;
|
|
|
12962
12816
|
**********************************/
|
|
12963
12817
|
module.exports = pushX;
|
|
12964
12818
|
|
|
12965
|
-
var keepaliveAgent = new Agent({
|
|
12966
|
-
timeout: 60000,
|
|
12967
|
-
freeSocketTimeout: 30000
|
|
12968
|
-
});
|
|
12969
|
-
|
|
12970
12819
|
/*********************************
|
|
12971
12820
|
* Public Function definitions
|
|
12972
12821
|
**********************************/
|
|
12973
12822
|
function pushX() {
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
"getPushedEvents": getPushedEvents.bind(this)
|
|
12983
|
-
};
|
|
12823
|
+
var _pubnubClientWrapper = pubnubClientWrapper();
|
|
12824
|
+
return {
|
|
12825
|
+
"connect": _connect.bind(this, _pubnubClientWrapper),
|
|
12826
|
+
"cleanup": _cleanup.bind(this, _pubnubClientWrapper),
|
|
12827
|
+
"grantByUserOrgId": grantByUserOrgId.bind(this),
|
|
12828
|
+
"grantByAccountId": grantByAccountId.bind(this),
|
|
12829
|
+
"grantByAccountIdOnExtUserId": grantByAccountIdOnExtUserId.bind(this)
|
|
12830
|
+
};
|
|
12984
12831
|
}
|
|
12985
12832
|
|
|
12986
12833
|
/*********************************
|
|
@@ -12988,195 +12835,149 @@ function pushX() {
|
|
|
12988
12835
|
**********************************/
|
|
12989
12836
|
|
|
12990
12837
|
function _connect(pubnubCW, options) {
|
|
12991
|
-
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
|
|
12997
|
-
|
|
12998
|
-
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
|
|
13002
|
-
|
|
13003
|
-
|
|
13004
|
-
|
|
13005
|
-
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
}
|
|
13010
|
-
});
|
|
12838
|
+
var bpubnubV7 = true; // If pubnub v7 or higher in package.json, set it true
|
|
12839
|
+
if (bpubnubV7 && !options.userid) {
|
|
12840
|
+
var err = {};
|
|
12841
|
+
err.message = err.description = 'Mandatory parameter userid not found in request options.';
|
|
12842
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.PUSHX_ERROR, err);
|
|
12843
|
+
throw err;
|
|
12844
|
+
}
|
|
12845
|
+
|
|
12846
|
+
// Adding SSL flag
|
|
12847
|
+
return pubnubCW.setup({
|
|
12848
|
+
'userid': options.userid,
|
|
12849
|
+
'pubnub': {
|
|
12850
|
+
'publishKey': options.publishKey,
|
|
12851
|
+
'subscribeKey': options.subscribeKey,
|
|
12852
|
+
'authKey': options.authKey,
|
|
12853
|
+
'ssl': true
|
|
12854
|
+
}
|
|
12855
|
+
});
|
|
13011
12856
|
}
|
|
13012
12857
|
|
|
13013
12858
|
function _cleanup(pubnubCW) { pubnubCW.cleanup(); }
|
|
13014
12859
|
|
|
13015
|
-
/*options = {
|
|
12860
|
+
/*options = {
|
|
12861
|
+
authKey: <authKey>
|
|
12862
|
+
}*/
|
|
13016
12863
|
function grantByUserOrgId(options) {
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
12864
|
+
var self = this;
|
|
12865
|
+
var dfd = q.defer(); // Initializing promise
|
|
12866
|
+
// Validations
|
|
12867
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
12868
|
+
if(err) { dfd.reject(err); }
|
|
12869
|
+
else {
|
|
12870
|
+
// Passed all validations, Construct API url
|
|
12871
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByUserOrgId;
|
|
12872
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
12873
|
+
// Setup request with URL and Params
|
|
12874
|
+
var requestAPI = request.post(url)
|
|
12875
|
+
.set('Content-Type', 'application/json')
|
|
12876
|
+
.set('Accept', 'application/json');
|
|
12877
|
+
|
|
12878
|
+
var body = {};
|
|
12879
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
12880
|
+
|
|
12881
|
+
requestAPI.send(body);
|
|
12882
|
+
|
|
12883
|
+
//Setup token in Authorization header
|
|
12884
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
12885
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
12886
|
+
|
|
12887
|
+
// Call Change Password Api
|
|
12888
|
+
requestAPI.end(function(err, response) {
|
|
12889
|
+
if(err) {
|
|
12890
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
12891
|
+
dfd.reject(err);
|
|
12892
|
+
}
|
|
12893
|
+
else { dfd.resolve(response.body); }
|
|
12894
|
+
});
|
|
12895
|
+
}
|
|
12896
|
+
return dfd.promise;
|
|
13035
12897
|
}
|
|
13036
12898
|
|
|
13037
12899
|
/*options = {
|
|
13038
12900
|
accountId: <accountid>,
|
|
13039
|
-
refId: <extRefId
|
|
12901
|
+
refId: <extRefId>,
|
|
12902
|
+
authKey: <authKey>
|
|
13040
12903
|
}*/
|
|
13041
12904
|
function grantByAccountId(options) {
|
|
13042
|
-
var err ={};
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
|
|
13046
|
-
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
13064
|
-
|
|
12905
|
+
var self = this, err ={};
|
|
12906
|
+
var dfd = q.defer(); // Initializing promise
|
|
12907
|
+
|
|
12908
|
+
if(options.accountId && options.refId) {
|
|
12909
|
+
// Passed all validations, Construct API url
|
|
12910
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByAccountId;
|
|
12911
|
+
url = helpers.api.constructAPIUrl(url, { accountId: options.accountId });
|
|
12912
|
+
// Setup request with URL and Params
|
|
12913
|
+
var requestAPI = request.post(url)
|
|
12914
|
+
.set('Content-Type', 'application/json')
|
|
12915
|
+
.set('Accept', 'application/json');
|
|
12916
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
12917
|
+
|
|
12918
|
+
var body = { refId: options.refId };
|
|
12919
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
12920
|
+
|
|
12921
|
+
requestAPI.send(body);
|
|
12922
|
+
requestAPI.end(function(err, response) {
|
|
12923
|
+
if(err) {
|
|
12924
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
12925
|
+
dfd.reject(err);
|
|
12926
|
+
}
|
|
12927
|
+
else { dfd.resolve(response.body); }
|
|
12928
|
+
});
|
|
12929
|
+
}
|
|
12930
|
+
else {
|
|
12931
|
+
err.message = err.description = "Required parameter ['accountId', 'refId'] " +
|
|
12932
|
+
"not found in request options";
|
|
12933
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12934
|
+
dfd.reject(err);
|
|
12935
|
+
}
|
|
12936
|
+
return dfd.promise;
|
|
13065
12937
|
}
|
|
13066
12938
|
|
|
13067
12939
|
/*options = {
|
|
13068
12940
|
accountId: <accountid>,
|
|
13069
12941
|
extUserId: <extUserId>, //mandatory
|
|
12942
|
+
authKey: <authKey>
|
|
13070
12943
|
}*/
|
|
13071
12944
|
function grantByAccountIdOnExtUserId(options) {
|
|
13072
|
-
var err ={};
|
|
13073
|
-
|
|
13074
|
-
|
|
13075
|
-
if(options.accountId && options.extUserId) {
|
|
13076
|
-
var channel = "a-" + options.accountId + "$u-" + options.extUserId;
|
|
13077
|
-
var exactMatch = [channel];
|
|
13078
|
-
options.channels = {};
|
|
13079
|
-
options.channels.exactMatch = exactMatch;
|
|
13080
|
-
grantV2.call(this, options)
|
|
13081
|
-
.then(function (res) {
|
|
13082
|
-
dfd.resolve(res);
|
|
13083
|
-
})
|
|
13084
|
-
.catch(function(err) {
|
|
13085
|
-
dfd.reject(err);
|
|
13086
|
-
});
|
|
13087
|
-
}
|
|
13088
|
-
else {
|
|
13089
|
-
err.message = err.description = "Required parameter ['accountId', 'extUserId'] " +
|
|
13090
|
-
"not found in request options";
|
|
13091
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
13092
|
-
dfd.reject(err);
|
|
13093
|
-
}
|
|
13094
|
-
return dfd.promise;
|
|
13095
|
-
}
|
|
12945
|
+
var self = this, err ={};
|
|
12946
|
+
var dfd = q.defer(); // Initializing promise
|
|
13096
12947
|
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
if(!options.channels) {
|
|
13107
|
-
err.message = err.description = "channels not given in input body.";
|
|
13108
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
13109
|
-
dfd.reject(err);
|
|
13110
|
-
return dfd.promise;
|
|
13111
|
-
}
|
|
13112
|
-
body.channels = options.channels;
|
|
13113
|
-
// Passed all validations, Construct API url
|
|
13114
|
-
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantV2;
|
|
13115
|
-
// Setup request with URL and Params
|
|
13116
|
-
var requestAPI = request.post(url)
|
|
13117
|
-
.set('Content-Type', 'application/json')
|
|
13118
|
-
.set('Accept', 'application/json');
|
|
13119
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
12948
|
+
if(options.accountId && options.extUserId) {
|
|
12949
|
+
// Passed all validations, Construct API url
|
|
12950
|
+
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantByAccountId;
|
|
12951
|
+
url = helpers.api.constructAPIUrl(url, { accountId: options.accountId });
|
|
12952
|
+
// Setup request with URL and Params
|
|
12953
|
+
var requestAPI = request.post(url)
|
|
12954
|
+
.set('Content-Type', 'application/json')
|
|
12955
|
+
.set('Accept', 'application/json');
|
|
12956
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
13120
12957
|
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
|
|
12958
|
+
var body = { extUserId: options.extUserId };
|
|
12959
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
12960
|
+
|
|
12961
|
+
requestAPI.send(body);
|
|
12962
|
+
requestAPI.end(function(err, response) {
|
|
12963
|
+
if(err) {
|
|
12964
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
12965
|
+
dfd.reject(err);
|
|
12966
|
+
}
|
|
12967
|
+
else { dfd.resolve(response.body); }
|
|
12968
|
+
});
|
|
13126
12969
|
}
|
|
13127
|
-
else {
|
|
13128
|
-
|
|
13129
|
-
|
|
12970
|
+
else {
|
|
12971
|
+
err.message = err.description = "Required parameter ['accountId', 'extUserId'] " +
|
|
12972
|
+
"not found in request options";
|
|
12973
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
12974
|
+
dfd.reject(err);
|
|
12975
|
+
}
|
|
12976
|
+
return dfd.promise;
|
|
13130
12977
|
}
|
|
13131
12978
|
|
|
13132
|
-
/**
|
|
13133
|
-
* @param {
|
|
13134
|
-
* *accountid: "string",
|
|
13135
|
-
* *channelName: "string",
|
|
13136
|
-
* *starttime: number,
|
|
13137
|
-
* *endtime: number
|
|
13138
|
-
* } options
|
|
13139
|
-
*/
|
|
13140
|
-
function getPushedEvents(options) {
|
|
13141
|
-
var self = this;
|
|
13142
|
-
var dfd = q.defer(); // Initializing promise
|
|
13143
|
-
var accountid = options.accountid,
|
|
13144
|
-
channelname = options.channelname,
|
|
13145
|
-
starttime = options.starttime,
|
|
13146
|
-
endtime = options.endtime;
|
|
13147
|
-
|
|
13148
|
-
if (accountid && channelname && starttime && endtime) {
|
|
13149
|
-
// Passed all validations, Construct API url
|
|
13150
|
-
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.getPushedEvents;
|
|
13151
|
-
url = helpers.api.constructAPIUrl(url, { accountId: accountid });
|
|
13152
|
-
|
|
13153
|
-
// Setup request with URL and Params
|
|
13154
|
-
var params = {channelname: channelname, starttime: starttime, endtime: endtime};
|
|
13155
|
-
var requestAPI = request.get(url).query(params);
|
|
13156
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
13157
|
-
|
|
13158
|
-
requestAPI
|
|
13159
|
-
.agent(keepaliveAgent)
|
|
13160
|
-
.end(function(error, response) {
|
|
13161
|
-
if (error) {
|
|
13162
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
13163
|
-
dfd.reject(error);
|
|
13164
|
-
} else {
|
|
13165
|
-
dfd.resolve(response.body);
|
|
13166
|
-
}
|
|
13167
|
-
});
|
|
13168
|
-
}
|
|
13169
|
-
else {
|
|
13170
|
-
var err = {};
|
|
13171
|
-
err.message = err.description = 'Mandatory parameters [accountId, channelname,' +
|
|
13172
|
-
' starttime, endtime] not found in request options';
|
|
13173
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
13174
|
-
dfd.reject(err);
|
|
13175
|
-
}
|
|
13176
|
-
return dfd.promise;
|
|
13177
|
-
}
|
|
13178
12979
|
|
|
13179
|
-
},{"../../helpers":3,"./pubnubClientWrapper":26,"
|
|
12980
|
+
},{"../../helpers":3,"./pubnubClientWrapper":26,"q":42,"superagent":45}],26:[function(require,module,exports){
|
|
13180
12981
|
var pubNub = require("pubnub");
|
|
13181
12982
|
var EventEmitter = require("events").EventEmitter;
|
|
13182
12983
|
var helpers = require('../../helpers');
|
|
@@ -13254,7 +13055,7 @@ module.exports = function () {
|
|
|
13254
13055
|
_eventEmitter.emit(subscribedChannel, message);
|
|
13255
13056
|
};
|
|
13256
13057
|
|
|
13257
|
-
var _translatePubnubStatus = function(status
|
|
13058
|
+
var _translatePubnubStatus = function(status) {
|
|
13258
13059
|
var channels = [], error, successObj;
|
|
13259
13060
|
switch (status.category) {
|
|
13260
13061
|
case "PNConnectedCategory":
|
|
@@ -13283,10 +13084,8 @@ module.exports = function () {
|
|
|
13283
13084
|
break;
|
|
13284
13085
|
case "PNAccessDeniedCategory":
|
|
13285
13086
|
if(status.operation === "PNSubscribeOperation") {
|
|
13286
|
-
var errorText = status.errorData.response && status.errorData.response.text;
|
|
13287
|
-
var errorJSON = errorText ? JSON.parse(errorText) : undefined;
|
|
13288
13087
|
var errorData = {
|
|
13289
|
-
payload:
|
|
13088
|
+
payload: JSON.parse(status.errorData.response.text).payload,
|
|
13290
13089
|
message: 'Forbidden: Subscription failed.',
|
|
13291
13090
|
errorDetails: {
|
|
13292
13091
|
operation: status.operation,
|
|
@@ -13315,46 +13114,6 @@ module.exports = function () {
|
|
|
13315
13114
|
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
13316
13115
|
_eventEmitter.emit('pushx_status', error);
|
|
13317
13116
|
break;
|
|
13318
|
-
case "PNNetworkIssuesCategory":
|
|
13319
|
-
if(status.operation === 'PNSubscribeOperation') {
|
|
13320
|
-
if(!options.accountId) {
|
|
13321
|
-
error = {
|
|
13322
|
-
message: "Missing mandatory parameters to initiate polling operation - accountId",
|
|
13323
|
-
status: status.statusCode,
|
|
13324
|
-
type: helpers.errors.ERROR_TYPES.POLLING_INITIATION,
|
|
13325
|
-
};
|
|
13326
|
-
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
13327
|
-
_eventEmitter.emit('pushx_status', error);
|
|
13328
|
-
break;
|
|
13329
|
-
}
|
|
13330
|
-
else {
|
|
13331
|
-
/**
|
|
13332
|
-
* Handle network issue category status for 'subscription' opreration
|
|
13333
|
-
* Start the events polling here.
|
|
13334
|
-
*
|
|
13335
|
-
* The wrapper supports multiple channels, but the APP currently uses a single channel only.
|
|
13336
|
-
* Polling will also limited to a single channel.
|
|
13337
|
-
*/
|
|
13338
|
-
}
|
|
13339
|
-
}
|
|
13340
|
-
else {
|
|
13341
|
-
// Handle network issue category status for other operations like 'unsubscription'
|
|
13342
|
-
}
|
|
13343
|
-
break;
|
|
13344
|
-
case "PNReconnectedCategory":
|
|
13345
|
-
// Handle reconnected category status.
|
|
13346
|
-
break;
|
|
13347
|
-
default:
|
|
13348
|
-
// Emit error for other status-category received from pubnub
|
|
13349
|
-
error = {
|
|
13350
|
-
message: "PushX Error",
|
|
13351
|
-
status: status.statusCode,
|
|
13352
|
-
type: helpers.errors.ERROR_TYPES.UNEXPECTED_ERROR,
|
|
13353
|
-
pushXError: status
|
|
13354
|
-
};
|
|
13355
|
-
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
13356
|
-
_eventEmitter.emit('pushx_status', error);
|
|
13357
|
-
break;
|
|
13358
13117
|
}
|
|
13359
13118
|
};
|
|
13360
13119
|
|
|
@@ -13388,12 +13147,9 @@ module.exports = function () {
|
|
|
13388
13147
|
var __setup = function (userOptions) {
|
|
13389
13148
|
var pubnubConfig = userOptions.pubnub;
|
|
13390
13149
|
pubnubConfig.uuid = userOptions.userid;
|
|
13391
|
-
var accountId = userOptions.accountid;
|
|
13392
|
-
var token = userOptions.token;
|
|
13393
13150
|
|
|
13394
13151
|
if (!_pubnubClient && pubnubConfig) {
|
|
13395
13152
|
_pubnubClient = new pubNub(pubnubConfig); //Connect with PubNub SDK
|
|
13396
|
-
_pubnubClient.setToken(token);
|
|
13397
13153
|
processSetup();
|
|
13398
13154
|
} else {
|
|
13399
13155
|
return new Error('Already Initialized');
|
|
@@ -13409,8 +13165,7 @@ module.exports = function () {
|
|
|
13409
13165
|
_translatePubnubMessage(data);
|
|
13410
13166
|
},
|
|
13411
13167
|
"status": function (status) {
|
|
13412
|
-
|
|
13413
|
-
_translatePubnubStatus(status, statusOptions);
|
|
13168
|
+
_translatePubnubStatus(status);
|
|
13414
13169
|
}
|
|
13415
13170
|
});
|
|
13416
13171
|
}
|
|
@@ -14433,7 +14188,6 @@ function provisionBulkSpaces(options) {
|
|
|
14433
14188
|
* *startdate: <epoch>,
|
|
14434
14189
|
* *enddate: <epoch>,
|
|
14435
14190
|
* description: 'string',
|
|
14436
|
-
* ext_class_title : 'string',
|
|
14437
14191
|
* ext_data: {},
|
|
14438
14192
|
* limits: {
|
|
14439
14193
|
* *los: 0,
|
|
@@ -14447,7 +14201,6 @@ function provisionBulkSpaces(options) {
|
|
|
14447
14201
|
* clone_settings: {
|
|
14448
14202
|
* *src_ext_classid: 'string',
|
|
14449
14203
|
* products: boolean,
|
|
14450
|
-
* bundles: boolean,
|
|
14451
14204
|
* assigned_paths: boolean,
|
|
14452
14205
|
* ext_assigned_path_id_rule: 'string' //enum: ['SRC_ID']
|
|
14453
14206
|
* advanced: {
|
|
@@ -14461,9 +14214,6 @@ function provisionBulkSpaces(options) {
|
|
|
14461
14214
|
* ],
|
|
14462
14215
|
* products: [
|
|
14463
14216
|
* { *productcode: 'string' },
|
|
14464
|
-
* ],
|
|
14465
|
-
* bundles: [
|
|
14466
|
-
* { *bundlecode: 'string' },
|
|
14467
14217
|
* ]
|
|
14468
14218
|
* }
|
|
14469
14219
|
* }
|
|
@@ -15142,8 +14892,7 @@ var keepaliveAgent = new Agent({
|
|
|
15142
14892
|
function spacesextn(accountId) {
|
|
15143
14893
|
this.accountId = accountId;
|
|
15144
14894
|
return {
|
|
15145
|
-
entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this)
|
|
15146
|
-
setupUser: setupUser.bind(this)
|
|
14895
|
+
entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this)
|
|
15147
14896
|
};
|
|
15148
14897
|
}
|
|
15149
14898
|
|
|
@@ -15204,49 +14953,6 @@ function entitleBulkUsersToProducts(options) {
|
|
|
15204
14953
|
return dfd.promise;
|
|
15205
14954
|
}
|
|
15206
14955
|
|
|
15207
|
-
/**
|
|
15208
|
-
* @param {
|
|
15209
|
-
* *ext_user_id: "string",
|
|
15210
|
-
* *workflow_type: "string",
|
|
15211
|
-
* *<workflow_type>: {}
|
|
15212
|
-
* } options
|
|
15213
|
-
*/
|
|
15214
|
-
function setupUser(options) {
|
|
15215
|
-
var self = this;
|
|
15216
|
-
//Initializing promise
|
|
15217
|
-
var deferred = q.defer();
|
|
15218
|
-
|
|
15219
|
-
if (options && options.ext_user_id && options.workflow_type) {
|
|
15220
|
-
//Passed all validations, Contruct API url
|
|
15221
|
-
var url = self.config.DEFAULT_HOSTS.AUTHEXTN + self.config.AUTHEXTN_API_URLS.setupUser;
|
|
15222
|
-
url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
|
|
15223
|
-
|
|
15224
|
-
var requestAPI = request.post(url)
|
|
15225
|
-
.set('Content-Type', 'application/json')
|
|
15226
|
-
.set('Accept', 'application/json')
|
|
15227
|
-
.send(options);
|
|
15228
|
-
|
|
15229
|
-
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
15230
|
-
|
|
15231
|
-
requestAPI
|
|
15232
|
-
.agent(keepaliveAgent)
|
|
15233
|
-
.end(function(err, res) {
|
|
15234
|
-
if (err) {
|
|
15235
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
15236
|
-
deferred.reject(err);
|
|
15237
|
-
} else {
|
|
15238
|
-
deferred.resolve(res.body);
|
|
15239
|
-
}
|
|
15240
|
-
});
|
|
15241
|
-
} else {
|
|
15242
|
-
var err = {};
|
|
15243
|
-
err.message = err.description = 'Mandatory field \'ext_user_id\' or \'workflow_type\' not found '+
|
|
15244
|
-
'in the request options.';
|
|
15245
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
15246
|
-
deferred.reject(err);
|
|
15247
|
-
}
|
|
15248
|
-
return deferred.promise;
|
|
15249
|
-
}
|
|
15250
14956
|
|
|
15251
14957
|
},{"../../helpers":3,"agentkeepalive":36,"q":42,"superagent":45}],30:[function(require,module,exports){
|
|
15252
14958
|
/*************************************************************************
|
|
@@ -15924,7 +15630,6 @@ function workflows(accountId) {
|
|
|
15924
15630
|
"address": {
|
|
15925
15631
|
"city": "string",
|
|
15926
15632
|
"country": "string",
|
|
15927
|
-
"line1": "string",
|
|
15928
15633
|
"street1": "string",
|
|
15929
15634
|
"street2": "string",
|
|
15930
15635
|
"street3": "string",
|
|
@@ -16280,7 +15985,6 @@ function completeAWorkflow(options) {
|
|
|
16280
15985
|
"address": {
|
|
16281
15986
|
"city": "string",
|
|
16282
15987
|
"country": "string",
|
|
16283
|
-
"line1": "string",
|
|
16284
15988
|
"street1": "string",
|
|
16285
15989
|
"street2": "string",
|
|
16286
15990
|
"street3": "string",
|
|
@@ -16290,7 +15994,7 @@ function completeAWorkflow(options) {
|
|
|
16290
15994
|
"display_name": "string",
|
|
16291
15995
|
"school_key": "string"
|
|
16292
15996
|
}
|
|
16293
|
-
}
|
|
15997
|
+
}
|
|
16294
15998
|
}
|
|
16295
15999
|
*/
|
|
16296
16000
|
function updateWorkflowRequest(options) {
|
|
@@ -16329,8 +16033,7 @@ function updateWorkflowRequest(options) {
|
|
|
16329
16033
|
dfd.reject(err);
|
|
16330
16034
|
}
|
|
16331
16035
|
return dfd.promise;
|
|
16332
|
-
}
|
|
16333
|
-
|
|
16036
|
+
}
|
|
16334
16037
|
},{"./../../helpers":3,"q":42,"superagent":45}],33:[function(require,module,exports){
|
|
16335
16038
|
/*************************************************************************
|
|
16336
16039
|
*
|
|
@@ -16376,7 +16079,8 @@ function xapi(accountId) {
|
|
|
16376
16079
|
this.accountId = accountId;
|
|
16377
16080
|
return {
|
|
16378
16081
|
postStatement: postStatements.bind(this),
|
|
16379
|
-
postExternalStatements: postExternalStatements.bind(this)
|
|
16082
|
+
postExternalStatements: postExternalStatements.bind(this),
|
|
16083
|
+
resetUserProductProgress: resetUserProductProgress.bind(this)
|
|
16380
16084
|
};
|
|
16381
16085
|
}
|
|
16382
16086
|
|
|
@@ -16565,6 +16269,47 @@ function postExternalStatements(options) {
|
|
|
16565
16269
|
});
|
|
16566
16270
|
return dfd.promise;
|
|
16567
16271
|
}
|
|
16272
|
+
|
|
16273
|
+
/*options = {
|
|
16274
|
+
userid: 'string',
|
|
16275
|
+
productcode: 'string',
|
|
16276
|
+
actorid: 'string'
|
|
16277
|
+
}*/
|
|
16278
|
+
function resetUserProductProgress(options) {
|
|
16279
|
+
var self = this;
|
|
16280
|
+
// Initializing promise
|
|
16281
|
+
var dfd = q.defer();
|
|
16282
|
+
var err = {};
|
|
16283
|
+
if(options && options.userid && options.productcode && options.actorid) {
|
|
16284
|
+
|
|
16285
|
+
// Passed all validations, Contruct API url
|
|
16286
|
+
var url = self.config.DEFAULT_HOSTS.XAPI + self.config.XAPI_API_URLS.resetUserProductProgress;
|
|
16287
|
+
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
16288
|
+
|
|
16289
|
+
// Setup request with URL and Params
|
|
16290
|
+
var requestAPI = request.delete(url)
|
|
16291
|
+
.set('Content-Type', 'application/json')
|
|
16292
|
+
.set('Accept', 'application/json')
|
|
16293
|
+
.send(options);
|
|
16294
|
+
|
|
16295
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
16296
|
+
|
|
16297
|
+
requestAPI.end(function(error, response) {
|
|
16298
|
+
if(error) {
|
|
16299
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
16300
|
+
dfd.reject(err);
|
|
16301
|
+
}
|
|
16302
|
+
else { dfd.resolve(response.body); }
|
|
16303
|
+
});
|
|
16304
|
+
}
|
|
16305
|
+
else {
|
|
16306
|
+
err.message = err.description = 'userid, productcode or actorid not found in request options.';
|
|
16307
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
16308
|
+
dfd.reject(err);
|
|
16309
|
+
}
|
|
16310
|
+
|
|
16311
|
+
return dfd.promise;
|
|
16312
|
+
}
|
|
16568
16313
|
|
|
16569
16314
|
},{"../../helpers":3,"q":42,"superagent":45}],34:[function(require,module,exports){
|
|
16570
16315
|
/*************************************************************************
|