@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.
package/lib/dashboard.js CHANGED
@@ -1,75 +1,71 @@
1
- import { axios } from "./axiosClient";
1
+ import axios from "./axiosClient";
2
2
 
3
- module.exports = {
4
- axios: axios,
3
+ /**
4
+ * Add a card to the dashboard
5
+ * @param {String} id - the id of the card to be added to the dashboard
6
+ * @param {Number} position - The position on the dashboard
7
+ * @param {Object} data - The card settings data
8
+ * @param {String} authToken - Authorization token
9
+ */
10
+ export const addCardToDashboard = (id, position, data, authToken) => {
11
+ return new Promise(function (resolve, reject) {
12
+ const request = axios.put(
13
+ `/api/v1/dashboard/card`,
14
+ {
15
+ id: id,
16
+ position: position,
17
+ data: data ? data : {},
18
+ },
19
+ { headers: { authorization: authToken } }
20
+ );
21
+ request
22
+ .then((response) => {
23
+ resolve(response.data);
24
+ })
25
+ .catch((error) => {
26
+ reject(error);
27
+ });
28
+ });
29
+ };
5
30
 
6
- /**
7
- * Add a card to the dashboard
8
- * @param {String} id - the id of the card to be added to the dashboard
9
- * @param {Number} position - The position on the dashboard
10
- * @param {Object} data - The card settings data
11
- * @param {String} authToken - Authorization token
12
- */
13
- addCardToDashboard: (id, position, data, authToken) => {
14
- return new Promise(function (resolve, reject) {
15
- const request = axios.put(
16
- `/api/v1/dashboard/card`,
17
- {
18
- id: id,
19
- position: position,
20
- data: data ? data : {},
21
- },
22
- { headers: { authorization: authToken } }
23
- );
24
- request
25
- .then((response) => {
26
- resolve(response.data);
27
- })
28
- .catch((error) => {
29
- reject(error);
30
- });
31
+ /**
32
+ * Get the list of the cards from the dashboard
33
+ * @param {String} authToken - Authorization token
34
+ */
35
+ export const getDashboardCardsList = (authToken) => {
36
+ return new Promise(function (resolve, reject) {
37
+ const request = axios.get(`/api/v1/dashboard/card`, {
38
+ headers: { authorization: authToken },
31
39
  });
32
- },
33
-
34
- /**
35
- * Get the list of the cards from the dashboard
36
- * @param {String} authToken - Authorization token
37
- */
38
- getDashboardCardsList: (authToken) => {
39
- return new Promise(function (resolve, reject) {
40
- const request = axios.get(`/api/v1/dashboard/card`, {
41
- headers: { authorization: authToken },
40
+ request
41
+ .then((response) => {
42
+ resolve(response.data);
43
+ })
44
+ .catch((error) => {
45
+ reject(error);
42
46
  });
43
- request
44
- .then((response) => {
45
- resolve(response.data);
46
- })
47
- .catch((error) => {
48
- reject(error);
49
- });
50
- });
51
- },
47
+ });
48
+ };
52
49
 
53
- /**
54
- * Remove a card from the dashboard
55
- * @param {String} id - the id of the configuration element
56
- * @param {String} authToken - Authorization token
57
- */
58
- removeCardFromDashboard: (id, authToken) => {
59
- return new Promise(function (resolve, reject) {
60
- const request = axios.delete(`/api/v1/dashboard/card`, {
61
- headers: { authorization: authToken },
62
- data: {
63
- id: id,
64
- },
65
- });
66
- request
67
- .then((response) => {
68
- resolve(response.data);
69
- })
70
- .catch((error) => {
71
- reject(error);
72
- });
50
+ /**
51
+ * Remove a card from the dashboard
52
+ * @param {String} id - the id of the configuration element
53
+ * @param {String} authToken - Authorization token
54
+ */
55
+ export const removeCardFromDashboard = (id, authToken) => {
56
+ return new Promise(function (resolve, reject) {
57
+ const request = axios.delete(`/api/v1/dashboard/card`, {
58
+ headers: { authorization: authToken },
59
+ data: {
60
+ id: id,
61
+ },
73
62
  });
74
- },
63
+ request
64
+ .then((response) => {
65
+ resolve(response.data);
66
+ })
67
+ .catch((error) => {
68
+ reject(error);
69
+ });
70
+ });
75
71
  };
@@ -1,163 +1,169 @@
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 {String} name
6
+ * @param {String} summary
7
+ * @param {Array<Object>} activities
8
+ * @param {String} token Authorization token
9
+ */
10
+ export const createDepartmentTrainingPlan = (
11
+ name,
12
+ summary,
13
+ skill,
14
+ activities,
15
+ token
16
+ ) => {
17
+ return new Promise(function (resolve, reject) {
18
+ const requestData = {
19
+ name: name ? name : "",
20
+ summary: summary ? summary : "",
21
+ skill: skill ? skill : "",
22
+ activities: activities ? activities : [],
23
+ };
24
+ let confirmationRequest = axios.put(
25
+ "api/v1/departmentTrainingPlans",
26
+ requestData,
27
+ {
28
+ headers: { authorization: token },
29
+ }
30
+ );
31
+ confirmationRequest
32
+ .then((response) => {
33
+ resolve(response.data);
34
+ })
35
+ .catch((error) => {
36
+ reject(error);
37
+ });
38
+ });
39
+ };
5
40
 
6
- /**
7
- * Create training plan template and set information
8
- * @param {String} name
9
- * @param {String} summary
10
- * @param {Array<Object>} activities
11
- * @param {String} token Authorization token
12
- */
13
- createDepartmentTrainingPlan: (name, summary, skill, activities, token) => {
14
- return new Promise(function (resolve, reject) {
15
- const requestData = {
16
- name: name ? name : "",
17
- summary: summary ? summary : "",
18
- skill: skill ? skill : "",
19
- activities: activities ? activities : [],
20
- };
21
- let confirmationRequest = axios.put(
22
- "api/v1/departmentTrainingPlans",
23
- requestData,
24
- {
25
- headers: { authorization: token },
26
- }
27
- );
28
- confirmationRequest
29
- .then((response) => {
30
- resolve(response.data);
31
- })
32
- .catch((error) => {
33
- reject(error);
34
- });
41
+ /**
42
+ * Delete department training plan
43
+ * @param {String} id The id of the template to be deleted
44
+ * @param {String} token Authorization token
45
+ */
46
+ export const deleteDepartmentTrainingPlan = (id, token) => {
47
+ return new Promise(function (resolve, reject) {
48
+ const request = axios.delete(`api/v1/departmenttrainingplans/`, {
49
+ headers: { authorization: token },
50
+ data: {
51
+ id: id,
52
+ },
35
53
  });
36
- },
54
+ request
55
+ .then((response) => {
56
+ resolve(response.data);
57
+ })
58
+ .catch((error) => {
59
+ reject(error);
60
+ });
61
+ });
62
+ };
37
63
 
38
- /**
39
- * Delete department training plan
40
- * @param {String} id The id of the template to be deleted
41
- * @param {String} token Authorization token
42
- */
43
- deleteDepartmentTrainingPlan: (id, token) => {
44
- return new Promise(function (resolve, reject) {
45
- const request = axios.delete(`api/v1/departmenttrainingplans/`, {
64
+ /**
65
+ * Get department traing plan information
66
+ * @param {Number} id The id of the plan
67
+ * @param {String} token Authorization token
68
+ */
69
+ export const getDepartmentTrainingPlanInformationById = (
70
+ id,
71
+ version,
72
+ token
73
+ ) => {
74
+ return new Promise(function (resolve, reject) {
75
+ let confirmationRequest = axios.get(
76
+ `api/v1/departmenttrainingplans/${id}/${version}`,
77
+ {
46
78
  headers: { authorization: token },
47
- data: {
48
- id: id,
49
- },
79
+ }
80
+ );
81
+ confirmationRequest
82
+ .then((response) => {
83
+ resolve(response.data);
84
+ })
85
+ .catch((error) => {
86
+ reject(error);
50
87
  });
51
- request
52
- .then((response) => {
53
- resolve(response.data);
54
- })
55
- .catch((error) => {
56
- reject(error);
57
- });
58
- });
59
- },
60
-
61
- /**
62
- * Get department traing plan information
63
- * @param {Number} id The id of the plan
64
- * @param {String} token Authorization token
65
- */
66
- getDepartmentTrainingPlanInformationById: (id, version, token) => {
67
- return new Promise(function (resolve, reject) {
68
- let confirmationRequest = axios.get(
69
- `api/v1/departmenttrainingplans/${id}/${version}`,
70
- {
71
- headers: { authorization: token },
72
- }
73
- );
74
- confirmationRequest
75
- .then((response) => {
76
- resolve(response.data);
77
- })
78
- .catch((error) => {
79
- reject(error);
80
- });
81
- });
82
- },
88
+ });
89
+ };
83
90
 
84
- /**
85
- * Get department training plan list
86
- * @param {Object} filter The filter used to select the plan
87
- * @param {String} token Authorization token
88
- */
89
- getDepartmentTrainingPlanList: (filter, version, token) => {
90
- return new Promise(function (resolve, reject) {
91
- const requestData = {
92
- filter: filter ? filter : "",
93
- version: version,
94
- };
95
- let confirmationRequest = axios.post(
96
- `api/v1/departmenttrainingplans`,
97
- requestData,
98
- {
99
- headers: { authorization: token },
100
- }
101
- );
102
- confirmationRequest
103
- .then((response) => {
104
- resolve(response.data);
105
- })
106
- .catch((error) => {
107
- reject(error);
108
- });
109
- });
110
- },
91
+ /**
92
+ * Get department training plan list
93
+ * @param {Object} filter The filter used to select the plan
94
+ * @param {String} token Authorization token
95
+ */
96
+ export const getDepartmentTrainingPlanList = (filter, version, token) => {
97
+ return new Promise(function (resolve, reject) {
98
+ const requestData = {
99
+ filter: filter ? filter : "",
100
+ version: version,
101
+ };
102
+ let confirmationRequest = axios.post(
103
+ `api/v1/departmenttrainingplans`,
104
+ requestData,
105
+ {
106
+ headers: { authorization: token },
107
+ }
108
+ );
109
+ confirmationRequest
110
+ .then((response) => {
111
+ resolve(response.data);
112
+ })
113
+ .catch((error) => {
114
+ reject(error);
115
+ });
116
+ });
117
+ };
111
118
 
112
- /**
113
- * Publish department training plan
114
- * @param {number} id The id of the plan to be published
115
- * @param {String} token Authorization token
116
- */
117
- publishDepartmentTrainingPlan: (id, token) => {
118
- return new Promise(function (resolve, reject) {
119
- let confirmationRequest = axios.post(
120
- `api/v1/departmenttrainingplans/publish/${id}`,
121
- {},
122
- {
123
- headers: { authorization: token },
124
- }
125
- );
126
- confirmationRequest
127
- .then((response) => {
128
- resolve(response.data);
129
- })
130
- .catch((error) => {
131
- reject(error);
132
- });
133
- });
134
- },
119
+ /**
120
+ * Publish department training plan
121
+ * @param {number} id The id of the plan to be published
122
+ * @param {String} token Authorization token
123
+ */
124
+ export const publishDepartmentTrainingPlan = (id, token) => {
125
+ return new Promise(function (resolve, reject) {
126
+ let confirmationRequest = axios.post(
127
+ `api/v1/departmenttrainingplans/publish/${id}`,
128
+ {},
129
+ {
130
+ headers: { authorization: token },
131
+ }
132
+ );
133
+ confirmationRequest
134
+ .then((response) => {
135
+ resolve(response.data);
136
+ })
137
+ .catch((error) => {
138
+ reject(error);
139
+ });
140
+ });
141
+ };
135
142
 
136
- /**
137
- * Set department training plan profile information
138
- * @param {String} id The id of the plan to be updated
139
- * @param {Object} data Data used to update the plan
140
- * @param {String} token Authorization token
141
- */
142
- setDepartmentTrainingPlanInformation: (id, data, token) => {
143
- return new Promise(function (resolve, reject) {
144
- const requestData = {
145
- data: data,
146
- };
147
- let confirmationRequest = axios.post(
148
- `api/v1/departmenttrainingplans/${id}`,
149
- requestData,
150
- {
151
- headers: { authorization: token },
152
- }
153
- );
154
- confirmationRequest
155
- .then((response) => {
156
- resolve(response.data);
157
- })
158
- .catch((error) => {
159
- reject(error);
160
- });
161
- });
162
- },
143
+ /**
144
+ * Set department training plan profile information
145
+ * @param {String} id The id of the plan to be updated
146
+ * @param {Object} data Data used to update the plan
147
+ * @param {String} token Authorization token
148
+ */
149
+ export const setDepartmentTrainingPlanInformation = (id, data, token) => {
150
+ return new Promise(function (resolve, reject) {
151
+ const requestData = {
152
+ data: data,
153
+ };
154
+ let confirmationRequest = axios.post(
155
+ `api/v1/departmenttrainingplans/${id}`,
156
+ requestData,
157
+ {
158
+ headers: { authorization: token },
159
+ }
160
+ );
161
+ confirmationRequest
162
+ .then((response) => {
163
+ resolve(response.data);
164
+ })
165
+ .catch((error) => {
166
+ reject(error);
167
+ });
168
+ });
163
169
  };