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/dist/comprodls-sdk.js
CHANGED
|
@@ -292,7 +292,6 @@ exports.AUTH_API_URLS = {
|
|
|
292
292
|
getParticularShadowClassAPI: '/org/{orgId}/shadow/classes/{extClassId}',
|
|
293
293
|
classProductAssociation: '/org/{orgId}/classes/{classId}/associate-product/{productcode}',
|
|
294
294
|
multiClassProductAssociations: '/org/{orgId}/classes/{classId}/associate-product/multi',
|
|
295
|
-
classMaterialAssociation: '/org/{orgId}/classes/{classId}/associate-materials/multi',
|
|
296
295
|
enrollUsertoClass: '/org/{orgId}/classes/{classId}/enroll-user/{userId}',
|
|
297
296
|
enrollSelftoClass: '/org/{orgId}/classes/{classId}/enroll-self',
|
|
298
297
|
enrollMultiUserstoClass: '/org/{orgId}/classes/{classId}/enroll-user/multi',
|
|
@@ -475,7 +474,8 @@ exports.PRODUCT_API_URLS = {
|
|
|
475
474
|
|
|
476
475
|
exports.XAPI_API_URLS = {
|
|
477
476
|
postMultiStatements: '/{orgId}/statements/multi',
|
|
478
|
-
postExternalMultiStatements: '/{orgId}/external/statements/multi'
|
|
477
|
+
postExternalMultiStatements: '/{orgId}/external/statements/multi',
|
|
478
|
+
resetUserProductProgress: '/accounts/{accountId}/progress/user/product/reset'
|
|
479
479
|
};
|
|
480
480
|
|
|
481
481
|
exports.ATTEMPTS_API_URLS = {
|
|
@@ -503,9 +503,7 @@ exports.PUB_API_URLS = {
|
|
|
503
503
|
|
|
504
504
|
exports.PUSHX_API_URLS = {
|
|
505
505
|
grantByUserOrgId: '/orgs/{orgId}/grants',
|
|
506
|
-
grantByAccountId: '/accounts/{accountId}/grants'
|
|
507
|
-
grantV2: '/ver/v2/grants',
|
|
508
|
-
getPushedEvents: '/accounts/{accountId}/pushed-events/channels'
|
|
506
|
+
grantByAccountId: '/accounts/{accountId}/grants'
|
|
509
507
|
};
|
|
510
508
|
|
|
511
509
|
exports.INTEGRATIONS_API_URLS = {
|
|
@@ -1014,7 +1012,7 @@ function PUSHXError(category, error) {
|
|
|
1014
1012
|
|
|
1015
1013
|
if (category === ERROR_CATEGORY.PUSHX) {
|
|
1016
1014
|
this.category = ERROR_CATEGORY.PUSHX;
|
|
1017
|
-
this.type =
|
|
1015
|
+
this.type = ERROR_TYPES.CHANNEL_SUBSCRIPTION;
|
|
1018
1016
|
this.status = ERROR_STATUS.ERROR;
|
|
1019
1017
|
this.message = error.message;
|
|
1020
1018
|
this.data = error;
|
|
@@ -4566,8 +4564,6 @@ function auth() {
|
|
|
4566
4564
|
createClassProductAssociation: createClassProductAssociation.bind(this),
|
|
4567
4565
|
removeClassProductAssociation: removeClassProductAssociation.bind(this),
|
|
4568
4566
|
createMultiClassProductAssociations: createMultiClassProductAssociations.bind(this),
|
|
4569
|
-
associateMaterialsWithClass: associateMaterialsWithClass.bind(this),
|
|
4570
|
-
unassociateMaterialsWithClass: unassociateMaterialsWithClass.bind(this),
|
|
4571
4567
|
addItemsToShowcaseOfAClass: addItemsToShowcaseOfAClass.bind(this),
|
|
4572
4568
|
deleteItemsFromShowcaseOfAClass: deleteItemsFromShowcaseOfAClass.bind(this),
|
|
4573
4569
|
|
|
@@ -5886,111 +5882,6 @@ function createClassProductAssociation(options) {
|
|
|
5886
5882
|
return dfd.promise;
|
|
5887
5883
|
}
|
|
5888
5884
|
|
|
5889
|
-
/**
|
|
5890
|
-
* @param {
|
|
5891
|
-
* *classId: 'string',
|
|
5892
|
-
* *body: {
|
|
5893
|
-
* productcodes: ['string'],
|
|
5894
|
-
* bundlecodes: ['string'],
|
|
5895
|
-
* }
|
|
5896
|
-
* } options
|
|
5897
|
-
*/
|
|
5898
|
-
function associateMaterialsWithClass(options) {
|
|
5899
|
-
var self = this;
|
|
5900
|
-
// Initializing promise
|
|
5901
|
-
var dfd = q.defer();
|
|
5902
|
-
// Validations
|
|
5903
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
5904
|
-
if(err) { dfd.reject(err); }
|
|
5905
|
-
else {
|
|
5906
|
-
if(options && options.classId && options.body && (options.body.productcodes
|
|
5907
|
-
|| options.body.bundlecodes)) {
|
|
5908
|
-
// Passed all validations, Contruct API url
|
|
5909
|
-
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
5910
|
-
self.config.AUTH_API_URLS.classMaterialAssociation;
|
|
5911
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
5912
|
-
orgId: self.orgId, classId: options.classId
|
|
5913
|
-
});
|
|
5914
|
-
// Setup request with URL and Params
|
|
5915
|
-
var requestAPI = request.post(url)
|
|
5916
|
-
.set('Content-Type', 'application/json')
|
|
5917
|
-
.set('Accept', 'application/json');
|
|
5918
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
5919
|
-
|
|
5920
|
-
// Setup token in Authorization header
|
|
5921
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
5922
|
-
|
|
5923
|
-
requestAPI.agent(keepaliveAgent).end(function(err, response) {
|
|
5924
|
-
if(err) {
|
|
5925
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
5926
|
-
dfd.reject(err);
|
|
5927
|
-
}
|
|
5928
|
-
else { dfd.resolve(response.body); }
|
|
5929
|
-
});
|
|
5930
|
-
} else {
|
|
5931
|
-
err = {};
|
|
5932
|
-
err.message = err.description = 'classId or productcodes or bundlecodes not found in'
|
|
5933
|
-
+ 'request options.';
|
|
5934
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
5935
|
-
dfd.reject(err);
|
|
5936
|
-
}
|
|
5937
|
-
}
|
|
5938
|
-
return dfd.promise;
|
|
5939
|
-
}
|
|
5940
|
-
|
|
5941
|
-
/**
|
|
5942
|
-
* @param {
|
|
5943
|
-
* *classId: string,
|
|
5944
|
-
* *body: {
|
|
5945
|
-
* 'productcodes' :['string'],
|
|
5946
|
-
* 'bundlecodes' : ['string']
|
|
5947
|
-
* }
|
|
5948
|
-
* } options
|
|
5949
|
-
*/
|
|
5950
|
-
function unassociateMaterialsWithClass(options) {
|
|
5951
|
-
var self = this;
|
|
5952
|
-
// Initializing promise
|
|
5953
|
-
var dfd = q.defer();
|
|
5954
|
-
// Validations
|
|
5955
|
-
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
5956
|
-
if(err) { dfd.reject(err); }
|
|
5957
|
-
else {
|
|
5958
|
-
if(options && options.classId && options.body &&
|
|
5959
|
-
(options.body.productcodes || options.body.bundlecodes)) {
|
|
5960
|
-
// Passed all validations, Contruct API url
|
|
5961
|
-
var url= self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.classMaterialAssociation;
|
|
5962
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
5963
|
-
orgId: self.orgId, classId: options.classId
|
|
5964
|
-
});
|
|
5965
|
-
// Setup request with URL and Params
|
|
5966
|
-
var requestAPI = request.delete(url)
|
|
5967
|
-
.set('Content-Type', 'application/json')
|
|
5968
|
-
.set('Accept', 'application/json');
|
|
5969
|
-
|
|
5970
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
5971
|
-
|
|
5972
|
-
// Setup token in Authorization header
|
|
5973
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
5974
|
-
|
|
5975
|
-
requestAPI.agent(keepaliveAgent).end(function(err, response) {
|
|
5976
|
-
if(err) {
|
|
5977
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
5978
|
-
dfd.reject(err);
|
|
5979
|
-
}
|
|
5980
|
-
else { dfd.resolve(response.body); }
|
|
5981
|
-
});
|
|
5982
|
-
} else {
|
|
5983
|
-
err = {};
|
|
5984
|
-
const msg = 'classId or productcodes or bundlecodes not found in request options.';
|
|
5985
|
-
err.message = msg;
|
|
5986
|
-
err.description = msg;
|
|
5987
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
5988
|
-
dfd.reject(err);
|
|
5989
|
-
}
|
|
5990
|
-
}
|
|
5991
|
-
return dfd.promise;
|
|
5992
|
-
}
|
|
5993
|
-
|
|
5994
5885
|
//options = {
|
|
5995
5886
|
// classId: 'class uuid',
|
|
5996
5887
|
// productcode: 'product code'
|
|
@@ -6682,14 +6573,6 @@ function updateClass(options) {
|
|
|
6682
6573
|
"productcode": "string", //mandatory
|
|
6683
6574
|
"title": ""
|
|
6684
6575
|
}
|
|
6685
|
-
],
|
|
6686
|
-
"bundles": [ // optional
|
|
6687
|
-
{
|
|
6688
|
-
"bundlecode": "string", //mandatory
|
|
6689
|
-
},
|
|
6690
|
-
{
|
|
6691
|
-
"bundlecode": "string", //mandatory
|
|
6692
|
-
}
|
|
6693
6576
|
]
|
|
6694
6577
|
}
|
|
6695
6578
|
],
|
|
@@ -6705,7 +6588,6 @@ function updateClass(options) {
|
|
|
6705
6588
|
"students": true,
|
|
6706
6589
|
"teachers": true,
|
|
6707
6590
|
"products": true,
|
|
6708
|
-
"bundles": true,
|
|
6709
6591
|
"groups": true,
|
|
6710
6592
|
"assigned_paths": true,
|
|
6711
6593
|
"tags": true,
|
|
@@ -6713,7 +6595,6 @@ function updateClass(options) {
|
|
|
6713
6595
|
"analytics_score_aggregation_type": true,
|
|
6714
6596
|
"ext_data": true,
|
|
6715
6597
|
"limits": true,
|
|
6716
|
-
"skip_assigned_path_create_notification": true,
|
|
6717
6598
|
"advanced": {
|
|
6718
6599
|
"students": [
|
|
6719
6600
|
{
|
|
@@ -6746,7 +6627,6 @@ function updateClass(options) {
|
|
|
6746
6627
|
}
|
|
6747
6628
|
],
|
|
6748
6629
|
"products": [ { "productcode": "string" } ],
|
|
6749
|
-
"bundles": [ { "bundlecode": "string" } ],
|
|
6750
6630
|
"analyticsharingmodel": "string" // Valid values: ['NOINHERIT_SYNCBACK']
|
|
6751
6631
|
"analytics_score_aggregation_type": "string", // Valid values: ['best', 'first', 'last']
|
|
6752
6632
|
"limits": {los: number, students: number} // Optional field
|
|
@@ -6973,12 +6853,7 @@ function deleteAssignedPath(options) {
|
|
|
6973
6853
|
item_type: 'string', //mandatory, ['dls-internal','external']
|
|
6974
6854
|
dls_product_code: 'string' //mandatory only if item_type is 'dls-internal'
|
|
6975
6855
|
}
|
|
6976
|
-
]
|
|
6977
|
-
"rules": {}, // Optional
|
|
6978
|
-
"context": { // Optional (Needed for system event only)
|
|
6979
|
-
"bundle-code": "string",
|
|
6980
|
-
"space_key": "string"
|
|
6981
|
-
}
|
|
6856
|
+
]
|
|
6982
6857
|
}
|
|
6983
6858
|
}
|
|
6984
6859
|
*/
|
|
@@ -7739,60 +7614,7 @@ function deleteItemsFromShowcaseOfAClass(options){
|
|
|
7739
7614
|
* startdate: 'Epoch(Unix) timestamp in milliseconds',
|
|
7740
7615
|
* enddate: 'Epoch(Unix) timestamp in milliseconds',
|
|
7741
7616
|
* instructor: 'user who clones the class',
|
|
7742
|
-
* clone_setting: {
|
|
7743
|
-
* "students": true,
|
|
7744
|
-
* "teachers": true,
|
|
7745
|
-
* "products": true,
|
|
7746
|
-
* "bundles": true,
|
|
7747
|
-
* "groups": true,
|
|
7748
|
-
* "assigned_paths": true,
|
|
7749
|
-
* "skip_assigned_path_create_notification": true,
|
|
7750
|
-
* "tags": true,
|
|
7751
|
-
* "analyticsharingmodel": true,
|
|
7752
|
-
* "analytics_score_aggregation_type": true,
|
|
7753
|
-
* "ext_data": true,
|
|
7754
|
-
* "limits": true,
|
|
7755
|
-
* "advanced": {
|
|
7756
|
-
* "students": [
|
|
7757
|
-
* {
|
|
7758
|
-
* "ext_user_id": "string"
|
|
7759
|
-
* }
|
|
7760
|
-
* ],
|
|
7761
|
-
* "teachers": [
|
|
7762
|
-
* {
|
|
7763
|
-
* "ext_user_id": "string"
|
|
7764
|
-
* }
|
|
7765
|
-
* ],
|
|
7766
|
-
* "groups": [
|
|
7767
|
-
* {
|
|
7768
|
-
* "groupid": "string"
|
|
7769
|
-
* }
|
|
7770
|
-
* ],
|
|
7771
|
-
* "assigned_paths": [
|
|
7772
|
-
* {
|
|
7773
|
-
* "assigned_path_id": "string",
|
|
7774
|
-
* "startdate": 0,
|
|
7775
|
-
* "duedate": 0
|
|
7776
|
-
* }
|
|
7777
|
-
* ],
|
|
7778
|
-
* "products": [
|
|
7779
|
-
* {
|
|
7780
|
-
* "productcode": "string"
|
|
7781
|
-
* }
|
|
7782
|
-
* ],
|
|
7783
|
-
* "bundles": [
|
|
7784
|
-
* {
|
|
7785
|
-
* "bundlecode": "string"
|
|
7786
|
-
* }
|
|
7787
|
-
* ],
|
|
7788
|
-
* "analyticsharingmodel": "NOINHERIT_SYNCBACK",
|
|
7789
|
-
* "analytics_score_aggregation_type": "best",
|
|
7790
|
-
* "limits": {
|
|
7791
|
-
* "los": 0,
|
|
7792
|
-
* "students": 0
|
|
7793
|
-
* }
|
|
7794
|
-
* }
|
|
7795
|
-
* },
|
|
7617
|
+
* clone_setting: {}, // Optional field
|
|
7796
7618
|
* }
|
|
7797
7619
|
*/
|
|
7798
7620
|
function cloneClass(options) {
|
|
@@ -8896,7 +8718,8 @@ var keepaliveAgent = new Agent({
|
|
|
8896
8718
|
});
|
|
8897
8719
|
|
|
8898
8720
|
//AuthExtn Adaptor Contsructor
|
|
8899
|
-
function authextn() {
|
|
8721
|
+
function authextn(accountId) {
|
|
8722
|
+
this.accountId = accountId;
|
|
8900
8723
|
return {
|
|
8901
8724
|
// Gradeformat related APIs
|
|
8902
8725
|
createGradeformat: createGradeformat.bind(this),
|
|
@@ -8922,7 +8745,9 @@ function authextn() {
|
|
|
8922
8745
|
createOrgProductEntitlement: createOrgProductEntitlement.bind(this),
|
|
8923
8746
|
updateOrgProductEntitlement: updateOrgProductEntitlement.bind(this),
|
|
8924
8747
|
getParticularOrgProductEntitlement: getParticularOrgProductEntitlement.bind(this),
|
|
8925
|
-
getAllOrgProductEntitlements: getAllOrgProductEntitlements.bind(this)
|
|
8748
|
+
getAllOrgProductEntitlements: getAllOrgProductEntitlements.bind(this),
|
|
8749
|
+
setupUser: setupUser.bind(this)
|
|
8750
|
+
|
|
8926
8751
|
};
|
|
8927
8752
|
}
|
|
8928
8753
|
|
|
@@ -9579,17 +9404,14 @@ function getClassesOfAGradeformat(options) {
|
|
|
9579
9404
|
|
|
9580
9405
|
/*
|
|
9581
9406
|
options = {
|
|
9582
|
-
assignedpathid: "string", //
|
|
9407
|
+
assignedpathid: "string", //Mandatory
|
|
9583
9408
|
classid: "string", // Mandatory
|
|
9584
|
-
body :
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
],
|
|
9591
|
-
"context": {} // Optional
|
|
9592
|
-
}
|
|
9409
|
+
body : [ // min:1 , max: 50
|
|
9410
|
+
{
|
|
9411
|
+
extUserId: "string", //Mandatory
|
|
9412
|
+
}.
|
|
9413
|
+
....
|
|
9414
|
+
]
|
|
9593
9415
|
}
|
|
9594
9416
|
*/
|
|
9595
9417
|
function createUserAssignedPathEnrollments(options) {
|
|
@@ -9873,7 +9695,64 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
9873
9695
|
//Initializing promise
|
|
9874
9696
|
var deferred = q.defer();
|
|
9875
9697
|
|
|
9876
|
-
|
|
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 {
|
|
9877
9756
|
// Passed all validations, Contruct the API URL
|
|
9878
9757
|
var url = self.config.DEFAULT_HOSTS.AUTHEXTN +
|
|
9879
9758
|
self.config.AUTHEXTN_API_URLS.orgProductEntitlement;
|
|
@@ -9881,11 +9760,19 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
9881
9760
|
|
|
9882
9761
|
// Setup request with URL and Query Params
|
|
9883
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
|
+
|
|
9884
9768
|
var requestAPI = request.get(url).query(params);
|
|
9885
9769
|
|
|
9886
9770
|
// Setup 'traceid' in request header
|
|
9887
9771
|
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
9888
9772
|
|
|
9773
|
+
// Setup 'token' in Authorization header
|
|
9774
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
9775
|
+
|
|
9889
9776
|
requestAPI.agent(keepaliveAgent).end(function (error, response) {
|
|
9890
9777
|
if (error) {
|
|
9891
9778
|
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
@@ -9894,12 +9781,6 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
9894
9781
|
deferred.resolve(response.body);
|
|
9895
9782
|
}
|
|
9896
9783
|
});
|
|
9897
|
-
} else {
|
|
9898
|
-
var error = {};
|
|
9899
|
-
error.message = error.description = 'Mandatory field \'productcode\' not found '+
|
|
9900
|
-
'in request options.';
|
|
9901
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
9902
|
-
deferred.reject(error);
|
|
9903
9784
|
}
|
|
9904
9785
|
|
|
9905
9786
|
return deferred.promise;
|
|
@@ -9907,43 +9788,46 @@ function getParticularOrgProductEntitlement(options) {
|
|
|
9907
9788
|
|
|
9908
9789
|
/**
|
|
9909
9790
|
* @param {
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
|
|
9915
|
-
function
|
|
9791
|
+
* ext_user_id: "string", // mandatory
|
|
9792
|
+
* workflow_type: "string", // mandatory
|
|
9793
|
+
* <workflow_type>: {} // mandatory
|
|
9794
|
+
* } options
|
|
9795
|
+
*/
|
|
9796
|
+
function setupUser(options) {
|
|
9916
9797
|
var self = this;
|
|
9917
9798
|
//Initializing promise
|
|
9918
9799
|
var deferred = q.defer();
|
|
9919
9800
|
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
self.config.AUTHEXTN_API_URLS.
|
|
9923
|
-
|
|
9924
|
-
|
|
9925
|
-
// Setup request with URL and Query Params
|
|
9926
|
-
var params = { productcode: options.productcode };
|
|
9927
|
-
|
|
9928
|
-
if (options.status) { params.status = options.status; }
|
|
9929
|
-
if (options.hasOwnProperty('expired')) { params.expired = options.expired; }
|
|
9930
|
-
if (options.cursor) { params.cursor = options.cursor; }
|
|
9931
|
-
|
|
9932
|
-
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 });
|
|
9933
9805
|
|
|
9934
|
-
|
|
9935
|
-
|
|
9806
|
+
var requestAPI = request.post(url)
|
|
9807
|
+
.set('Content-Type', 'application/json')
|
|
9808
|
+
.set('Accept', 'application/json')
|
|
9809
|
+
.send(options);
|
|
9936
9810
|
|
|
9937
|
-
|
|
9938
|
-
if (error) {
|
|
9939
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
9940
|
-
deferred.reject(error);
|
|
9941
|
-
} else {
|
|
9942
|
-
deferred.resolve(response.body);
|
|
9943
|
-
}
|
|
9944
|
-
});
|
|
9811
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
9945
9812
|
|
|
9946
|
-
|
|
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;
|
|
9947
9831
|
}
|
|
9948
9832
|
|
|
9949
9833
|
},{"../../helpers":3,"agentkeepalive":36,"q":42,"superagent":45}],18:[function(require,module,exports){
|
|
@@ -12143,10 +12027,9 @@ function getMicroEntitlementsForAUser(options) {
|
|
|
12143
12027
|
|
|
12144
12028
|
}
|
|
12145
12029
|
|
|
12146
|
-
|
|
12147
|
-
stage: "
|
|
12148
|
-
|
|
12149
|
-
} */
|
|
12030
|
+
// options= {
|
|
12031
|
+
// stage: "", //stage number or version
|
|
12032
|
+
// }
|
|
12150
12033
|
function getAllBundles(options) {
|
|
12151
12034
|
var self = this;
|
|
12152
12035
|
var dfd = q.defer();
|
|
@@ -12157,14 +12040,7 @@ function getAllBundles(options) {
|
|
|
12157
12040
|
url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
|
|
12158
12041
|
//Contruct parameters
|
|
12159
12042
|
var params = {};
|
|
12160
|
-
if(options) {
|
|
12161
|
-
if(options.stage){
|
|
12162
|
-
params.stage = options.stage;
|
|
12163
|
-
}
|
|
12164
|
-
if(options.target_role){
|
|
12165
|
-
params.target_role = options.target_role;
|
|
12166
|
-
}
|
|
12167
|
-
}
|
|
12043
|
+
if(options && options.stage) { params.stage = options.stage; }
|
|
12168
12044
|
|
|
12169
12045
|
//Setup request with URL and Post data
|
|
12170
12046
|
var requestAPI = request.get(url).query(params);
|
|
@@ -12639,10 +12515,10 @@ function updateBundle(options) {
|
|
|
12639
12515
|
return dfd.promise;
|
|
12640
12516
|
}
|
|
12641
12517
|
|
|
12642
|
-
|
|
12643
|
-
stage: "
|
|
12644
|
-
|
|
12645
|
-
|
|
12518
|
+
// options= {
|
|
12519
|
+
// stage: "", //stage number or version
|
|
12520
|
+
// }
|
|
12521
|
+
|
|
12646
12522
|
function getAllBundles(options) {
|
|
12647
12523
|
var self = this;
|
|
12648
12524
|
//Initializing promise
|
|
@@ -12654,14 +12530,7 @@ function getAllBundles(options) {
|
|
|
12654
12530
|
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, });
|
|
12655
12531
|
//Contruct parameters
|
|
12656
12532
|
var params = {};
|
|
12657
|
-
if(options) {
|
|
12658
|
-
if(options.stage){
|
|
12659
|
-
params.stage = options.stage;
|
|
12660
|
-
}
|
|
12661
|
-
if(options.target_role){
|
|
12662
|
-
params.target_role = options.target_role;
|
|
12663
|
-
}
|
|
12664
|
-
}
|
|
12533
|
+
if(options && options.stage) { params.stage = options.stage; }
|
|
12665
12534
|
|
|
12666
12535
|
//Setup request with URL and Post data
|
|
12667
12536
|
var requestAPI = request.get(url).query(params);
|
|
@@ -12937,7 +12806,6 @@ function getAllProductFamilies(options) {
|
|
|
12937
12806
|
|
|
12938
12807
|
var q = require('q');
|
|
12939
12808
|
var request = require('superagent');
|
|
12940
|
-
var Agent = require('agentkeepalive');
|
|
12941
12809
|
|
|
12942
12810
|
var helpers = require('../../helpers');
|
|
12943
12811
|
var pubnubClientWrapper = require('./pubnubClientWrapper');
|
|
@@ -12948,25 +12816,18 @@ var DLSError = helpers.errors.DLSError;
|
|
|
12948
12816
|
**********************************/
|
|
12949
12817
|
module.exports = pushX;
|
|
12950
12818
|
|
|
12951
|
-
var keepaliveAgent = new Agent({
|
|
12952
|
-
timeout: 60000,
|
|
12953
|
-
freeSocketTimeout: 30000
|
|
12954
|
-
});
|
|
12955
|
-
|
|
12956
12819
|
/*********************************
|
|
12957
12820
|
* Public Function definitions
|
|
12958
12821
|
**********************************/
|
|
12959
12822
|
function pushX() {
|
|
12960
|
-
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
"getPushedEvents": getPushedEvents.bind(this)
|
|
12969
|
-
};
|
|
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
|
+
};
|
|
12970
12831
|
}
|
|
12971
12832
|
|
|
12972
12833
|
/*********************************
|
|
@@ -12974,200 +12835,150 @@ function pushX() {
|
|
|
12974
12835
|
**********************************/
|
|
12975
12836
|
|
|
12976
12837
|
function _connect(pubnubCW, options) {
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
},
|
|
12996
|
-
'pollingEndpoint': options.pollingEndpoint,
|
|
12997
|
-
'pollingIterations': options.pollingIterations || 10, // Default polling iterations is 10
|
|
12998
|
-
'pollingInterval': options.pollingInterval, // Default polling interval is exponential backoff
|
|
12999
|
-
});
|
|
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
|
+
});
|
|
13000
12856
|
}
|
|
13001
12857
|
|
|
13002
12858
|
function _cleanup(pubnubCW) { pubnubCW.cleanup(); }
|
|
13003
12859
|
|
|
13004
|
-
/*options = {}*/
|
|
13005
|
-
function grantByUserOrgId(options) {
|
|
13006
|
-
var dfd = q.defer(); // Initializing promise
|
|
13007
|
-
var allowedChannels = ['jobs', 'systemevents'];
|
|
13008
|
-
var baseChannelName = "o-" + this.orgId + "\\$u-" + this.token.access_token + "\\$";
|
|
13009
|
-
var patterns = [];
|
|
13010
|
-
for(var i in allowedChannels) {
|
|
13011
|
-
var channelName = baseChannelName + allowedChannels[i] + "\\..*";
|
|
13012
|
-
patterns.push(channelName);
|
|
13013
|
-
}
|
|
13014
|
-
options.channels = {};
|
|
13015
|
-
options.channels.patterns = patterns;
|
|
13016
|
-
grantV2.call(this, options)
|
|
13017
|
-
.then(function (res) {
|
|
13018
|
-
dfd.resolve(res);
|
|
13019
|
-
})
|
|
13020
|
-
.catch(function(err) {
|
|
13021
|
-
dfd.reject(err);
|
|
13022
|
-
});
|
|
13023
|
-
return dfd.promise;
|
|
13024
|
-
}
|
|
13025
|
-
|
|
13026
12860
|
/*options = {
|
|
13027
|
-
|
|
13028
|
-
refId: <extRefId>
|
|
12861
|
+
authKey: <authKey>
|
|
13029
12862
|
}*/
|
|
13030
|
-
function
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
|
|
13046
|
-
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
12863
|
+
function grantByUserOrgId(options) {
|
|
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;
|
|
13054
12897
|
}
|
|
13055
12898
|
|
|
13056
12899
|
/*options = {
|
|
13057
12900
|
accountId: <accountid>,
|
|
13058
|
-
|
|
12901
|
+
refId: <extRefId>,
|
|
12902
|
+
authKey: <authKey>
|
|
13059
12903
|
}*/
|
|
13060
|
-
function
|
|
13061
|
-
var err ={};
|
|
13062
|
-
|
|
13063
|
-
|
|
13064
|
-
if(options.accountId && options.extUserId) {
|
|
13065
|
-
var channel = "a-" + options.accountId + "$u-" + options.extUserId;
|
|
13066
|
-
var exactMatch = [channel];
|
|
13067
|
-
options.channels = {};
|
|
13068
|
-
options.channels.exactMatch = exactMatch;
|
|
13069
|
-
grantV2.call(this, options)
|
|
13070
|
-
.then(function (res) {
|
|
13071
|
-
dfd.resolve(res);
|
|
13072
|
-
})
|
|
13073
|
-
.catch(function(err) {
|
|
13074
|
-
dfd.reject(err);
|
|
13075
|
-
});
|
|
13076
|
-
}
|
|
13077
|
-
else {
|
|
13078
|
-
err.message = err.description = "Required parameter ['accountId', 'extUserId'] " +
|
|
13079
|
-
"not found in request options";
|
|
13080
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
13081
|
-
dfd.reject(err);
|
|
13082
|
-
}
|
|
13083
|
-
return dfd.promise;
|
|
13084
|
-
}
|
|
12904
|
+
function grantByAccountId(options) {
|
|
12905
|
+
var self = this, err ={};
|
|
12906
|
+
var dfd = q.defer(); // Initializing promise
|
|
13085
12907
|
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
if(!options.channels) {
|
|
13096
|
-
err.message = err.description = "channels not given in input body.";
|
|
13097
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
13098
|
-
dfd.reject(err);
|
|
13099
|
-
return dfd.promise;
|
|
13100
|
-
}
|
|
13101
|
-
body.channels = options.channels;
|
|
13102
|
-
// Passed all validations, Construct API url
|
|
13103
|
-
var url = self.config.DEFAULT_HOSTS.PUSHX + self.config.PUSHX_API_URLS.grantV2;
|
|
13104
|
-
// Setup request with URL and Params
|
|
13105
|
-
var requestAPI = request.post(url)
|
|
13106
|
-
.set('Content-Type', 'application/json')
|
|
13107
|
-
.set('Accept', 'application/json');
|
|
13108
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
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); }
|
|
13109
12917
|
|
|
13110
|
-
|
|
13111
|
-
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
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
|
+
});
|
|
13115
12929
|
}
|
|
13116
|
-
else {
|
|
13117
|
-
|
|
13118
|
-
|
|
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;
|
|
13119
12937
|
}
|
|
13120
12938
|
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
function getPushedEvents(options) {
|
|
13130
|
-
var self = this;
|
|
13131
|
-
var dfd = q.defer(); // Initializing promise
|
|
13132
|
-
var accountid = options.accountid,
|
|
13133
|
-
channelname = options.channelname,
|
|
13134
|
-
starttime = options.starttime,
|
|
13135
|
-
endtime = options.endtime;
|
|
12939
|
+
/*options = {
|
|
12940
|
+
accountId: <accountid>,
|
|
12941
|
+
extUserId: <extUserId>, //mandatory
|
|
12942
|
+
authKey: <authKey>
|
|
12943
|
+
}*/
|
|
12944
|
+
function grantByAccountIdOnExtUserId(options) {
|
|
12945
|
+
var self = this, err ={};
|
|
12946
|
+
var dfd = q.defer(); // Initializing promise
|
|
13136
12947
|
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
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); }
|
|
13141
12957
|
|
|
13142
|
-
|
|
13143
|
-
|
|
13144
|
-
var requestAPI = request.get(url).query(params);
|
|
13145
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
12958
|
+
var body = { extUserId: options.extUserId };
|
|
12959
|
+
if(options.authKey) { body.authKey = options.authKey; }
|
|
13146
12960
|
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
|
|
13150
|
-
|
|
13151
|
-
|
|
13152
|
-
|
|
13153
|
-
|
|
13154
|
-
|
|
13155
|
-
|
|
13156
|
-
|
|
13157
|
-
|
|
13158
|
-
|
|
13159
|
-
|
|
13160
|
-
|
|
13161
|
-
|
|
13162
|
-
|
|
13163
|
-
dfd.reject(err);
|
|
13164
|
-
}
|
|
13165
|
-
return dfd.promise;
|
|
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
|
+
});
|
|
12969
|
+
}
|
|
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;
|
|
13166
12977
|
}
|
|
12978
|
+
|
|
13167
12979
|
|
|
13168
|
-
},{"../../helpers":3,"./pubnubClientWrapper":26,"
|
|
12980
|
+
},{"../../helpers":3,"./pubnubClientWrapper":26,"q":42,"superagent":45}],26:[function(require,module,exports){
|
|
13169
12981
|
var pubNub = require("pubnub");
|
|
13170
|
-
var request = require('superagent');
|
|
13171
12982
|
var EventEmitter = require("events").EventEmitter;
|
|
13172
12983
|
var helpers = require('../../helpers');
|
|
13173
12984
|
|
|
@@ -13190,13 +13001,6 @@ module.exports = function () {
|
|
|
13190
13001
|
var _globalSubscription = [];
|
|
13191
13002
|
var _globalSubscriptionStatus = {};
|
|
13192
13003
|
var bStatusSubscribed = false;
|
|
13193
|
-
/** ID of the setTimeout - used for Polling events when PubNub fails */
|
|
13194
|
-
var _setTimeoutIDForPolling;
|
|
13195
|
-
/** Timestamp from when the events need to be fetched */
|
|
13196
|
-
var _startTimestampForPolling;
|
|
13197
|
-
/** Counter for polling */
|
|
13198
|
-
var _pollingCounter;
|
|
13199
|
-
var bPollingInitiated = false;
|
|
13200
13004
|
|
|
13201
13005
|
/** ###### END OF MODULE GLOBALS */
|
|
13202
13006
|
|
|
@@ -13212,9 +13016,6 @@ module.exports = function () {
|
|
|
13212
13016
|
//Returning the adaptor (Plain Javascript object)
|
|
13213
13017
|
return {
|
|
13214
13018
|
"on": function (channelObj, handler) {
|
|
13215
|
-
// If PubNub fails, we will fetch the events from this timestamp
|
|
13216
|
-
_startTimestampForPolling = Date.now();
|
|
13217
|
-
|
|
13218
13019
|
var pubNubChannel;
|
|
13219
13020
|
var channelContext = [];
|
|
13220
13021
|
|
|
@@ -13243,9 +13044,6 @@ module.exports = function () {
|
|
|
13243
13044
|
_eventEmitter.on(channelObj.channel, handler);
|
|
13244
13045
|
bStatusSubscribed = true;
|
|
13245
13046
|
}
|
|
13246
|
-
|
|
13247
|
-
// Clean up the old events
|
|
13248
|
-
_checkOldBubbledEvents();
|
|
13249
13047
|
},
|
|
13250
13048
|
"getMySubscriptionStatus": __getMySubscriptionStatus
|
|
13251
13049
|
};
|
|
@@ -13257,12 +13055,8 @@ module.exports = function () {
|
|
|
13257
13055
|
_eventEmitter.emit(subscribedChannel, message);
|
|
13258
13056
|
};
|
|
13259
13057
|
|
|
13260
|
-
var _translatePubnubStatus = function(status
|
|
13058
|
+
var _translatePubnubStatus = function(status) {
|
|
13261
13059
|
var channels = [], error, successObj;
|
|
13262
|
-
|
|
13263
|
-
// If polling has been initiated, ignore all punnub status
|
|
13264
|
-
if (bPollingInitiated) return;
|
|
13265
|
-
|
|
13266
13060
|
switch (status.category) {
|
|
13267
13061
|
case "PNConnectedCategory":
|
|
13268
13062
|
if(status.operation === "PNSubscribeOperation") {
|
|
@@ -13290,10 +13084,8 @@ module.exports = function () {
|
|
|
13290
13084
|
break;
|
|
13291
13085
|
case "PNAccessDeniedCategory":
|
|
13292
13086
|
if(status.operation === "PNSubscribeOperation") {
|
|
13293
|
-
var errorText = status.errorData.response && status.errorData.response.text;
|
|
13294
|
-
var errorJSON = errorText ? JSON.parse(errorText) : undefined;
|
|
13295
13087
|
var errorData = {
|
|
13296
|
-
payload:
|
|
13088
|
+
payload: JSON.parse(status.errorData.response.text).payload,
|
|
13297
13089
|
message: 'Forbidden: Subscription failed.',
|
|
13298
13090
|
errorDetails: {
|
|
13299
13091
|
operation: status.operation,
|
|
@@ -13322,47 +13114,6 @@ module.exports = function () {
|
|
|
13322
13114
|
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
13323
13115
|
_eventEmitter.emit('pushx_status', error);
|
|
13324
13116
|
break;
|
|
13325
|
-
case "PNNetworkIssuesCategory":
|
|
13326
|
-
if(status.operation === 'PNSubscribeOperation') {
|
|
13327
|
-
if(!options.accountId || !_userOptions.pollingEndpoint) {
|
|
13328
|
-
error = {
|
|
13329
|
-
message: "Polling initiation error: Missing mandatory parameters to initiate polling operation - [accountId, pollingEndpoint]",
|
|
13330
|
-
status: status.statusCode
|
|
13331
|
-
};
|
|
13332
|
-
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
13333
|
-
_eventEmitter.emit('pushx_status', error);
|
|
13334
|
-
break;
|
|
13335
|
-
}
|
|
13336
|
-
else {
|
|
13337
|
-
/**
|
|
13338
|
-
* Handle network issue category status for 'subscription' opreration
|
|
13339
|
-
* Start the events polling here.
|
|
13340
|
-
*
|
|
13341
|
-
* The wrapper supports multiple channels, but the APP currently uses a single channel only.
|
|
13342
|
-
* Polling will also limited to a single channel.
|
|
13343
|
-
*/
|
|
13344
|
-
_pollingCounter = 0;
|
|
13345
|
-
_pollForEvents();
|
|
13346
|
-
bPollingInitiated = true;
|
|
13347
|
-
}
|
|
13348
|
-
}
|
|
13349
|
-
else {
|
|
13350
|
-
// Handle network issue category status for other operations like 'unsubscription'
|
|
13351
|
-
}
|
|
13352
|
-
break;
|
|
13353
|
-
case "PNReconnectedCategory":
|
|
13354
|
-
// Handle reconnected category status.
|
|
13355
|
-
break;
|
|
13356
|
-
default:
|
|
13357
|
-
// Emit error for other status-category received from pubnub
|
|
13358
|
-
error = {
|
|
13359
|
-
message: "PushX Error: unexpected error",
|
|
13360
|
-
status: status.statusCode,
|
|
13361
|
-
pushXError: status
|
|
13362
|
-
};
|
|
13363
|
-
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
13364
|
-
_eventEmitter.emit('pushx_status', error);
|
|
13365
|
-
break;
|
|
13366
13117
|
}
|
|
13367
13118
|
};
|
|
13368
13119
|
|
|
@@ -13394,15 +13145,11 @@ module.exports = function () {
|
|
|
13394
13145
|
* @returns PROMISE.
|
|
13395
13146
|
*/
|
|
13396
13147
|
var __setup = function (userOptions) {
|
|
13397
|
-
|
|
13398
13148
|
var pubnubConfig = userOptions.pubnub;
|
|
13399
13149
|
pubnubConfig.uuid = userOptions.userid;
|
|
13400
|
-
var accountId = userOptions.accountid;
|
|
13401
|
-
var token = userOptions.token;
|
|
13402
13150
|
|
|
13403
13151
|
if (!_pubnubClient && pubnubConfig) {
|
|
13404
13152
|
_pubnubClient = new pubNub(pubnubConfig); //Connect with PubNub SDK
|
|
13405
|
-
_pubnubClient.setToken(token);
|
|
13406
13153
|
processSetup();
|
|
13407
13154
|
} else {
|
|
13408
13155
|
return new Error('Already Initialized');
|
|
@@ -13418,8 +13165,7 @@ module.exports = function () {
|
|
|
13418
13165
|
_translatePubnubMessage(data);
|
|
13419
13166
|
},
|
|
13420
13167
|
"status": function (status) {
|
|
13421
|
-
|
|
13422
|
-
_translatePubnubStatus(status, statusOptions);
|
|
13168
|
+
_translatePubnubStatus(status);
|
|
13423
13169
|
}
|
|
13424
13170
|
});
|
|
13425
13171
|
}
|
|
@@ -13433,169 +13179,8 @@ module.exports = function () {
|
|
|
13433
13179
|
_globalSubscription = [];
|
|
13434
13180
|
bStatusSubscribed = false;
|
|
13435
13181
|
_globalSubscriptionStatus = {};
|
|
13436
|
-
bPollingInitiated = false;
|
|
13437
13182
|
}
|
|
13438
13183
|
_pubnubClient = undefined;
|
|
13439
|
-
|
|
13440
|
-
// Clear the Polling
|
|
13441
|
-
if (_setTimeoutIDForPolling) {
|
|
13442
|
-
clearTimeout(_setTimeoutIDForPolling);
|
|
13443
|
-
// Setting the start time to now to clear the old events
|
|
13444
|
-
_startTimestampForPolling = Date.now();
|
|
13445
|
-
_checkOldBubbledEvents();
|
|
13446
|
-
_setTimeoutIDForPolling = undefined;
|
|
13447
|
-
_pollingCounter = undefined;
|
|
13448
|
-
_startTimestampForPolling = undefined;
|
|
13449
|
-
}
|
|
13450
|
-
};
|
|
13451
|
-
|
|
13452
|
-
/**
|
|
13453
|
-
* Polling function
|
|
13454
|
-
*/
|
|
13455
|
-
var _pollForEvents = function () {
|
|
13456
|
-
// Setup request params
|
|
13457
|
-
var params = {
|
|
13458
|
-
accountid: _userOptions.accountid,
|
|
13459
|
-
channelname: _globalSubscription[0],
|
|
13460
|
-
starttime: _startTimestampForPolling,
|
|
13461
|
-
endtime: Date.now()
|
|
13462
|
-
};
|
|
13463
|
-
|
|
13464
|
-
// Safe check to avoid poll for events if the channel name or start time is not set
|
|
13465
|
-
// This handles an edge condition where the clearTimeout doesn't work as expected
|
|
13466
|
-
if (!params.channelname || !params.starttime) {
|
|
13467
|
-
return;
|
|
13468
|
-
}
|
|
13469
|
-
|
|
13470
|
-
var requestAPI = request.get(_userOptions.pollingEndpoint).query(params);
|
|
13471
|
-
|
|
13472
|
-
requestAPI
|
|
13473
|
-
.end(function(error, response) {
|
|
13474
|
-
|
|
13475
|
-
if (!error) {
|
|
13476
|
-
// Bubble the connected status
|
|
13477
|
-
if (_pollingCounter === 0) {
|
|
13478
|
-
// Set the status of the channel to subscribed
|
|
13479
|
-
if(_globalSubscriptionStatus[_globalSubscription[0]]) {
|
|
13480
|
-
_globalSubscriptionStatus[_globalSubscription[0]].status = 'subscribed';
|
|
13481
|
-
}
|
|
13482
|
-
|
|
13483
|
-
var successObj = {
|
|
13484
|
-
category: 'PUSHX',
|
|
13485
|
-
type: 'CHANNEL_SUBSCRIPTION',
|
|
13486
|
-
status: 'SUCCESS',
|
|
13487
|
-
message: 'Success: Subscribed successfully.',
|
|
13488
|
-
httpcode: 200,
|
|
13489
|
-
data: {
|
|
13490
|
-
payload: {
|
|
13491
|
-
channels: _globalSubscription
|
|
13492
|
-
},
|
|
13493
|
-
message: 'Success: Subscribed successfully.'
|
|
13494
|
-
}
|
|
13495
|
-
};
|
|
13496
|
-
_eventEmitter.emit('pushx_status', successObj);
|
|
13497
|
-
}
|
|
13498
|
-
|
|
13499
|
-
// Bubble the received events
|
|
13500
|
-
_bubblePolledEvents(response.body);
|
|
13501
|
-
|
|
13502
|
-
// Increase the counter
|
|
13503
|
-
_pollingCounter++;
|
|
13504
|
-
}
|
|
13505
|
-
|
|
13506
|
-
// Polling will be done only for specific number of times
|
|
13507
|
-
if (_pollingCounter > _userOptions.pollingIterations) {
|
|
13508
|
-
var error = {
|
|
13509
|
-
message: "Polling error: Polling limit exceeded",
|
|
13510
|
-
status: 429
|
|
13511
|
-
};
|
|
13512
|
-
error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
|
|
13513
|
-
_eventEmitter.emit('pushx_status', error);
|
|
13514
|
-
} else {
|
|
13515
|
-
var timeoutDelay;
|
|
13516
|
-
|
|
13517
|
-
// If the polling interval is provided, use that
|
|
13518
|
-
if (_userOptions.pollingInterval) {
|
|
13519
|
-
timeoutDelay = _userOptions.pollingInterval * 60 * 1000;
|
|
13520
|
-
} else {
|
|
13521
|
-
// Else, use exponential backoff
|
|
13522
|
-
timeoutDelay = parseInt(Math.pow(1.3, _pollingCounter) * 10 * 1000, 10);
|
|
13523
|
-
}
|
|
13524
|
-
|
|
13525
|
-
// Set timeout for next poll
|
|
13526
|
-
if (timeoutDelay) {
|
|
13527
|
-
_setTimeoutIDForPolling = setTimeout(_pollForEvents, timeoutDelay);
|
|
13528
|
-
}
|
|
13529
|
-
}
|
|
13530
|
-
});
|
|
13531
|
-
};
|
|
13532
|
-
|
|
13533
|
-
/**
|
|
13534
|
-
* Bubble the polled events to the FE APP
|
|
13535
|
-
* @param {*} events - Events recieved from the polling endpoint
|
|
13536
|
-
*/
|
|
13537
|
-
var _bubblePolledEvents = function (events) {
|
|
13538
|
-
// Load the old events from the session storage
|
|
13539
|
-
var oldEventData = _checkOldBubbledEvents();
|
|
13540
|
-
|
|
13541
|
-
var oldEvents = oldEventData.events;
|
|
13542
|
-
var sessionStorageKey = oldEventData.key;
|
|
13543
|
-
|
|
13544
|
-
for (var i = 0; i < events.entities.length; i++) {
|
|
13545
|
-
var event = events.entities[i];
|
|
13546
|
-
var eventId = event.pk + '_' + event.sk;
|
|
13547
|
-
|
|
13548
|
-
// Check if the event is already emitted
|
|
13549
|
-
if (!oldEvents[eventId]) {
|
|
13550
|
-
oldEvents[eventId] = event.context.start_time;
|
|
13551
|
-
|
|
13552
|
-
// Emit the event
|
|
13553
|
-
_eventEmitter.emit(_globalSubscription[0], event);
|
|
13554
|
-
}
|
|
13555
|
-
}
|
|
13556
|
-
|
|
13557
|
-
// Save the bubbled events to session storage
|
|
13558
|
-
sessionStorage.setItem(sessionStorageKey, JSON.stringify(oldEvents));
|
|
13559
|
-
};
|
|
13560
|
-
|
|
13561
|
-
/**
|
|
13562
|
-
* Check the old bubbled events and remove the events that are older than the start timestamp
|
|
13563
|
-
* @returns {object} - Object containing the key and the events
|
|
13564
|
-
*/
|
|
13565
|
-
var _checkOldBubbledEvents = function () {
|
|
13566
|
-
var sessionStorageKey = 'comprodls.old_pushx_events.' + _userOptions.userid + '.' + _globalSubscription[0];
|
|
13567
|
-
var oldEvents = sessionStorage.getItem(sessionStorageKey);
|
|
13568
|
-
|
|
13569
|
-
if (oldEvents) {
|
|
13570
|
-
try {
|
|
13571
|
-
oldEvents = JSON.parse(oldEvents);
|
|
13572
|
-
} catch (e) {
|
|
13573
|
-
oldEvents = {};
|
|
13574
|
-
}
|
|
13575
|
-
|
|
13576
|
-
var oldEventIds = Object.keys(oldEvents);
|
|
13577
|
-
|
|
13578
|
-
// Remove the events that are older than the start timestamp
|
|
13579
|
-
for (var i = 0; i < oldEventIds.length; i++) {
|
|
13580
|
-
var oldEventId = oldEventIds[i];
|
|
13581
|
-
|
|
13582
|
-
if (oldEvents[oldEventId] < _startTimestampForPolling) {
|
|
13583
|
-
delete oldEvents[oldEventId];
|
|
13584
|
-
}
|
|
13585
|
-
}
|
|
13586
|
-
|
|
13587
|
-
// If the number of events has changed, save the events
|
|
13588
|
-
if (oldEventIds.length !== Object.keys(oldEvents).length) {
|
|
13589
|
-
sessionStorage.setItem(sessionStorageKey, JSON.stringify(oldEvents));
|
|
13590
|
-
}
|
|
13591
|
-
} else {
|
|
13592
|
-
oldEvents = {};
|
|
13593
|
-
}
|
|
13594
|
-
|
|
13595
|
-
return {
|
|
13596
|
-
key: sessionStorageKey,
|
|
13597
|
-
events: oldEvents
|
|
13598
|
-
};
|
|
13599
13184
|
};
|
|
13600
13185
|
|
|
13601
13186
|
return { // Return public methods for the wrapper
|
|
@@ -13605,7 +13190,7 @@ module.exports = function () {
|
|
|
13605
13190
|
|
|
13606
13191
|
}; //End of Client Wrapper module
|
|
13607
13192
|
|
|
13608
|
-
},{"../../helpers":3,"events":38,"pubnub":41
|
|
13193
|
+
},{"../../helpers":3,"events":38,"pubnub":41}],27:[function(require,module,exports){
|
|
13609
13194
|
/*************************************************************************
|
|
13610
13195
|
*
|
|
13611
13196
|
* COMPRO CONFIDENTIAL
|
|
@@ -14603,7 +14188,6 @@ function provisionBulkSpaces(options) {
|
|
|
14603
14188
|
* *startdate: <epoch>,
|
|
14604
14189
|
* *enddate: <epoch>,
|
|
14605
14190
|
* description: 'string',
|
|
14606
|
-
* ext_class_title : 'string',
|
|
14607
14191
|
* ext_data: {},
|
|
14608
14192
|
* limits: {
|
|
14609
14193
|
* *los: 0,
|
|
@@ -14617,7 +14201,6 @@ function provisionBulkSpaces(options) {
|
|
|
14617
14201
|
* clone_settings: {
|
|
14618
14202
|
* *src_ext_classid: 'string',
|
|
14619
14203
|
* products: boolean,
|
|
14620
|
-
* bundles: boolean,
|
|
14621
14204
|
* assigned_paths: boolean,
|
|
14622
14205
|
* ext_assigned_path_id_rule: 'string' //enum: ['SRC_ID']
|
|
14623
14206
|
* advanced: {
|
|
@@ -14631,9 +14214,6 @@ function provisionBulkSpaces(options) {
|
|
|
14631
14214
|
* ],
|
|
14632
14215
|
* products: [
|
|
14633
14216
|
* { *productcode: 'string' },
|
|
14634
|
-
* ],
|
|
14635
|
-
* bundles: [
|
|
14636
|
-
* { *bundlecode: 'string' },
|
|
14637
14217
|
* ]
|
|
14638
14218
|
* }
|
|
14639
14219
|
* }
|
|
@@ -15312,8 +14892,7 @@ var keepaliveAgent = new Agent({
|
|
|
15312
14892
|
function spacesextn(accountId) {
|
|
15313
14893
|
this.accountId = accountId;
|
|
15314
14894
|
return {
|
|
15315
|
-
entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this)
|
|
15316
|
-
setupUser: setupUser.bind(this)
|
|
14895
|
+
entitleBulkUsersToProducts: entitleBulkUsersToProducts.bind(this)
|
|
15317
14896
|
};
|
|
15318
14897
|
}
|
|
15319
14898
|
|
|
@@ -15374,49 +14953,6 @@ function entitleBulkUsersToProducts(options) {
|
|
|
15374
14953
|
return dfd.promise;
|
|
15375
14954
|
}
|
|
15376
14955
|
|
|
15377
|
-
/**
|
|
15378
|
-
* @param {
|
|
15379
|
-
* *ext_user_id: "string",
|
|
15380
|
-
* *workflow_type: "string",
|
|
15381
|
-
* *<workflow_type>: {}
|
|
15382
|
-
* } options
|
|
15383
|
-
*/
|
|
15384
|
-
function setupUser(options) {
|
|
15385
|
-
var self = this;
|
|
15386
|
-
//Initializing promise
|
|
15387
|
-
var deferred = q.defer();
|
|
15388
|
-
|
|
15389
|
-
if (options && options.ext_user_id && options.workflow_type) {
|
|
15390
|
-
//Passed all validations, Contruct API url
|
|
15391
|
-
var url = self.config.DEFAULT_HOSTS.AUTHEXTN + self.config.AUTHEXTN_API_URLS.setupUser;
|
|
15392
|
-
url = helpers.api.constructAPIUrl(url, { accountId: self.accountId });
|
|
15393
|
-
|
|
15394
|
-
var requestAPI = request.post(url)
|
|
15395
|
-
.set('Content-Type', 'application/json')
|
|
15396
|
-
.set('Accept', 'application/json')
|
|
15397
|
-
.send(options);
|
|
15398
|
-
|
|
15399
|
-
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
15400
|
-
|
|
15401
|
-
requestAPI
|
|
15402
|
-
.agent(keepaliveAgent)
|
|
15403
|
-
.end(function(err, res) {
|
|
15404
|
-
if (err) {
|
|
15405
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
15406
|
-
deferred.reject(err);
|
|
15407
|
-
} else {
|
|
15408
|
-
deferred.resolve(res.body);
|
|
15409
|
-
}
|
|
15410
|
-
});
|
|
15411
|
-
} else {
|
|
15412
|
-
var err = {};
|
|
15413
|
-
err.message = err.description = 'Mandatory field \'ext_user_id\' or \'workflow_type\' not found '+
|
|
15414
|
-
'in the request options.';
|
|
15415
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
15416
|
-
deferred.reject(err);
|
|
15417
|
-
}
|
|
15418
|
-
return deferred.promise;
|
|
15419
|
-
}
|
|
15420
14956
|
|
|
15421
14957
|
},{"../../helpers":3,"agentkeepalive":36,"q":42,"superagent":45}],30:[function(require,module,exports){
|
|
15422
14958
|
/*************************************************************************
|
|
@@ -16094,7 +15630,6 @@ function workflows(accountId) {
|
|
|
16094
15630
|
"address": {
|
|
16095
15631
|
"city": "string",
|
|
16096
15632
|
"country": "string",
|
|
16097
|
-
"line1": "string",
|
|
16098
15633
|
"street1": "string",
|
|
16099
15634
|
"street2": "string",
|
|
16100
15635
|
"street3": "string",
|
|
@@ -16450,7 +15985,6 @@ function completeAWorkflow(options) {
|
|
|
16450
15985
|
"address": {
|
|
16451
15986
|
"city": "string",
|
|
16452
15987
|
"country": "string",
|
|
16453
|
-
"line1": "string",
|
|
16454
15988
|
"street1": "string",
|
|
16455
15989
|
"street2": "string",
|
|
16456
15990
|
"street3": "string",
|
|
@@ -16460,7 +15994,7 @@ function completeAWorkflow(options) {
|
|
|
16460
15994
|
"display_name": "string",
|
|
16461
15995
|
"school_key": "string"
|
|
16462
15996
|
}
|
|
16463
|
-
}
|
|
15997
|
+
}
|
|
16464
15998
|
}
|
|
16465
15999
|
*/
|
|
16466
16000
|
function updateWorkflowRequest(options) {
|
|
@@ -16499,8 +16033,7 @@ function updateWorkflowRequest(options) {
|
|
|
16499
16033
|
dfd.reject(err);
|
|
16500
16034
|
}
|
|
16501
16035
|
return dfd.promise;
|
|
16502
|
-
}
|
|
16503
|
-
|
|
16036
|
+
}
|
|
16504
16037
|
},{"./../../helpers":3,"q":42,"superagent":45}],33:[function(require,module,exports){
|
|
16505
16038
|
/*************************************************************************
|
|
16506
16039
|
*
|
|
@@ -16546,7 +16079,8 @@ function xapi(accountId) {
|
|
|
16546
16079
|
this.accountId = accountId;
|
|
16547
16080
|
return {
|
|
16548
16081
|
postStatement: postStatements.bind(this),
|
|
16549
|
-
postExternalStatements: postExternalStatements.bind(this)
|
|
16082
|
+
postExternalStatements: postExternalStatements.bind(this),
|
|
16083
|
+
resetUserProductProgress: resetUserProductProgress.bind(this)
|
|
16550
16084
|
};
|
|
16551
16085
|
}
|
|
16552
16086
|
|
|
@@ -16735,6 +16269,47 @@ function postExternalStatements(options) {
|
|
|
16735
16269
|
});
|
|
16736
16270
|
return dfd.promise;
|
|
16737
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
|
+
}
|
|
16738
16313
|
|
|
16739
16314
|
},{"../../helpers":3,"q":42,"superagent":45}],34:[function(require,module,exports){
|
|
16740
16315
|
/*************************************************************************
|