comprodls-sdk 2.34.3 → 2.35.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 +4706 -4070
- package/dist/comprodls-sdk.min.js +22 -21
- package/lib/config/index.js +8 -3
- package/lib/services/auth/index.js +630 -1
- package/package.json +1 -1
package/lib/config/index.js
CHANGED
|
@@ -206,8 +206,13 @@ exports.AUTH_API_URLS = {
|
|
|
206
206
|
//Data-Sync-Manager related APIs
|
|
207
207
|
createDataSyncManager: '/accounts/{accountid}/data-sync-managers',
|
|
208
208
|
dataSyncManager: '/accounts/{accountid}/data-sync-managers/{dsmid}',
|
|
209
|
-
getAllDataSyncManagersOfAGroup: '/accounts/{accountid}/dsm-groups/{dsm_groupid}/data-sync-managers'
|
|
209
|
+
getAllDataSyncManagersOfAGroup: '/accounts/{accountid}/dsm-groups/{dsm_groupid}/data-sync-managers',
|
|
210
210
|
|
|
211
|
+
//Gradebooks related APIs
|
|
212
|
+
createOrGetGradebookMeta: '/org/{orgId}/classes/{classId}/gradebooks',
|
|
213
|
+
updateOrDeleteGradebookMeta: '/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}',
|
|
214
|
+
gradebookColumns: '/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}/columns',
|
|
215
|
+
updateGradebookColumn: '/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}/columns/{column_id}'
|
|
211
216
|
};
|
|
212
217
|
|
|
213
218
|
exports.ACTIVITY_API_URLS = {
|
|
@@ -242,8 +247,8 @@ exports.ANALYTICS_API_URLS = {
|
|
|
242
247
|
getClassRecordUserAggregations: '/{orgId}/class/product/user-aggregations',
|
|
243
248
|
getUserClassRecentSubmissions: '/{orgId}/user/product/class/recent-submissions',
|
|
244
249
|
appState: '/{orgId}/user/product/progress/state',
|
|
245
|
-
getUserProductAllState: '/{
|
|
246
|
-
updateUserProductMultiState: '/{
|
|
250
|
+
getUserProductAllState: '/{orgId}/user/product/progress/state/all',
|
|
251
|
+
updateUserProductMultiState: '/{orgId}/user/product/progress/state/multi',
|
|
247
252
|
|
|
248
253
|
//AssignedPaths Related APIs
|
|
249
254
|
getAllAssignedPathsOfClass: '/{orgId}/class/assigned-paths',
|
|
@@ -102,7 +102,19 @@ function auth() {
|
|
|
102
102
|
deleteMultiUserGroupMembership: deleteMultiUserGroupMembership.bind(this),
|
|
103
103
|
getMyAllMemberships: getMyAllMemberships.bind(this),
|
|
104
104
|
archiveGroup: archiveGroup.bind(this),
|
|
105
|
-
unarchiveGroup: unarchiveGroup.bind(this)
|
|
105
|
+
unarchiveGroup: unarchiveGroup.bind(this),
|
|
106
|
+
|
|
107
|
+
//Gradeooks related APIs
|
|
108
|
+
createGradebookMeta: createGradebookMeta.bind(this),
|
|
109
|
+
updateGradebookMeta: updateGradebookMeta.bind(this),
|
|
110
|
+
deleteGradebookMeta: deleteGradebookMeta.bind(this),
|
|
111
|
+
getParticularGradebookMetaOfAClass: getParticularGradebookMetaOfAClass.bind(this),
|
|
112
|
+
getAllGradebooksMetaOfAClass: getAllGradebooksMetaOfAClass.bind(this),
|
|
113
|
+
addGradebookColumns: addGradebookColumns.bind(this),
|
|
114
|
+
updateGradebookColumn: updateGradebookColumn.bind(this),
|
|
115
|
+
removeGradebookColumns: removeGradebookColumns.bind(this),
|
|
116
|
+
getParticularColumnOfAGradebook: getParticularColumnOfAGradebook.bind(this),
|
|
117
|
+
getAllColumnsOfAGradebook: getAllColumnsOfAGradebook.bind(this)
|
|
106
118
|
};
|
|
107
119
|
}
|
|
108
120
|
|
|
@@ -1714,6 +1726,8 @@ function updateClass(options) {
|
|
|
1714
1726
|
/** options =
|
|
1715
1727
|
*{
|
|
1716
1728
|
"space_title": "string",
|
|
1729
|
+
"skip_email_to_actor": true/false, // optional, default false
|
|
1730
|
+
"ext_data": {}, // optional,
|
|
1717
1731
|
"classes": [
|
|
1718
1732
|
{
|
|
1719
1733
|
"title": "class tiltle",
|
|
@@ -2794,3 +2808,618 @@ function cloneClass(options) {
|
|
|
2794
2808
|
}
|
|
2795
2809
|
return dfd.promise;
|
|
2796
2810
|
}
|
|
2811
|
+
|
|
2812
|
+
/*
|
|
2813
|
+
options = {
|
|
2814
|
+
classid: "string", //mandatory
|
|
2815
|
+
body : {
|
|
2816
|
+
gradebook_id: "string", //mandatory
|
|
2817
|
+
title: "string", //mandatory
|
|
2818
|
+
data: {}
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
*/
|
|
2822
|
+
function createGradebookMeta(options) {
|
|
2823
|
+
var self = this;
|
|
2824
|
+
// Initializing promise
|
|
2825
|
+
var dfd = q.defer();
|
|
2826
|
+
|
|
2827
|
+
//Validations
|
|
2828
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
2829
|
+
if(error) {
|
|
2830
|
+
dfd.reject(error);
|
|
2831
|
+
} else {
|
|
2832
|
+
if(options && options.classid && options.body) {
|
|
2833
|
+
// Passed all validations, Contruct API url
|
|
2834
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.createOrGetGradebookMeta;
|
|
2835
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
2836
|
+
orgId: self.orgId, classId: options.classid
|
|
2837
|
+
});
|
|
2838
|
+
|
|
2839
|
+
var requestAPI = request.post(url)
|
|
2840
|
+
.set('Content-Type', 'application/json')
|
|
2841
|
+
.set('Accept', 'application/json')
|
|
2842
|
+
.send(options.body);
|
|
2843
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
2844
|
+
|
|
2845
|
+
//Setup token in Authorization header
|
|
2846
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
2847
|
+
|
|
2848
|
+
requestAPI
|
|
2849
|
+
.agent(keepaliveAgent)
|
|
2850
|
+
.end(function(error, response) {
|
|
2851
|
+
if(error) {
|
|
2852
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
2853
|
+
dfd.reject(err);
|
|
2854
|
+
}
|
|
2855
|
+
else { dfd.resolve(response.body); }
|
|
2856
|
+
});
|
|
2857
|
+
} else {
|
|
2858
|
+
var err = {};
|
|
2859
|
+
err.message = err.description = 'Mandatory param - classid or body' +
|
|
2860
|
+
' not found in request options.';
|
|
2861
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
2862
|
+
dfd.reject(err);
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
return dfd.promise;
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
/*
|
|
2870
|
+
options = {
|
|
2871
|
+
classid: "string", //mandatory
|
|
2872
|
+
gradebook_id: "string", //mandatory
|
|
2873
|
+
body : { //mandatory
|
|
2874
|
+
title: "string",
|
|
2875
|
+
data: {}
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
*/
|
|
2879
|
+
function updateGradebookMeta(options) {
|
|
2880
|
+
// Initializing promise
|
|
2881
|
+
var deferred = q.defer();
|
|
2882
|
+
var self = this;
|
|
2883
|
+
var error = {};
|
|
2884
|
+
|
|
2885
|
+
//Validations
|
|
2886
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
2887
|
+
if(err) {
|
|
2888
|
+
deferred.reject(err);
|
|
2889
|
+
} else {
|
|
2890
|
+
if (options && options.classid && options.gradebook_id && options.body) {
|
|
2891
|
+
if (Object.keys(options.body).length !== 0) {
|
|
2892
|
+
// Passed all validations, Contruct API url
|
|
2893
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.updateOrDeleteGradebookMeta;
|
|
2894
|
+
|
|
2895
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
2896
|
+
orgId: self.orgId, classId: options.classid, gradebook_id: options.gradebook_id
|
|
2897
|
+
});
|
|
2898
|
+
|
|
2899
|
+
var params = options.body;
|
|
2900
|
+
// Setup request with URL and Params
|
|
2901
|
+
var requestAPI = request.put(url)
|
|
2902
|
+
.set('Content-Type', 'application/json')
|
|
2903
|
+
.set('Accept', 'application/json')
|
|
2904
|
+
.send(params);
|
|
2905
|
+
|
|
2906
|
+
if (self.traceid) {
|
|
2907
|
+
requestAPI.set('X-Amzn-Trace-Id', self.traceid);
|
|
2908
|
+
}
|
|
2909
|
+
|
|
2910
|
+
//Setup token in Authorization header
|
|
2911
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
2912
|
+
|
|
2913
|
+
requestAPI
|
|
2914
|
+
.agent(keepaliveAgent)
|
|
2915
|
+
.end(function(error, response) {
|
|
2916
|
+
if (error) {
|
|
2917
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
2918
|
+
deferred.reject(error);
|
|
2919
|
+
} else {
|
|
2920
|
+
deferred.resolve(response.body);
|
|
2921
|
+
}
|
|
2922
|
+
});
|
|
2923
|
+
} else {
|
|
2924
|
+
error.message = error.description = 'Body of the request cannot be empty.';
|
|
2925
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
2926
|
+
deferred.reject(error);
|
|
2927
|
+
}
|
|
2928
|
+
} else {
|
|
2929
|
+
error.message = error.description = 'Mandatory params: classid, gradebook_id or body' +
|
|
2930
|
+
' not found in the request options.';
|
|
2931
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
2932
|
+
deferred.reject(error);
|
|
2933
|
+
}
|
|
2934
|
+
}
|
|
2935
|
+
|
|
2936
|
+
return deferred.promise;
|
|
2937
|
+
}
|
|
2938
|
+
|
|
2939
|
+
/*
|
|
2940
|
+
options = {
|
|
2941
|
+
classid: "string", //mandatory
|
|
2942
|
+
gradebook_id: "string" //mandatory
|
|
2943
|
+
}
|
|
2944
|
+
*/
|
|
2945
|
+
function deleteGradebookMeta(options) {
|
|
2946
|
+
var self = this;
|
|
2947
|
+
var dfd = q.defer();
|
|
2948
|
+
|
|
2949
|
+
//Validations
|
|
2950
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
2951
|
+
if(error) {
|
|
2952
|
+
dfd.reject(error);
|
|
2953
|
+
} else {
|
|
2954
|
+
if(options && options.classid && options.gradebook_id) {
|
|
2955
|
+
// Passed all validations, Contruct API url
|
|
2956
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.updateOrDeleteGradebookMeta;
|
|
2957
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
2958
|
+
orgId: self.orgId, classId: options.classid, gradebook_id: options.gradebook_id
|
|
2959
|
+
});
|
|
2960
|
+
|
|
2961
|
+
// Setup request with URL and Params
|
|
2962
|
+
var requestAPI = request.delete(url);
|
|
2963
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
2964
|
+
|
|
2965
|
+
//Setup token in Authorization header
|
|
2966
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
2967
|
+
|
|
2968
|
+
requestAPI
|
|
2969
|
+
.agent(keepaliveAgent)
|
|
2970
|
+
.end(function (error, response) {
|
|
2971
|
+
if(error) {
|
|
2972
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
2973
|
+
dfd.reject(err);
|
|
2974
|
+
}
|
|
2975
|
+
else { dfd.resolve(response.body); }
|
|
2976
|
+
});
|
|
2977
|
+
}
|
|
2978
|
+
else {
|
|
2979
|
+
var err = {};
|
|
2980
|
+
err.message = err.description = 'Mandatory params - classid or gradebook_id' +
|
|
2981
|
+
' not found in request options.';
|
|
2982
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
2983
|
+
dfd.reject(err);
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
return dfd.promise;
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
/*
|
|
2991
|
+
options = {
|
|
2992
|
+
classid: "string", //mandatory
|
|
2993
|
+
gradebook_id: "string" //mandatory
|
|
2994
|
+
}
|
|
2995
|
+
*/
|
|
2996
|
+
function getParticularGradebookMetaOfAClass(options) {
|
|
2997
|
+
// Initializing promise
|
|
2998
|
+
var deferred = q.defer();
|
|
2999
|
+
var self = this;
|
|
3000
|
+
|
|
3001
|
+
//Validations
|
|
3002
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3003
|
+
if(err) {
|
|
3004
|
+
deferred.reject(err);
|
|
3005
|
+
} else {
|
|
3006
|
+
if (options && options.classid && options.gradebook_id) {
|
|
3007
|
+
// Passed all validations, Contruct API url
|
|
3008
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
3009
|
+
self.config.AUTH_API_URLS.createOrGetGradebookMeta;
|
|
3010
|
+
|
|
3011
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3012
|
+
orgId: self.orgId, classId: options.classid
|
|
3013
|
+
});
|
|
3014
|
+
|
|
3015
|
+
// Setup request with URL and Params
|
|
3016
|
+
var params = {gradebook_id: options.gradebook_id};
|
|
3017
|
+
var requestAPI = request.get(url).query(params);
|
|
3018
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
3019
|
+
|
|
3020
|
+
//Setup token in Authorization header
|
|
3021
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3022
|
+
|
|
3023
|
+
requestAPI
|
|
3024
|
+
.agent(keepaliveAgent)
|
|
3025
|
+
.end(function(error, response) {
|
|
3026
|
+
if (error) {
|
|
3027
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3028
|
+
deferred.reject(error);
|
|
3029
|
+
} else {
|
|
3030
|
+
deferred.resolve(response.body.entities[0]);
|
|
3031
|
+
}
|
|
3032
|
+
});
|
|
3033
|
+
} else {
|
|
3034
|
+
var error = {};
|
|
3035
|
+
error.message = error.description = 'Mandatory params: classid or gradebook_id' +
|
|
3036
|
+
' not found in request options.';
|
|
3037
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3038
|
+
deferred.reject(error);
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
return deferred.promise;
|
|
3043
|
+
}
|
|
3044
|
+
|
|
3045
|
+
/*
|
|
3046
|
+
options = {
|
|
3047
|
+
classid: "string", //mandatory
|
|
3048
|
+
cursor: "string"
|
|
3049
|
+
}
|
|
3050
|
+
*/
|
|
3051
|
+
function getAllGradebooksMetaOfAClass (options) {
|
|
3052
|
+
// Initializing promise
|
|
3053
|
+
var deferred = q.defer();
|
|
3054
|
+
var self = this;
|
|
3055
|
+
|
|
3056
|
+
//Validations
|
|
3057
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3058
|
+
if(err) {
|
|
3059
|
+
deferred.reject(err);
|
|
3060
|
+
} else {
|
|
3061
|
+
if (options && options.classid) {
|
|
3062
|
+
// Passed all validations, Contruct API url
|
|
3063
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.createOrGetGradebookMeta;
|
|
3064
|
+
|
|
3065
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3066
|
+
orgId: self.orgId, classId: options.classid
|
|
3067
|
+
});
|
|
3068
|
+
|
|
3069
|
+
// Setup request with URL and Params
|
|
3070
|
+
var params = {};
|
|
3071
|
+
if(options.cursor){ params.cursor = options.cursor; }
|
|
3072
|
+
|
|
3073
|
+
var requestAPI = request.get(url).query(params);
|
|
3074
|
+
|
|
3075
|
+
if (self.traceid) {
|
|
3076
|
+
requestAPI.set('X-Amzn-Trace-Id', self.traceid);
|
|
3077
|
+
}
|
|
3078
|
+
|
|
3079
|
+
//Setup token in Authorization header
|
|
3080
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3081
|
+
|
|
3082
|
+
requestAPI
|
|
3083
|
+
.agent(keepaliveAgent)
|
|
3084
|
+
.end(function(error, response) {
|
|
3085
|
+
if (error) {
|
|
3086
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3087
|
+
deferred.reject(error);
|
|
3088
|
+
} else {
|
|
3089
|
+
deferred.resolve(response.body);
|
|
3090
|
+
}
|
|
3091
|
+
});
|
|
3092
|
+
} else {
|
|
3093
|
+
var error = {};
|
|
3094
|
+
error.message = error.description = 'Mandatory params: classid not found in request options.';
|
|
3095
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3096
|
+
deferred.reject(error);
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
return deferred.promise;
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
/*
|
|
3103
|
+
options = {
|
|
3104
|
+
classid: "string", //mandatory
|
|
3105
|
+
gradebook_id: "string", //mandatory
|
|
3106
|
+
body : {
|
|
3107
|
+
"columns": [
|
|
3108
|
+
{
|
|
3109
|
+
"column_id": "string", // Mandatory
|
|
3110
|
+
"title": "string",
|
|
3111
|
+
"type": "product / custom",
|
|
3112
|
+
"weightage": "string",
|
|
3113
|
+
"bundle-codes": [],
|
|
3114
|
+
"productcode": "string",
|
|
3115
|
+
"custom_component_code": "string",
|
|
3116
|
+
"items": [
|
|
3117
|
+
{
|
|
3118
|
+
"item-code": "string"
|
|
3119
|
+
}
|
|
3120
|
+
],
|
|
3121
|
+
"data": {...}
|
|
3122
|
+
}
|
|
3123
|
+
]
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
*/
|
|
3127
|
+
function addGradebookColumns(options) {
|
|
3128
|
+
var self = this;
|
|
3129
|
+
// Initializing promise
|
|
3130
|
+
var dfd = q.defer();
|
|
3131
|
+
|
|
3132
|
+
//Validations
|
|
3133
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3134
|
+
if(error) {
|
|
3135
|
+
dfd.reject(error);
|
|
3136
|
+
} else {
|
|
3137
|
+
if(options && options.classid && options.gradebook_id && options.body) {
|
|
3138
|
+
// Passed all validations, Contruct API url
|
|
3139
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.gradebookColumns;
|
|
3140
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3141
|
+
orgId: self.orgId, classId: options.classid, gradebook_id: options.gradebook_id
|
|
3142
|
+
});
|
|
3143
|
+
|
|
3144
|
+
var requestAPI = request.post(url)
|
|
3145
|
+
.set('Content-Type', 'application/json')
|
|
3146
|
+
.set('Accept', 'application/json')
|
|
3147
|
+
.send(options.body);
|
|
3148
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
3149
|
+
|
|
3150
|
+
//Setup token in Authorization header
|
|
3151
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3152
|
+
|
|
3153
|
+
requestAPI
|
|
3154
|
+
.agent(keepaliveAgent)
|
|
3155
|
+
.end(function(error, response) {
|
|
3156
|
+
if(error) {
|
|
3157
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3158
|
+
dfd.reject(err);
|
|
3159
|
+
}
|
|
3160
|
+
else { dfd.resolve(response.body); }
|
|
3161
|
+
});
|
|
3162
|
+
} else {
|
|
3163
|
+
var err = {};
|
|
3164
|
+
err.message = err.description = 'Mandatory param - classid, gradebook_id or body' +
|
|
3165
|
+
' not found in request options.';
|
|
3166
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
3167
|
+
dfd.reject(err);
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
return dfd.promise;
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3173
|
+
/*
|
|
3174
|
+
options = {
|
|
3175
|
+
classid: "string", //mandatory
|
|
3176
|
+
gradebook_id: "string", //mandatory
|
|
3177
|
+
column_id: "string", //mandatory
|
|
3178
|
+
body : {
|
|
3179
|
+
"title": "string",
|
|
3180
|
+
"weightage": "string",
|
|
3181
|
+
"items": [
|
|
3182
|
+
{
|
|
3183
|
+
"item-code": "string"
|
|
3184
|
+
}
|
|
3185
|
+
],
|
|
3186
|
+
"data": {...}
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
*/
|
|
3190
|
+
function updateGradebookColumn(options) {
|
|
3191
|
+
// Initializing promise
|
|
3192
|
+
var deferred = q.defer();
|
|
3193
|
+
var self = this;
|
|
3194
|
+
var error = {};
|
|
3195
|
+
|
|
3196
|
+
//Validations
|
|
3197
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3198
|
+
if(err) {
|
|
3199
|
+
deferred.reject(err);
|
|
3200
|
+
} else {
|
|
3201
|
+
if (options && options.classid && options.gradebook_id && options.column_id && options.body) {
|
|
3202
|
+
if (Object.keys(options.body).length !== 0) {
|
|
3203
|
+
// Passed all validations, Contruct API url
|
|
3204
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.updateGradebookColumn;
|
|
3205
|
+
|
|
3206
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3207
|
+
orgId: self.orgId,
|
|
3208
|
+
classId: options.classid,
|
|
3209
|
+
gradebook_id: options.gradebook_id,
|
|
3210
|
+
column_id: options.column_id
|
|
3211
|
+
});
|
|
3212
|
+
|
|
3213
|
+
var params = options.body;
|
|
3214
|
+
// Setup request with URL and Params
|
|
3215
|
+
var requestAPI = request.put(url)
|
|
3216
|
+
.set('Content-Type', 'application/json')
|
|
3217
|
+
.set('Accept', 'application/json')
|
|
3218
|
+
.send(params);
|
|
3219
|
+
|
|
3220
|
+
if (self.traceid) {
|
|
3221
|
+
requestAPI.set('X-Amzn-Trace-Id', self.traceid);
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
//Setup token in Authorization header
|
|
3225
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3226
|
+
|
|
3227
|
+
requestAPI
|
|
3228
|
+
.agent(keepaliveAgent)
|
|
3229
|
+
.end(function(error, response) {
|
|
3230
|
+
if (error) {
|
|
3231
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3232
|
+
deferred.reject(error);
|
|
3233
|
+
} else {
|
|
3234
|
+
deferred.resolve(response.body);
|
|
3235
|
+
}
|
|
3236
|
+
});
|
|
3237
|
+
} else {
|
|
3238
|
+
error.message = error.description = 'Body of the request input cannot be empty.';
|
|
3239
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3240
|
+
deferred.reject(error);
|
|
3241
|
+
}
|
|
3242
|
+
} else {
|
|
3243
|
+
error.message = error.description = 'Mandatory params: classid, gradebook_id, column_id or body' +
|
|
3244
|
+
' not found in the request options.';
|
|
3245
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3246
|
+
deferred.reject(error);
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
return deferred.promise;
|
|
3250
|
+
}
|
|
3251
|
+
|
|
3252
|
+
/*
|
|
3253
|
+
options = {
|
|
3254
|
+
classid: "string", //mandatory
|
|
3255
|
+
gradebook_id: "string", //mandatory
|
|
3256
|
+
body : {
|
|
3257
|
+
"columns": [
|
|
3258
|
+
{
|
|
3259
|
+
"column_id": "string", // Mandatory
|
|
3260
|
+
}
|
|
3261
|
+
]
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
*/
|
|
3265
|
+
function removeGradebookColumns(options) {
|
|
3266
|
+
var self = this;
|
|
3267
|
+
var dfd = q.defer();
|
|
3268
|
+
|
|
3269
|
+
//Validations
|
|
3270
|
+
var error = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3271
|
+
if(error) {
|
|
3272
|
+
dfd.reject(error);
|
|
3273
|
+
} else {
|
|
3274
|
+
if(options && options.classid && options.gradebook_id && options.body) {
|
|
3275
|
+
// Passed all validations, Contruct API url
|
|
3276
|
+
var url = self.config.DEFAULT_HOSTS.AUTH + self.config.AUTH_API_URLS.gradebookColumns;
|
|
3277
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3278
|
+
orgId: self.orgId, classId: options.classid, gradebook_id: options.gradebook_id
|
|
3279
|
+
});
|
|
3280
|
+
|
|
3281
|
+
// Setup request with URL and Params
|
|
3282
|
+
var requestAPI = request.delete(url)
|
|
3283
|
+
.set('Content-Type', 'application/json')
|
|
3284
|
+
.set('Accept', 'application/json')
|
|
3285
|
+
.send(options.body);
|
|
3286
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
3287
|
+
|
|
3288
|
+
//Setup token in Authorization header
|
|
3289
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3290
|
+
|
|
3291
|
+
requestAPI
|
|
3292
|
+
.agent(keepaliveAgent)
|
|
3293
|
+
.end(function (error, response) {
|
|
3294
|
+
if(error) {
|
|
3295
|
+
var err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3296
|
+
dfd.reject(err);
|
|
3297
|
+
}
|
|
3298
|
+
else { dfd.resolve(response.body); }
|
|
3299
|
+
});
|
|
3300
|
+
}
|
|
3301
|
+
else {
|
|
3302
|
+
var err = {};
|
|
3303
|
+
err.message = err.description = 'Mandatory params - classid, gradebook_id or body' +
|
|
3304
|
+
' not found in request options.';
|
|
3305
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
3306
|
+
dfd.reject(err);
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
return dfd.promise;
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3312
|
+
/*
|
|
3313
|
+
options = {
|
|
3314
|
+
classid: "string", //mandatory
|
|
3315
|
+
gradebook_id: "string", //mandatory
|
|
3316
|
+
column_id: "string" //mandatory
|
|
3317
|
+
}
|
|
3318
|
+
*/
|
|
3319
|
+
function getParticularColumnOfAGradebook (options) {
|
|
3320
|
+
// Initializing promise
|
|
3321
|
+
var deferred = q.defer();
|
|
3322
|
+
var self = this;
|
|
3323
|
+
|
|
3324
|
+
//Validations
|
|
3325
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3326
|
+
if(err) {
|
|
3327
|
+
deferred.reject(err);
|
|
3328
|
+
} else {
|
|
3329
|
+
if (options && options.classid && options.gradebook_id && options.column_id) {
|
|
3330
|
+
// Passed all validations, Contruct API url
|
|
3331
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
3332
|
+
self.config.AUTH_API_URLS.gradebookColumns ;
|
|
3333
|
+
|
|
3334
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3335
|
+
orgId: self.orgId, classId: options.classid, gradebook_id: options.gradebook_id
|
|
3336
|
+
});
|
|
3337
|
+
|
|
3338
|
+
// Setup request with URL and Params
|
|
3339
|
+
var params = {column_id: options.column_id};
|
|
3340
|
+
var requestAPI = request.get(url).query(params);
|
|
3341
|
+
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
3342
|
+
|
|
3343
|
+
//Setup token in Authorization header
|
|
3344
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3345
|
+
|
|
3346
|
+
requestAPI
|
|
3347
|
+
.agent(keepaliveAgent)
|
|
3348
|
+
.end(function(error, response) {
|
|
3349
|
+
if (error) {
|
|
3350
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3351
|
+
deferred.reject(error);
|
|
3352
|
+
} else {
|
|
3353
|
+
deferred.resolve(response.body.entities[0]);
|
|
3354
|
+
}
|
|
3355
|
+
});
|
|
3356
|
+
} else {
|
|
3357
|
+
var error = {};
|
|
3358
|
+
error.message = error.description = 'Mandatory params: classid, gradebook_id or column_id' +
|
|
3359
|
+
' not found in request options.';
|
|
3360
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3361
|
+
deferred.reject(error);
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
return deferred.promise;
|
|
3365
|
+
}
|
|
3366
|
+
|
|
3367
|
+
/*
|
|
3368
|
+
options = {
|
|
3369
|
+
classid: "string", //mandatory
|
|
3370
|
+
gradebook_id: "string", //mandatory
|
|
3371
|
+
cursor: "string" //optional
|
|
3372
|
+
}
|
|
3373
|
+
*/
|
|
3374
|
+
function getAllColumnsOfAGradebook (options) {
|
|
3375
|
+
// Initializing promise
|
|
3376
|
+
var deferred = q.defer();
|
|
3377
|
+
var self = this;
|
|
3378
|
+
|
|
3379
|
+
//Validations
|
|
3380
|
+
var err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
3381
|
+
if(err) {
|
|
3382
|
+
deferred.reject(err);
|
|
3383
|
+
} else {
|
|
3384
|
+
if (options && options.classid && options.gradebook_id) {
|
|
3385
|
+
// Passed all validations, Contruct API url
|
|
3386
|
+
var url = self.config.DEFAULT_HOSTS.AUTH +
|
|
3387
|
+
self.config.AUTH_API_URLS.gradebookColumns ;
|
|
3388
|
+
|
|
3389
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
3390
|
+
orgId: self.orgId, classId: options.classid, gradebook_id: options.gradebook_id
|
|
3391
|
+
});
|
|
3392
|
+
|
|
3393
|
+
// Setup request with URL and Params
|
|
3394
|
+
var params = {};
|
|
3395
|
+
if(options.cursor){ params.cursor = options.cursor; }
|
|
3396
|
+
|
|
3397
|
+
var requestAPI = request.get(url).query(params);
|
|
3398
|
+
|
|
3399
|
+
if (self.traceid) {
|
|
3400
|
+
requestAPI.set('X-Amzn-Trace-Id', self.traceid);
|
|
3401
|
+
}
|
|
3402
|
+
|
|
3403
|
+
//Setup token in Authorization header
|
|
3404
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
3405
|
+
|
|
3406
|
+
requestAPI
|
|
3407
|
+
.agent(keepaliveAgent)
|
|
3408
|
+
.end(function(error, response) {
|
|
3409
|
+
if (error) {
|
|
3410
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
3411
|
+
deferred.reject(error);
|
|
3412
|
+
} else {
|
|
3413
|
+
deferred.resolve(response.body);
|
|
3414
|
+
}
|
|
3415
|
+
});
|
|
3416
|
+
} else {
|
|
3417
|
+
var error = {};
|
|
3418
|
+
error.message = error.description = 'Mandatory params: classid or gradebook_id' +
|
|
3419
|
+
' not found in request options.';
|
|
3420
|
+
error = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, error);
|
|
3421
|
+
deferred.reject(error);
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
return deferred.promise;
|
|
3425
|
+
}
|