@stackfactor/client-api 1.0.32 → 1.0.34

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.
@@ -1,255 +1,254 @@
1
- import { axios } from "./axiosClient";
1
+ import axios from "./axiosClient";
2
2
 
3
- module.exports = {
4
- axios: axios,
5
-
6
- /**
7
- * Create learning content and set information
8
- * @param {Object} data Learning content data
9
- * @param {String} token Authorization token
10
- * @returns {Promise<Object>} The created learning content
11
- */
12
- createLearningContent: (data, token) => {
13
- return new Promise(function (resolve, reject) {
14
- const requestData = {
15
- data: data,
16
- };
17
- let confirmationRequest = axios.put(
18
- "api/v1/learningcontent",
19
- requestData,
20
- { headers: { authorization: token } }
21
- );
22
- confirmationRequest
23
- .then((response) => {
24
- resolve(response.data);
25
- })
26
- .catch((error) => {
27
- reject(error);
28
- });
3
+ /**
4
+ * Create learning content and set information
5
+ * @param {Object} data Learning content data
6
+ * @param {String} token Authorization token
7
+ * @returns {Promise<Object>} The created learning content
8
+ */
9
+ export const createLearningContent = (data, token) => {
10
+ return new Promise(function (resolve, reject) {
11
+ const requestData = {
12
+ data: data,
13
+ };
14
+ let confirmationRequest = axios.put("api/v1/learningcontent", requestData, {
15
+ headers: { authorization: token },
29
16
  });
30
- },
17
+ confirmationRequest
18
+ .then((response) => {
19
+ resolve(response.data);
20
+ })
21
+ .catch((error) => {
22
+ reject(error);
23
+ });
24
+ });
25
+ };
31
26
 
32
- /**
33
- * Delete learning content
34
- * @param {String} id The id of the learning content to be deleted
35
- * @param {String} comment The comment included with the deletion
36
- * @param {String} token Authorization token
37
- * @returns {Promise<Object>} The response from the server
38
- */
39
- deleteLearningContent: (id, comment, token) => {
40
- const data = {
41
- id: id,
42
- };
43
- if (comment) data.comment = comment;
44
- return new Promise(function (resolve, reject) {
45
- const request = axios.delete(`api/v1/learningcontent/`, {
46
- headers: { authorization: token },
47
- data: data,
27
+ /**
28
+ * Delete learning content
29
+ * @param {String} id The id of the learning content to be deleted
30
+ * @param {String} comment The comment included with the deletion
31
+ * @param {String} token Authorization token
32
+ * @returns {Promise<Object>} The response from the server
33
+ */
34
+ export const deleteLearningContent = (id, comment, token) => {
35
+ const data = {
36
+ id: id,
37
+ };
38
+ if (comment) data.comment = comment;
39
+ return new Promise(function (resolve, reject) {
40
+ const request = axios.delete(`api/v1/learningcontent/`, {
41
+ headers: { authorization: token },
42
+ data: data,
43
+ });
44
+ request
45
+ .then((response) => {
46
+ resolve(response.data);
47
+ })
48
+ .catch((error) => {
49
+ reject(error);
48
50
  });
49
- request
50
- .then((response) => {
51
- resolve(response.data);
52
- })
53
- .catch((error) => {
54
- reject(error);
55
- });
51
+ });
52
+ };
53
+
54
+ /**
55
+ * Discard the learning content draft changes
56
+ * @param {String} id The id of the learning content to be deleted
57
+ * @param {String} token Authorization token
58
+ * @returns {Promise<Object>} The response from the server
59
+ */
60
+ export const discardLearningContentChanges = (id, token) => {
61
+ return new Promise(function (resolve, reject) {
62
+ const data = {};
63
+ const request = axios.get(`api/v1/learningcontent/discard/${id}`, {
64
+ headers: { authorization: token },
65
+ data: data,
56
66
  });
57
- },
67
+ request
68
+ .then((response) => {
69
+ resolve(response.data);
70
+ })
71
+ .catch((error) => {
72
+ reject(error);
73
+ });
74
+ });
75
+ };
58
76
 
59
- /**
60
- * Discard the learning content draft changes
61
- * @param {String} id The id of the learning content to be deleted
62
- * @param {String} token Authorization token
63
- * @returns {Promise<Object>} The response from the server
64
- */
65
- discardLearningContentChanges: (id, token) => {
66
- return new Promise(function (resolve, reject) {
67
- const data = {};
68
- const request = axios.get(`api/v1/learningcontent/discard/${id}`, {
77
+ /**
78
+ * Get the learning content information by id
79
+ * @param {String} id The id of the learning content
80
+ * @param {String} version The version of the learning content
81
+ * @param {String} token Authorization token
82
+ * @returns {Promise<Object>} The response from the server
83
+ */
84
+ export const getLearningContentInformationById = (id, version, token) => {
85
+ return new Promise(function (resolve, reject) {
86
+ let confirmationRequest = axios.get(
87
+ `api/v1/learningcontent/${id}/${version}`,
88
+ {
69
89
  headers: { authorization: token },
70
- data: data,
90
+ }
91
+ );
92
+ confirmationRequest
93
+ .then((response) => {
94
+ resolve(response.data);
95
+ })
96
+ .catch((error) => {
97
+ reject(error);
71
98
  });
72
- request
73
- .then((response) => {
74
- resolve(response.data);
75
- })
76
- .catch((error) => {
77
- reject(error);
78
- });
79
- });
80
- },
81
-
82
- /**
83
- * Get the learning content information by id
84
- * @param {String} id The id of the learning content
85
- * @param {String} version The version of the learning content
86
- * @param {String} token Authorization token
87
- * @returns {Promise<Object>} The response from the server
88
- */
89
- getLearningContentInformationById: (id, version, token) => {
90
- return new Promise(function (resolve, reject) {
91
- let confirmationRequest = axios.get(
92
- `api/v1/learningcontent/${id}/${version}`,
93
- {
94
- headers: { authorization: token },
95
- }
96
- );
97
- confirmationRequest
98
- .then((response) => {
99
- resolve(response.data);
100
- })
101
- .catch((error) => {
102
- reject(error);
103
- });
104
- });
105
- },
99
+ });
100
+ };
106
101
 
107
- /**
108
- * Get the list of available content types
109
- * @param {Array<String>} filter The filter used to select the learning content
110
- * @param {String} version The version to be retrieved
111
- * @param {boolean} includeDeleted When true it will return the deleted records as well
112
- * @param {String} token Authorization token
113
- * @returns {Promise<Array<Object>>} The list of available content
114
- */
115
- getLearningContentList: (filter, version, includeDeleted, token) => {
116
- return new Promise(function (resolve, reject) {
117
- const requestData = {
118
- version: version,
119
- includeDeleted: includeDeleted,
120
- };
121
- if (filter) requestData.filter = filter;
122
- let confirmationRequest = axios.post(
123
- `api/v1/learningcontent`,
124
- requestData,
125
- {
126
- headers: { authorization: token },
127
- }
128
- );
129
- confirmationRequest
130
- .then((response) => {
131
- resolve(response.data);
132
- })
133
- .catch((error) => {
134
- reject(error);
135
- });
136
- });
137
- },
102
+ /**
103
+ * Get the list of available content types
104
+ * @param {Array<String>} filter The filter used to select the learning content
105
+ * @param {String} version The version to be retrieved
106
+ * @param {boolean} includeDeleted When true it will return the deleted records as well
107
+ * @param {String} token Authorization token
108
+ * @returns {Promise<Array<Object>>} The list of available content
109
+ */
110
+ export const getLearningContentList = (
111
+ filter,
112
+ version,
113
+ includeDeleted,
114
+ token
115
+ ) => {
116
+ return new Promise(function (resolve, reject) {
117
+ const requestData = {
118
+ version: version,
119
+ includeDeleted: includeDeleted,
120
+ };
121
+ if (filter) requestData.filter = filter;
122
+ let confirmationRequest = axios.post(
123
+ `api/v1/learningcontent`,
124
+ requestData,
125
+ {
126
+ headers: { authorization: token },
127
+ }
128
+ );
129
+ confirmationRequest
130
+ .then((response) => {
131
+ resolve(response.data);
132
+ })
133
+ .catch((error) => {
134
+ reject(error);
135
+ });
136
+ });
137
+ };
138
138
 
139
- /**
140
- * Publish learning content
141
- * @param {String} id The id of the content to be published
142
- * @param {String} comment The comment to be include with the request
143
- * @param {String} token Authorization token
144
- * @returns {Promise<Object>} The response from the server
145
- */
146
- publishLearningContent: (id, comment, token) => {
147
- return new Promise(function (resolve, reject) {
148
- let data = {};
149
- if (comment) data.comment = comment;
139
+ /**
140
+ * Publish learning content
141
+ * @param {String} id The id of the content to be published
142
+ * @param {String} comment The comment to be include with the request
143
+ * @param {String} token Authorization token
144
+ * @returns {Promise<Object>} The response from the server
145
+ */
146
+ export const publishLearningContent = (id, comment, token) => {
147
+ return new Promise(function (resolve, reject) {
148
+ let data = {};
149
+ if (comment) data.comment = comment;
150
150
 
151
- let confirmationRequest = axios.post(
152
- `api/v1/learningcontent/publish/${id}`,
153
- data,
154
- {
155
- headers: { authorization: token },
156
- }
157
- );
158
- confirmationRequest
159
- .then((response) => {
160
- resolve(response.data);
161
- })
162
- .catch((error) => {
163
- reject(error);
164
- });
165
- });
166
- },
151
+ let confirmationRequest = axios.post(
152
+ `api/v1/learningcontent/publish/${id}`,
153
+ data,
154
+ {
155
+ headers: { authorization: token },
156
+ }
157
+ );
158
+ confirmationRequest
159
+ .then((response) => {
160
+ resolve(response.data);
161
+ })
162
+ .catch((error) => {
163
+ reject(error);
164
+ });
165
+ });
166
+ };
167
167
 
168
- /**
169
- * Set learning content information
170
- * @param {String} id The id of the learning content to be updated
171
- * @param {Object} data Data used to update the learning content
172
- * @param {String} token Authorization token
173
- * @returns {Promise<Object>} The updated learning content
174
- */
175
- setLearningContentInformation: (id, data, token) => {
176
- return new Promise(function (resolve, reject) {
177
- const requestData = {
178
- data: data,
179
- id: id,
180
- };
181
- let confirmationRequest = axios.post(
182
- `api/v1/learningcontent/update`,
183
- requestData,
184
- {
185
- headers: { authorization: token },
186
- }
187
- );
188
- confirmationRequest
189
- .then((response) => {
190
- resolve(response.data);
191
- })
192
- .catch((error) => {
193
- reject(error);
194
- });
195
- });
196
- },
168
+ /**
169
+ * Set learning content information
170
+ * @param {String} id The id of the learning content to be updated
171
+ * @param {Object} data Data used to update the learning content
172
+ * @param {String} token Authorization token
173
+ * @returns {Promise<Object>} The updated learning content
174
+ */
175
+ export const setLearningContentInformation = (id, data, token) => {
176
+ return new Promise(function (resolve, reject) {
177
+ const requestData = {
178
+ data: data,
179
+ id: id,
180
+ };
181
+ let confirmationRequest = axios.post(
182
+ `api/v1/learningcontent/update`,
183
+ requestData,
184
+ {
185
+ headers: { authorization: token },
186
+ }
187
+ );
188
+ confirmationRequest
189
+ .then((response) => {
190
+ resolve(response.data);
191
+ })
192
+ .catch((error) => {
193
+ reject(error);
194
+ });
195
+ });
196
+ };
197
197
 
198
- /**
199
- * Update the learning content tags
200
- * @param {String} id The id of the learning to be updated
201
- * @param {Object} tags Updated learning content tags
202
- * @param {String} token Authorization token
203
- */
204
- setLearningContentTags: (id, tags, token) => {
205
- return new Promise(function (resolve, reject) {
206
- const requestData = {
207
- tags: tags,
208
- id: id,
209
- };
210
- let confirmationRequest = axios.post(
211
- `api/v1/learningcontent/updatetags/`,
212
- requestData,
213
- {
214
- headers: { authorization: token },
215
- }
216
- );
217
- confirmationRequest
218
- .then((response) => {
219
- resolve(response.data);
220
- })
221
- .catch((error) => {
222
- reject(error);
223
- });
224
- });
225
- },
198
+ /**
199
+ * Update the learning content tags
200
+ * @param {String} id The id of the learning to be updated
201
+ * @param {Object} tags Updated learning content tags
202
+ * @param {String} token Authorization token
203
+ */
204
+ export const setLearningContentTags = (id, tags, token) => {
205
+ return new Promise(function (resolve, reject) {
206
+ const requestData = {
207
+ tags: tags,
208
+ id: id,
209
+ };
210
+ let confirmationRequest = axios.post(
211
+ `api/v1/learningcontent/updatetags/`,
212
+ requestData,
213
+ {
214
+ headers: { authorization: token },
215
+ }
216
+ );
217
+ confirmationRequest
218
+ .then((response) => {
219
+ resolve(response.data);
220
+ })
221
+ .catch((error) => {
222
+ reject(error);
223
+ });
224
+ });
225
+ };
226
226
 
227
- /**
228
- * Watch learning content
229
- * @param {String} id The id of the learning content to be updated
230
- * @param {Boolean} watch Set to true or false
231
- * @param {String} token Authorization token
232
- */
233
- watchLearningContent: (id, watch, token) => {
234
- return new Promise(function (resolve, reject) {
235
- const requestData = {
236
- id: id,
237
- watch: watch,
238
- };
239
- let confirmationRequest = axios.post(
240
- `api/v1/learningcontent/watch`,
241
- requestData,
242
- {
243
- headers: { authorization: token },
244
- }
245
- );
246
- confirmationRequest
247
- .then((response) => {
248
- resolve(response.data);
249
- })
250
- .catch((error) => {
251
- reject(error);
252
- });
253
- });
254
- },
227
+ /**
228
+ * Watch learning content
229
+ * @param {String} id The id of the learning content to be updated
230
+ * @param {Boolean} watch Set to true or false
231
+ * @param {String} token Authorization token
232
+ */
233
+ export const watchLearningContent = (id, watch, token) => {
234
+ return new Promise(function (resolve, reject) {
235
+ const requestData = {
236
+ id: id,
237
+ watch: watch,
238
+ };
239
+ let confirmationRequest = axios.post(
240
+ `api/v1/learningcontent/watch`,
241
+ requestData,
242
+ {
243
+ headers: { authorization: token },
244
+ }
245
+ );
246
+ confirmationRequest
247
+ .then((response) => {
248
+ resolve(response.data);
249
+ })
250
+ .catch((error) => {
251
+ reject(error);
252
+ });
253
+ });
255
254
  };
package/lib/logger.js CHANGED
@@ -1,61 +1,56 @@
1
- import { axios } from "./axiosClient";
1
+ import axios from "./axiosClient";
2
2
 
3
- module.exports = {
4
- axios: axios,
5
-
6
- /**
7
- * Create a comment for a specified element id
8
- * @param {String} elementId
9
- * @param {String} elementType
10
- * @param {Object} data
11
- * @param {String} token Authorization token
12
- */
13
- comment: (elementId, elementType, data, token) => {
14
- return new Promise(function (resolve, reject) {
15
- let confirmationRequest = axios.post(
16
- "api/v1/logger/comment/",
17
- {
18
- data: data,
19
- elementId: elementId,
20
- elementType: elementType,
21
- },
22
- {
23
- headers: { authorization: token },
24
- }
25
- );
26
- confirmationRequest
27
- .then((response) => {
28
- resolve(response.data);
29
- })
30
- .catch((error) => {
31
- reject(error);
32
- });
33
- });
34
- },
35
-
36
- /**
37
- * Get the list of logger entries for selected element
38
- * @param {String} elementId
39
- * @param {Number} page The results page
40
- * @param {Number} elementsPerPage The number of elements per page
41
- * @param {String} token
42
- * @returns
43
- */
44
- getListByElementId: (elementId, page, elementsPerPage, token) => {
45
- return new Promise(function (resolve, reject) {
46
- let data = {};
47
- if (elementsPerPage !== null) data.elementsPerPage = elementsPerPage;
48
- if (page !== null) data.page = page;
49
- const getTokensRequest = axios.post(`api/v1/logger/${elementId}`, data, {
3
+ /**
4
+ * Create a comment for a specified element id
5
+ * @param {String} elementId
6
+ * @param {String} elementType
7
+ * @param {Object} data
8
+ * @param {String} token Authorization token
9
+ */
10
+ export const comment = (elementId, elementType, data, token) => {
11
+ return new Promise(function (resolve, reject) {
12
+ let confirmationRequest = axios.post(
13
+ "api/v1/logger/comment/",
14
+ {
15
+ data: data,
16
+ elementId: elementId,
17
+ elementType: elementType,
18
+ },
19
+ {
50
20
  headers: { authorization: token },
21
+ }
22
+ );
23
+ confirmationRequest
24
+ .then((response) => {
25
+ resolve(response.data);
26
+ })
27
+ .catch((error) => {
28
+ reject(error);
51
29
  });
52
- getTokensRequest
53
- .then((result) => {
54
- resolve(result.data);
55
- })
56
- .catch((error) => {
57
- reject(error);
58
- });
30
+ });
31
+ };
32
+
33
+ /**
34
+ * Get the list of logger entries for selected element
35
+ * @param {String} elementId
36
+ * @param {Number} page The results page
37
+ * @param {Number} elementsPerPage The number of elements per page
38
+ * @param {String} token
39
+ */
40
+ export const getListByElementId = (elementId, page, elementsPerPage, token) => {
41
+ return new Promise(function (resolve, reject) {
42
+ let data = {};
43
+ if (elementsPerPage !== null) data.elementsPerPage = elementsPerPage;
44
+ if (page !== null) data.page = page;
45
+ const getTokensRequest = axios.post(`api/v1/logger/${elementId}`, data, {
46
+ headers: { authorization: token },
59
47
  });
60
- },
48
+ getTokensRequest
49
+ .then((result) => {
50
+ resolve(result.data);
51
+ })
52
+ .catch((error) => {
53
+ reject(error);
54
+ });
55
+ });
61
56
  };