@stackfactor/client-api 1.0.32 → 1.0.33

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,215 +1,216 @@
1
- import { axios } from "./axiosClient";
1
+ import axios from "./axiosClient";
2
2
 
3
- module.exports = {
4
- axios: axios,
3
+ /**
4
+ * Create training plan template and set information
5
+ * @param {Object} data
6
+ * @param {String} token Authorization token
7
+ */
8
+ export const createTrainingPlanTemplate = (data, token) => {
9
+ return new Promise(function (resolve, reject) {
10
+ let confirmationRequest = axios.put(
11
+ "api/v1/trainingplantemplates",
12
+ { data: data },
13
+ {
14
+ headers: { authorization: token },
15
+ }
16
+ );
17
+ confirmationRequest
18
+ .then((response) => {
19
+ resolve(response.data);
20
+ })
21
+ .catch((error) => {
22
+ reject(error);
23
+ });
24
+ });
25
+ };
5
26
 
6
- /**
7
- * Create training plan template and set information
8
- * @param {Object} data
9
- * @param {String} token Authorization token
10
- */
11
- createTrainingPlanTemplate: (data, token) => {
12
- return new Promise(function (resolve, reject) {
13
- let confirmationRequest = axios.put(
14
- "api/v1/trainingplantemplates",
15
- { data: data },
16
- {
17
- headers: { authorization: token },
18
- }
19
- );
20
- confirmationRequest
21
- .then((response) => {
22
- resolve(response.data);
23
- })
24
- .catch((error) => {
25
- reject(error);
26
- });
27
+ /**
28
+ * Delete training plan template
29
+ * @param {String} id The id of the template to be deleted
30
+ * @param {String} comment The comment for approver
31
+ * @param {String} token Authorization token
32
+ */
33
+ export const deleteTrainingPlanTemplate = (id, comment, token) => {
34
+ return new Promise(function (resolve, reject) {
35
+ const data = {
36
+ id: id,
37
+ };
38
+ if (comment) data.comment = comment;
39
+ const request = axios.delete(`api/v1/trainingplantemplates/`, {
40
+ headers: { authorization: token },
41
+ data: data,
27
42
  });
28
- },
29
-
30
- /**
31
- * Delete training plan template
32
- * @param {String} id The id of the template to be deleted
33
- * @param {String} comment The comment for approver
34
- * @param {String} token Authorization token
35
- */
36
- deleteTrainingPlanTemplate: (id, comment, token) => {
37
- return new Promise(function (resolve, reject) {
38
- const data = {
39
- id: id,
40
- };
41
- if (comment) data.comment = comment;
42
- const request = axios.delete(`api/v1/trainingplantemplates/`, {
43
- headers: { authorization: token },
44
- data: data,
43
+ request
44
+ .then((response) => {
45
+ resolve(response.data);
46
+ })
47
+ .catch((error) => {
48
+ reject(error);
45
49
  });
46
- request
47
- .then((response) => {
48
- resolve(response.data);
49
- })
50
- .catch((error) => {
51
- reject(error);
52
- });
50
+ });
51
+ };
52
+
53
+ /**
54
+ * Discard the training plan draft changes
55
+ * @param {String} id The id of the training plan to be deleted
56
+ * @param {String} token Authorization token
57
+ */
58
+ export const discardTrainingPlanChanges = (id, token) => {
59
+ return new Promise(function (resolve, reject) {
60
+ const data = {};
61
+ const request = axios.get(`api/v1/trainingplantemplates/discard/${id}`, {
62
+ headers: { authorization: token },
63
+ data: data,
53
64
  });
54
- },
65
+ request
66
+ .then((response) => {
67
+ resolve(response.data);
68
+ })
69
+ .catch((error) => {
70
+ reject(error);
71
+ });
72
+ });
73
+ };
55
74
 
56
- /**
57
- * Discard the training plan draft changes
58
- * @param {String} id The id of the training plan to be deleted
59
- * @param {String} token Authorization token
60
- */
61
- discardTrainingPlanChanges: (id, token) => {
62
- return new Promise(function (resolve, reject) {
63
- const data = {};
64
- const request = axios.get(`api/v1/trainingplantemplates/discard/${id}`, {
75
+ /**
76
+ * Get traing plan template information
77
+ * @param {String} id The id of the template
78
+ * @param {String} token Authorization token
79
+ */
80
+ export const getTrainingPlanTemplateInformationById = (id, version, token) => {
81
+ return new Promise(function (resolve, reject) {
82
+ let confirmationRequest = axios.get(
83
+ `api/v1/trainingplantemplates/${id}/${version}`,
84
+ {
65
85
  headers: { authorization: token },
66
- data: data,
86
+ }
87
+ );
88
+ confirmationRequest
89
+ .then((response) => {
90
+ resolve(response.data);
91
+ })
92
+ .catch((error) => {
93
+ reject(error);
67
94
  });
68
- request
69
- .then((response) => {
70
- resolve(response.data);
71
- })
72
- .catch((error) => {
73
- reject(error);
74
- });
75
- });
76
- },
77
-
78
- /**
79
- * Get traing plan template information
80
- * @param {String} id The id of the template
81
- * @param {String} token Authorization token
82
- */
83
- getTrainingPlanTemplateInformationById: (id, version, token) => {
84
- return new Promise(function (resolve, reject) {
85
- let confirmationRequest = axios.get(
86
- `api/v1/trainingplantemplates/${id}/${version}`,
87
- {
88
- headers: { authorization: token },
89
- }
90
- );
91
- confirmationRequest
92
- .then((response) => {
93
- resolve(response.data);
94
- })
95
- .catch((error) => {
96
- reject(error);
97
- });
98
- });
99
- },
95
+ });
96
+ };
100
97
 
101
- /**
102
- * Get training plan template list
103
- * @param {Array<String>} list The filter used to select the skill
104
- * @param {String} version The version to be retrieved
105
- * @param {String} token Authorization token
106
- */
107
- getTrainingPlanTemplatesList: (list, version, includeDeleted, token) => {
108
- return new Promise(function (resolve, reject) {
109
- const requestData = {
110
- version: version,
111
- includeDeleted: includeDeleted,
112
- };
113
- if (list) requestData.list = list;
114
- let confirmationRequest = axios.post(
115
- `api/v1/trainingplantemplates`,
116
- requestData,
117
- {
118
- headers: { authorization: token },
119
- }
120
- );
121
- confirmationRequest
122
- .then((response) => {
123
- resolve(response.data);
124
- })
125
- .catch((error) => {
126
- reject(error);
127
- });
128
- });
129
- },
98
+ /**
99
+ * Get training plan template list
100
+ * @param {Array<String>} list The filter used to select the skill
101
+ * @param {String} version The version to be retrieved
102
+ * @param {String} token Authorization token
103
+ */
104
+ export const getTrainingPlanTemplatesList = (
105
+ list,
106
+ version,
107
+ includeDeleted,
108
+ token
109
+ ) => {
110
+ return new Promise(function (resolve, reject) {
111
+ const requestData = {
112
+ version: version,
113
+ includeDeleted: includeDeleted,
114
+ };
115
+ if (list) requestData.list = list;
116
+ let confirmationRequest = axios.post(
117
+ `api/v1/trainingplantemplates`,
118
+ requestData,
119
+ {
120
+ headers: { authorization: token },
121
+ }
122
+ );
123
+ confirmationRequest
124
+ .then((response) => {
125
+ resolve(response.data);
126
+ })
127
+ .catch((error) => {
128
+ reject(error);
129
+ });
130
+ });
131
+ };
130
132
 
131
- /**
132
- * Publish training pplan template
133
- * @param {String} id The id of the template to be published
134
- * @param {String} comment The comment to be include with the request
135
- * @param {String} token Authorization token
136
- */
137
- publishTrainingPlanTemplate: (id, comment, token) => {
138
- return new Promise(function (resolve, reject) {
139
- let data = {};
140
- if (comment) data.comment = comment;
141
- let confirmationRequest = axios.post(
142
- `api/v1/trainingplantemplates/publish/${id}`,
143
- data,
144
- {
145
- headers: { authorization: token },
146
- }
147
- );
148
- confirmationRequest
149
- .then((response) => {
150
- resolve(response.data);
151
- })
152
- .catch((error) => {
153
- reject(error);
154
- });
155
- });
156
- },
133
+ /**
134
+ * Publish training pplan template
135
+ * @param {String} id The id of the template to be published
136
+ * @param {String} comment The comment to be include with the request
137
+ * @param {String} token Authorization token
138
+ */
139
+ export const publishTrainingPlanTemplate = (id, comment, token) => {
140
+ return new Promise(function (resolve, reject) {
141
+ let data = {};
142
+ if (comment) data.comment = comment;
143
+ let confirmationRequest = axios.post(
144
+ `api/v1/trainingplantemplates/publish/${id}`,
145
+ data,
146
+ {
147
+ headers: { authorization: token },
148
+ }
149
+ );
150
+ confirmationRequest
151
+ .then((response) => {
152
+ resolve(response.data);
153
+ })
154
+ .catch((error) => {
155
+ reject(error);
156
+ });
157
+ });
158
+ };
157
159
 
158
- /**
159
- * Set training plan template profile information
160
- * @param {String} id The id of the template to be updated
161
- * @param {Object} data Data used to update the template
162
- * @param {String} token Authorization token
163
- */
164
- setTrainingPlanTemplateInformation: (id, data, token) => {
165
- return new Promise(function (resolve, reject) {
166
- const requestData = {
167
- data: data,
168
- id: id,
169
- };
170
- let confirmationRequest = axios.post(
171
- `api/v1/trainingplantemplates/update/`,
172
- requestData,
173
- {
174
- headers: { authorization: token },
175
- }
176
- );
177
- confirmationRequest
178
- .then((response) => {
179
- resolve(response.data);
180
- })
181
- .catch((error) => {
182
- reject(error);
183
- });
184
- });
185
- },
160
+ /**
161
+ * Set training plan template profile information
162
+ * @param {String} id The id of the template to be updated
163
+ * @param {Object} data Data used to update the template
164
+ * @param {String} token Authorization token
165
+ */
166
+ export const setTrainingPlanTemplateInformation = (id, data, token) => {
167
+ return new Promise(function (resolve, reject) {
168
+ const requestData = {
169
+ data: data,
170
+ id: id,
171
+ };
172
+ let confirmationRequest = axios.post(
173
+ `api/v1/trainingplantemplates/update/`,
174
+ requestData,
175
+ {
176
+ headers: { authorization: token },
177
+ }
178
+ );
179
+ confirmationRequest
180
+ .then((response) => {
181
+ resolve(response.data);
182
+ })
183
+ .catch((error) => {
184
+ reject(error);
185
+ });
186
+ });
187
+ };
186
188
 
187
- /**
188
- * Update training plan template tags
189
- * @param {String} id The id of the template to be updated
190
- * @param {Object} tags The updated tags
191
- * @param {String} token Authorization token
192
- */
193
- setTrainingPlanTemplateTags: (id, tags, token) => {
194
- return new Promise(function (resolve, reject) {
195
- const requestData = {
196
- tags: tags,
197
- id: id,
198
- };
199
- let confirmationRequest = axios.post(
200
- `api/v1/trainingplantemplates/updatetags/`,
201
- requestData,
202
- {
203
- headers: { authorization: token },
204
- }
205
- );
206
- confirmationRequest
207
- .then((response) => {
208
- resolve(response.data);
209
- })
210
- .catch((error) => {
211
- reject(error);
212
- });
213
- });
214
- },
189
+ /**
190
+ * Update training plan template tags
191
+ * @param {String} id The id of the template to be updated
192
+ * @param {Object} tags The updated tags
193
+ * @param {String} token Authorization token
194
+ */
195
+ export const setTrainingPlanTemplateTags = (id, tags, token) => {
196
+ return new Promise(function (resolve, reject) {
197
+ const requestData = {
198
+ tags: tags,
199
+ id: id,
200
+ };
201
+ let confirmationRequest = axios.post(
202
+ `api/v1/trainingplantemplates/updatetags/`,
203
+ requestData,
204
+ {
205
+ headers: { authorization: token },
206
+ }
207
+ );
208
+ confirmationRequest
209
+ .then((response) => {
210
+ resolve(response.data);
211
+ })
212
+ .catch((error) => {
213
+ reject(error);
214
+ });
215
+ });
215
216
  };