comprodls-sdk 2.37.0 → 2.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/comprodls-sdk.js +452 -49
- package/dist/comprodls-sdk.min.js +19 -19
- package/lib/config/index.js +6 -1
- package/lib/services/auth/index.js +446 -48
- package/package.json +1 -1
package/lib/config/index.js
CHANGED
|
@@ -212,7 +212,12 @@ exports.AUTH_API_URLS = {
|
|
|
212
212
|
createOrGetGradebookMeta: '/org/{orgId}/classes/{classId}/gradebooks',
|
|
213
213
|
updateOrDeleteGradebookMeta: '/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}',
|
|
214
214
|
gradebookColumns: '/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}/columns',
|
|
215
|
-
|
|
215
|
+
getAllClassesOfAComponent: '/org/{orgId}/components/{component_code}/classes',
|
|
216
|
+
removeAllGradebookColumnsOfAComponent: '/org/{orgId}/gradebook/columns/custom-components/{component_code}',
|
|
217
|
+
|
|
218
|
+
// Custom Components related APIs
|
|
219
|
+
customComponents: '/org/{orgid}/custom-components',
|
|
220
|
+
particularCustomComponent: '/org/{orgid}/custom-components/{custom_component_code}',
|
|
216
221
|
};
|
|
217
222
|
|
|
218
223
|
exports.ACTIVITY_API_URLS = {
|
|
@@ -112,10 +112,19 @@ function auth() {
|
|
|
112
112
|
getParticularGradebookMetaOfAClass: getParticularGradebookMetaOfAClass.bind(this),
|
|
113
113
|
getAllGradebooksMetaOfAClass: getAllGradebooksMetaOfAClass.bind(this),
|
|
114
114
|
addGradebookColumns: addGradebookColumns.bind(this),
|
|
115
|
-
|
|
115
|
+
updateMultipleGradebookColumns: updateMultipleGradebookColumns.bind(this),
|
|
116
116
|
removeGradebookColumns: removeGradebookColumns.bind(this),
|
|
117
117
|
getParticularColumnOfAGradebook: getParticularColumnOfAGradebook.bind(this),
|
|
118
|
-
getAllColumnsOfAGradebook: getAllColumnsOfAGradebook.bind(this)
|
|
118
|
+
getAllColumnsOfAGradebook: getAllColumnsOfAGradebook.bind(this),
|
|
119
|
+
getAllClassesOfAComponent: getAllClassesOfAComponent.bind(this),
|
|
120
|
+
removeAllGradebookColumnsOfAComponent: removeAllGradebookColumnsOfAComponent.bind(this),
|
|
121
|
+
|
|
122
|
+
// Custom Components related APIs
|
|
123
|
+
createCustomComponent: createCustomComponent.bind(this),
|
|
124
|
+
updateCustomComponent: updateCustomComponent.bind(this),
|
|
125
|
+
deleteCustomComponent: deleteCustomComponent.bind(this),
|
|
126
|
+
getParticularCustomComponent: getParticularCustomComponent.bind(this),
|
|
127
|
+
getAllCustomComponents: getAllCustomComponents.bind(this)
|
|
119
128
|
};
|
|
120
129
|
}
|
|
121
130
|
|
|
@@ -3394,20 +3403,24 @@ function addGradebookColumns(options) {
|
|
|
3394
3403
|
options = {
|
|
3395
3404
|
classid: "string", //mandatory
|
|
3396
3405
|
gradebook_id: "string", //mandatory
|
|
3397
|
-
column_id: "string", //mandatory
|
|
3398
3406
|
body : {
|
|
3399
|
-
"
|
|
3400
|
-
"weightage": "string",
|
|
3401
|
-
"items": [
|
|
3407
|
+
"columns": [
|
|
3402
3408
|
{
|
|
3403
|
-
"
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3409
|
+
"title": "string",
|
|
3410
|
+
"weightage": "string",
|
|
3411
|
+
"items": [
|
|
3412
|
+
{
|
|
3413
|
+
"item-code": "string"
|
|
3414
|
+
}
|
|
3415
|
+
],
|
|
3416
|
+
"data": {...}
|
|
3417
|
+
},
|
|
3418
|
+
{...}
|
|
3419
|
+
]
|
|
3407
3420
|
}
|
|
3408
3421
|
}
|
|
3409
3422
|
*/
|
|
3410
|
-
function
|
|
3423
|
+
function updateMultipleGradebookColumns(options) {
|
|
3411
3424
|
// Initializing promise
|
|
3412
3425
|
var deferred = q.defer();
|
|
3413
3426
|
var self = this;
|
|
@@ -3418,49 +3431,42 @@ function updateGradebookColumn(options) {
|
|
|
3418
3431
|
if(err) {
|
|
3419
3432
|
deferred.reject(err);
|
|
3420
3433
|
} else {
|
|
3421
|
-
if (options && options.classid && options.gradebook_id && options.
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.updateGradebookColumn;
|
|
3434
|
+
if (options && options.classid && options.gradebook_id && options.body && options.body.columns) {
|
|
3435
|
+
// Passed all validations, Contruct API url
|
|
3436
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.gradebookColumns;
|
|
3425
3437
|
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
});
|
|
3438
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3439
|
+
orgId: self.orgId,
|
|
3440
|
+
classId: options.classid,
|
|
3441
|
+
gradebook_id: options.gradebook_id
|
|
3442
|
+
});
|
|
3432
3443
|
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3444
|
+
var params = options.body;
|
|
3445
|
+
// Setup request with URL and Params
|
|
3446
|
+
var requestAPI = request.put(url)
|
|
3447
|
+
.set('Content-Type', 'application/json')
|
|
3448
|
+
.set('Accept', 'application/json')
|
|
3449
|
+
.send(params);
|
|
3439
3450
|
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3451
|
+
if (self.traceid) {
|
|
3452
|
+
requestAPI.set('X-Amzn-Trace-Id', self.traceid);
|
|
3453
|
+
}
|
|
3443
3454
|
|
|
3444
|
-
|
|
3445
|
-
|
|
3455
|
+
//Setup token in Authorization header
|
|
3456
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3446
3457
|
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
} else {
|
|
3458
|
-
error.message = error.description = 'Body of the request input cannot be empty.';
|
|
3459
|
-
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3460
|
-
deferred.reject(error);
|
|
3461
|
-
}
|
|
3458
|
+
requestAPI
|
|
3459
|
+
.agent(keepaliveAgent)
|
|
3460
|
+
.end(function(error, response) {
|
|
3461
|
+
if (error) {
|
|
3462
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3463
|
+
deferred.reject(error);
|
|
3464
|
+
} else {
|
|
3465
|
+
deferred.resolve(response.body);
|
|
3466
|
+
}
|
|
3467
|
+
});
|
|
3462
3468
|
} else {
|
|
3463
|
-
error.message = error.description = 'Mandatory params: classid, gradebook_id,
|
|
3469
|
+
error.message = error.description = 'Mandatory params: classid, gradebook_id, body or body.columns' +
|
|
3464
3470
|
' not found in the request options.';
|
|
3465
3471
|
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3466
3472
|
deferred.reject(error);
|
|
@@ -3643,3 +3649,395 @@ function getAllColumnsOfAGradebook (options) {
|
|
|
3643
3649
|
}
|
|
3644
3650
|
return deferred.promise;
|
|
3645
3651
|
}
|
|
3652
|
+
|
|
3653
|
+
/*
|
|
3654
|
+
options = {
|
|
3655
|
+
component_code: "string", //mandatory
|
|
3656
|
+
cursor: "string" //optional
|
|
3657
|
+
}
|
|
3658
|
+
*/
|
|
3659
|
+
function getAllClassesOfAComponent (options) {
|
|
3660
|
+
// Initializing promise
|
|
3661
|
+
var deferred = q.defer();
|
|
3662
|
+
var self = this;
|
|
3663
|
+
var error = {};
|
|
3664
|
+
|
|
3665
|
+
//Validations
|
|
3666
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3667
|
+
if(err) {
|
|
3668
|
+
deferred.reject(err);
|
|
3669
|
+
} else {
|
|
3670
|
+
if (options && options.component_code) {
|
|
3671
|
+
// Passed all validations, Contruct API url
|
|
3672
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
3673
|
+
self.config.AUTH_API_URLS.getAllClassesOfAComponent;
|
|
3674
|
+
|
|
3675
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3676
|
+
orgId: self.orgId,
|
|
3677
|
+
component_code: options.component_code
|
|
3678
|
+
});
|
|
3679
|
+
|
|
3680
|
+
var params = {};
|
|
3681
|
+
if(options.cursor){ params.cursor = options.cursor; }
|
|
3682
|
+
|
|
3683
|
+
var requestAPI = request.get(url).query(params);
|
|
3684
|
+
|
|
3685
|
+
if (self.traceid) {
|
|
3686
|
+
requestAPI.set('X-Amzn-Trace-Id', self.traceid);
|
|
3687
|
+
}
|
|
3688
|
+
|
|
3689
|
+
//Setup token in Authorization header
|
|
3690
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3691
|
+
|
|
3692
|
+
requestAPI
|
|
3693
|
+
.agent(keepaliveAgent)
|
|
3694
|
+
.end(function(error, response) {
|
|
3695
|
+
if (error) {
|
|
3696
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3697
|
+
deferred.reject(error);
|
|
3698
|
+
} else {
|
|
3699
|
+
deferred.resolve(response.body);
|
|
3700
|
+
}
|
|
3701
|
+
});
|
|
3702
|
+
} else {
|
|
3703
|
+
error.message = error.description = 'Mandatory params: component_code' +
|
|
3704
|
+
' not found in the request options.';
|
|
3705
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3706
|
+
deferred.reject(error);
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3709
|
+
return deferred.promise;
|
|
3710
|
+
}
|
|
3711
|
+
|
|
3712
|
+
/*
|
|
3713
|
+
options = {
|
|
3714
|
+
component_code: "string" //mandatory
|
|
3715
|
+
}
|
|
3716
|
+
*/
|
|
3717
|
+
function removeAllGradebookColumnsOfAComponent (options) {
|
|
3718
|
+
// Initializing promise
|
|
3719
|
+
var deferred = q.defer();
|
|
3720
|
+
var self = this;
|
|
3721
|
+
var error = {};
|
|
3722
|
+
|
|
3723
|
+
//Validations
|
|
3724
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3725
|
+
if(err) {
|
|
3726
|
+
deferred.reject(err);
|
|
3727
|
+
} else {
|
|
3728
|
+
if (options && options.component_code) {
|
|
3729
|
+
// Passed all validations, Contruct API url
|
|
3730
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
3731
|
+
self.config.AUTH_API_URLS.removeAllGradebookColumnsOfAComponent;
|
|
3732
|
+
|
|
3733
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3734
|
+
orgId: self.orgId,
|
|
3735
|
+
component_code: options.component_code
|
|
3736
|
+
});
|
|
3737
|
+
|
|
3738
|
+
// Setup request with URL and Params
|
|
3739
|
+
var requestAPI = request
|
|
3740
|
+
.delete(url)
|
|
3741
|
+
.set('Content-Type', 'application/json')
|
|
3742
|
+
.set('Accept', 'application/json')
|
|
3743
|
+
.send(options.body);
|
|
3744
|
+
|
|
3745
|
+
if (self.traceid) {
|
|
3746
|
+
requestAPI.set('X-Amzn-Trace-Id', self.traceid);
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3749
|
+
//Setup token in Authorization header
|
|
3750
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3751
|
+
|
|
3752
|
+
requestAPI
|
|
3753
|
+
.agent(keepaliveAgent)
|
|
3754
|
+
.end(function(error, response) {
|
|
3755
|
+
if (error) {
|
|
3756
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3757
|
+
deferred.reject(error);
|
|
3758
|
+
} else {
|
|
3759
|
+
deferred.resolve(response.body);
|
|
3760
|
+
}
|
|
3761
|
+
});
|
|
3762
|
+
} else {
|
|
3763
|
+
error.message = error.description = 'Mandatory params: component_code' +
|
|
3764
|
+
' not found in the request options.';
|
|
3765
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3766
|
+
deferred.reject(error);
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
return deferred.promise;
|
|
3770
|
+
}
|
|
3771
|
+
|
|
3772
|
+
/*
|
|
3773
|
+
options = {
|
|
3774
|
+
body : {
|
|
3775
|
+
custom_component_code: "string", // Mandatory
|
|
3776
|
+
title: "string", // Mandatory
|
|
3777
|
+
custom_component_type: "string", // Mandatory
|
|
3778
|
+
scoring_type: "string",
|
|
3779
|
+
items: [{...}],
|
|
3780
|
+
data: {...}
|
|
3781
|
+
}
|
|
3782
|
+
}
|
|
3783
|
+
*/
|
|
3784
|
+
function createCustomComponent(options) {
|
|
3785
|
+
var self = this;
|
|
3786
|
+
|
|
3787
|
+
// Initializing promise
|
|
3788
|
+
var deferred = q.defer();
|
|
3789
|
+
|
|
3790
|
+
// Validations
|
|
3791
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3792
|
+
if (error) {
|
|
3793
|
+
deferred.reject(error);
|
|
3794
|
+
} else {
|
|
3795
|
+
if (options && options.body) {
|
|
3796
|
+
// Passed all validations, Contruct API url
|
|
3797
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.customComponents;
|
|
3798
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
3799
|
+
|
|
3800
|
+
var requestAPI = request.post(url)
|
|
3801
|
+
.set('Content-Type', 'application/json')
|
|
3802
|
+
.set('Accept', 'application/json')
|
|
3803
|
+
.send(options.body);
|
|
3804
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
3805
|
+
|
|
3806
|
+
// Setup token in Authorization header
|
|
3807
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3808
|
+
|
|
3809
|
+
requestAPI
|
|
3810
|
+
.agent(keepaliveAgent)
|
|
3811
|
+
.end(function(error, response) {
|
|
3812
|
+
if (error) {
|
|
3813
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3814
|
+
deferred.reject(err);
|
|
3815
|
+
} else {
|
|
3816
|
+
deferred.resolve(response.body);
|
|
3817
|
+
}
|
|
3818
|
+
});
|
|
3819
|
+
} else {
|
|
3820
|
+
var err = {};
|
|
3821
|
+
err.message = err.description = 'Mandatory param - \'body\' not found in request options.';
|
|
3822
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
3823
|
+
deferred.reject(err);
|
|
3824
|
+
}
|
|
3825
|
+
}
|
|
3826
|
+
|
|
3827
|
+
return deferred.promise;
|
|
3828
|
+
}
|
|
3829
|
+
|
|
3830
|
+
/*
|
|
3831
|
+
options = {
|
|
3832
|
+
custom_component_code: "string", // Mandatory
|
|
3833
|
+
body : {
|
|
3834
|
+
title: "string",
|
|
3835
|
+
custom_component_type: "string",
|
|
3836
|
+
items: [{...}],
|
|
3837
|
+
data: {...}
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3840
|
+
*/
|
|
3841
|
+
function updateCustomComponent(options) {
|
|
3842
|
+
var self = this;
|
|
3843
|
+
|
|
3844
|
+
// Initializing promise
|
|
3845
|
+
var deferred = q.defer();
|
|
3846
|
+
|
|
3847
|
+
// Validations
|
|
3848
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3849
|
+
if (error) {
|
|
3850
|
+
deferred.reject(error);
|
|
3851
|
+
} else {
|
|
3852
|
+
if (options && options.custom_component_code && options.body) {
|
|
3853
|
+
if (Object.keys(options.body).length === 0) {
|
|
3854
|
+
error.message = error.description = 'Mandatory params: \'custom_component_code\' or \'body\' not found in the request options.';
|
|
3855
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3856
|
+
deferred.reject(error);
|
|
3857
|
+
} else {
|
|
3858
|
+
// Passed all validations, Contruct API url
|
|
3859
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.particularCustomComponent;
|
|
3860
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3861
|
+
orgid: self.orgId, custom_component_code: options.custom_component_code
|
|
3862
|
+
});
|
|
3863
|
+
|
|
3864
|
+
// Setup request with URL and Params
|
|
3865
|
+
var params = options.body;
|
|
3866
|
+
var requestAPI = request.put(url)
|
|
3867
|
+
.set('Content-Type', 'application/json')
|
|
3868
|
+
.set('Accept', 'application/json')
|
|
3869
|
+
.send(params);
|
|
3870
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
3871
|
+
|
|
3872
|
+
// Setup token in Authorization header
|
|
3873
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3874
|
+
|
|
3875
|
+
requestAPI
|
|
3876
|
+
.agent(keepaliveAgent)
|
|
3877
|
+
.end(function(error, response) {
|
|
3878
|
+
if (error) {
|
|
3879
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3880
|
+
deferred.reject(error);
|
|
3881
|
+
} else {
|
|
3882
|
+
deferred.resolve(response.body);
|
|
3883
|
+
}
|
|
3884
|
+
});
|
|
3885
|
+
}
|
|
3886
|
+
} else {
|
|
3887
|
+
error = {};
|
|
3888
|
+
error.message = error.description = 'Mandatory params: \'custom_component_code\' or \'body\' not found in the request options.';
|
|
3889
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3890
|
+
deferred.reject(error);
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
|
|
3894
|
+
return deferred.promise;
|
|
3895
|
+
}
|
|
3896
|
+
|
|
3897
|
+
/*
|
|
3898
|
+
options = {
|
|
3899
|
+
custom_component_code: "string", // Mandatory
|
|
3900
|
+
}
|
|
3901
|
+
*/
|
|
3902
|
+
function deleteCustomComponent(options) {
|
|
3903
|
+
var self = this;
|
|
3904
|
+
|
|
3905
|
+
// Initializing promise
|
|
3906
|
+
var deferred = q.defer();
|
|
3907
|
+
|
|
3908
|
+
// Validations
|
|
3909
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3910
|
+
if (error) {
|
|
3911
|
+
deferred.reject(error);
|
|
3912
|
+
} else {
|
|
3913
|
+
if (options && options.custom_component_code) {
|
|
3914
|
+
// Passed all validations, Contruct API url
|
|
3915
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.particularCustomComponent;
|
|
3916
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3917
|
+
orgid: self.orgId, custom_component_code: options.custom_component_code
|
|
3918
|
+
});
|
|
3919
|
+
|
|
3920
|
+
// Setup request with URL and Params
|
|
3921
|
+
var requestAPI = request.delete(url);
|
|
3922
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
3923
|
+
|
|
3924
|
+
// Setup token in Authorization header
|
|
3925
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3926
|
+
|
|
3927
|
+
requestAPI
|
|
3928
|
+
.agent(keepaliveAgent)
|
|
3929
|
+
.end(function (error, response) {
|
|
3930
|
+
if (error) {
|
|
3931
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3932
|
+
deferred.reject(err);
|
|
3933
|
+
} else {
|
|
3934
|
+
deferred.resolve(response.body);
|
|
3935
|
+
}
|
|
3936
|
+
});
|
|
3937
|
+
} else {
|
|
3938
|
+
var err = {};
|
|
3939
|
+
err.message = err.description = 'Mandatory params - \'custom_component_code\' not found in request options.';
|
|
3940
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
3941
|
+
deferred.reject(err);
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
3944
|
+
|
|
3945
|
+
return deferred.promise;
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3948
|
+
/*
|
|
3949
|
+
options = {
|
|
3950
|
+
custom_component_code: "string", // Mandatory
|
|
3951
|
+
}
|
|
3952
|
+
*/
|
|
3953
|
+
function getParticularCustomComponent(options) {
|
|
3954
|
+
var self = this;
|
|
3955
|
+
|
|
3956
|
+
// Initializing promise
|
|
3957
|
+
var deferred = q.defer();
|
|
3958
|
+
|
|
3959
|
+
// Validations
|
|
3960
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3961
|
+
if (err) {
|
|
3962
|
+
deferred.reject(err);
|
|
3963
|
+
} else {
|
|
3964
|
+
if (options && options.custom_component_code) {
|
|
3965
|
+
// Passed all validations, Contruct API url
|
|
3966
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.particularCustomComponent;
|
|
3967
|
+
|
|
3968
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3969
|
+
orgid: self.orgId, custom_component_code: options.custom_component_code
|
|
3970
|
+
});
|
|
3971
|
+
|
|
3972
|
+
// Setup request with URL and Params
|
|
3973
|
+
var requestAPI = request.get(url);
|
|
3974
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
3975
|
+
|
|
3976
|
+
// Setup token in Authorization header
|
|
3977
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3978
|
+
|
|
3979
|
+
requestAPI
|
|
3980
|
+
.agent(keepaliveAgent)
|
|
3981
|
+
.end(function(error, response) {
|
|
3982
|
+
if (error) {
|
|
3983
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3984
|
+
deferred.reject(error);
|
|
3985
|
+
} else {
|
|
3986
|
+
deferred.resolve(response.body);
|
|
3987
|
+
}
|
|
3988
|
+
});
|
|
3989
|
+
} else {
|
|
3990
|
+
var error = {};
|
|
3991
|
+
error.message = error.description = 'Mandatory params: \'custom_component_code\' not found in request options.';
|
|
3992
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3993
|
+
deferred.reject(error);
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
|
|
3997
|
+
return deferred.promise;
|
|
3998
|
+
}
|
|
3999
|
+
|
|
4000
|
+
/*
|
|
4001
|
+
options = {
|
|
4002
|
+
cursor: "string"
|
|
4003
|
+
}
|
|
4004
|
+
*/
|
|
4005
|
+
function getAllCustomComponents(options) {
|
|
4006
|
+
var self = this;
|
|
4007
|
+
|
|
4008
|
+
// Initializing promise
|
|
4009
|
+
var deferred = q.defer();
|
|
4010
|
+
|
|
4011
|
+
// Validations
|
|
4012
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
4013
|
+
if (error) {
|
|
4014
|
+
deferred.reject(error);
|
|
4015
|
+
} else {
|
|
4016
|
+
// Passed all validations, Contruct API url
|
|
4017
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.customComponents;
|
|
4018
|
+
url = helpers.api.constructAPIUrl(url, { orgid: self.orgId });
|
|
4019
|
+
|
|
4020
|
+
// Setup request with URL and Params
|
|
4021
|
+
var params = {};
|
|
4022
|
+
if (options.cursor) { params.cursor = options.cursor; }
|
|
4023
|
+
|
|
4024
|
+
var requestAPI = request.get(url).query(params);
|
|
4025
|
+
if (self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
4026
|
+
|
|
4027
|
+
// Setup token in Authorization header
|
|
4028
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
4029
|
+
|
|
4030
|
+
requestAPI
|
|
4031
|
+
.agent(keepaliveAgent)
|
|
4032
|
+
.end(function(error, response) {
|
|
4033
|
+
if (error) {
|
|
4034
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
4035
|
+
deferred.reject(error);
|
|
4036
|
+
} else {
|
|
4037
|
+
deferred.resolve(response.body);
|
|
4038
|
+
}
|
|
4039
|
+
});
|
|
4040
|
+
}
|
|
4041
|
+
|
|
4042
|
+
return deferred.promise;
|
|
4043
|
+
}
|