@stackfactor/client-api 1.0.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.
@@ -0,0 +1,131 @@
1
+ import axios from "./axios";
2
+
3
+ export default {
4
+ /**
5
+ * Create a new document to an existing template
6
+ *
7
+ * @param {String} templateId - the template id
8
+ * @param {String} parentPhaseId - the parent of the new phase. If null, it will add the phase to the
9
+ * root of the template
10
+ * @param {Object} data - new phase data information
11
+ * @param {String} token - authorization token
12
+ *
13
+ */
14
+ create(templateId, parentPhaseId, data, token) {
15
+ return new Promise(function (resolve, reject) {
16
+ const requestData = {
17
+ templateId: templateId,
18
+ parentPhaseId: parentPhaseId,
19
+ data: data,
20
+ };
21
+ let confirmationRequest = axios.put(
22
+ "api/v1/templates/template/phases/phase/document",
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
+ });
35
+ });
36
+ },
37
+
38
+ /**
39
+ * Delete an existing document from a template
40
+ *
41
+ * @param {String} templateId - the template id
42
+ * @param {String} documentId - the document id
43
+ * @param {String} token - authorization token
44
+ *
45
+ */
46
+ delete(templateId, documentId, token) {
47
+ return new Promise(function (resolve, reject) {
48
+ const requestData = {
49
+ templateId: templateId,
50
+ documentId: documentId,
51
+ };
52
+ let confirmationRequest = axios.delete(
53
+ `api/v1/templates/template/phases/phase/document`,
54
+ { headers: { authorization: token }, data: requestData }
55
+ );
56
+ confirmationRequest
57
+ .then((response) => {
58
+ resolve(response.data);
59
+ })
60
+ .catch((error) => {
61
+ reject(error);
62
+ });
63
+ });
64
+ },
65
+
66
+ /**
67
+ * Move an existing document
68
+ *
69
+ * @param {String} templateId - the template id
70
+ * @param {String} documentId - the id of the document to be moved
71
+ * @param {String} newParentPhaseId - the new parent phase id
72
+ * @param {String} token - authorization token
73
+ *
74
+ */
75
+ move(templateId, documentId, newParentPhaseId, token) {
76
+ return new Promise(function (resolve, reject) {
77
+ const requestData = {
78
+ templateId: templateId,
79
+ documentId: documentId,
80
+ newParentPhaseId: newParentPhaseId,
81
+ };
82
+ let confirmationRequest = axios.patch(
83
+ "api/v1/templates/template/phases/phase/document/move",
84
+ requestData,
85
+ {
86
+ headers: { authorization: token },
87
+ }
88
+ );
89
+ confirmationRequest
90
+ .then((response) => {
91
+ resolve(response.data);
92
+ })
93
+ .catch((error) => {
94
+ reject(error);
95
+ });
96
+ });
97
+ },
98
+
99
+ /**
100
+ * Update an existing document phase
101
+ *
102
+ * @param {String} templateId - template id
103
+ * @param {String} documentId - document id
104
+ * @param {Object} data - data containing the updated document information
105
+ * @param {String} token - authorization token
106
+ *
107
+ */
108
+ update(templateId, documentId, data, token) {
109
+ return new Promise(function (resolve, reject) {
110
+ const requestData = {
111
+ templateId: templateId,
112
+ documentId: documentId,
113
+ data: data,
114
+ };
115
+ let confirmationRequest = axios.patch(
116
+ "api/v1/templates/template/phases/phase/document",
117
+ requestData,
118
+ {
119
+ headers: { authorization: token },
120
+ }
121
+ );
122
+ confirmationRequest
123
+ .then((response) => {
124
+ resolve(response.data);
125
+ })
126
+ .catch((error) => {
127
+ reject(error);
128
+ });
129
+ });
130
+ },
131
+ };
@@ -0,0 +1,134 @@
1
+ import axios from "./axios";
2
+
3
+ export default {
4
+ /**
5
+ * Add a new phase to an existing template
6
+ *
7
+ * @param {String} templateId - the template id
8
+ * @param {String} parentPhaseId - the parent of the new phase. If null, it will add the phase to the root
9
+ * of the template
10
+ * @param {Object} data - new phase data information
11
+ * @param {String} token - authorization token
12
+ *
13
+ */
14
+ create(templateId, parentPhaseId, data, token) {
15
+ return new Promise(function (resolve, reject) {
16
+ const requestData = {
17
+ templateId: templateId,
18
+ data: data,
19
+ };
20
+ if (parentPhaseId) requestData.parentPhaseId = parentPhaseId;
21
+ let confirmationRequest = axios.put(
22
+ "api/v1/templates/template/phases/phase",
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
+ });
35
+ });
36
+ },
37
+
38
+ /**
39
+ * Delete an existing phase
40
+ *
41
+ * @param {String} templateId - the template id
42
+ * @param {String} phaseId - the phase id
43
+ * @param {String} token - authorization token
44
+ *
45
+ */
46
+ delete(templateId, phaseId, token) {
47
+ return new Promise(function (resolve, reject) {
48
+ const requestData = {
49
+ templateId: templateId,
50
+ phaseId: phaseId,
51
+ };
52
+ let confirmationRequest = axios.delete(
53
+ `api/v1/templates/template/phases/phase`,
54
+ {
55
+ headers: { authorization: token },
56
+ data: requestData,
57
+ }
58
+ );
59
+ confirmationRequest
60
+ .then((response) => {
61
+ resolve(response.data);
62
+ })
63
+ .catch((error) => {
64
+ reject(error);
65
+ });
66
+ });
67
+ },
68
+
69
+ /**
70
+ * Move an existing phase
71
+ *
72
+ * @param {String} templateId - the template id
73
+ * @param {String} phaseId - the id of the phase to be moved
74
+ * @param {String} newParentPhaseId - the new parent phase id
75
+ * @param {String} token - authorization token
76
+ *
77
+ */
78
+ move(templateId, phaseId, newParentPhaseId, token) {
79
+ return new Promise(function (resolve, reject) {
80
+ const requestData = {
81
+ templateId: templateId,
82
+ phaseId: phaseId,
83
+ newParentPhaseId: newParentPhaseId,
84
+ };
85
+ let confirmationRequest = axios.patch(
86
+ "api/v1/templates/template/phases/phase/move",
87
+ requestData,
88
+ {
89
+ headers: { authorization: token },
90
+ }
91
+ );
92
+ confirmationRequest
93
+ .then((response) => {
94
+ resolve(response.data);
95
+ })
96
+ .catch((error) => {
97
+ reject(error);
98
+ });
99
+ });
100
+ },
101
+
102
+ /**
103
+ * Update an existing template phase
104
+ *
105
+ * @param {String} templateId - template id
106
+ * @param {String} phaseId - phase id
107
+ * @param {Object} data - data containing the new phase information
108
+ * @param {String} token - authorization token
109
+ *
110
+ */
111
+ update(templateId, phaseId, data, token) {
112
+ return new Promise(function (resolve, reject) {
113
+ const requestData = {
114
+ templateId: templateId,
115
+ phaseId: phaseId,
116
+ data: data,
117
+ };
118
+ let confirmationRequest = axios.patch(
119
+ "api/v1/templates/template/phases/phase",
120
+ requestData,
121
+ {
122
+ headers: { authorization: token },
123
+ }
124
+ );
125
+ confirmationRequest
126
+ .then((response) => {
127
+ resolve(response.data);
128
+ })
129
+ .catch((error) => {
130
+ reject(error);
131
+ });
132
+ });
133
+ },
134
+ };
@@ -0,0 +1,98 @@
1
+ import axios from "./axios";
2
+
3
+ export default {
4
+ /**
5
+ * Create a new release to an existing template
6
+ *
7
+ * @param {string} templateId - the template id
8
+ * @param {Object} data - new phase data information
9
+ * @param {string} token - authorization token
10
+ *
11
+ */
12
+ create(templateId, data, token) {
13
+ return new Promise(function (resolve, reject) {
14
+ const requestData = {
15
+ templateId: templateId,
16
+ data: data,
17
+ };
18
+ let confirmationRequest = axios.put(
19
+ "api/v1/templates/template/releases/release",
20
+ requestData,
21
+ {
22
+ headers: { authorization: token },
23
+ }
24
+ );
25
+ confirmationRequest
26
+ .then((response) => {
27
+ resolve(response.data);
28
+ })
29
+ .catch((error) => {
30
+ reject(error);
31
+ });
32
+ });
33
+ },
34
+
35
+ /**
36
+ * Delete an existing release from a template
37
+ *
38
+ * @param {string} templateId - the template id
39
+ * @param {string} releaseId - the document id
40
+ * @param {string} token - authorization token
41
+ *
42
+ */
43
+ delete(templateId, releaseId, token) {
44
+ return new Promise(function (resolve, reject) {
45
+ const requestData = {
46
+ templateId: templateId,
47
+ releaseId: releaseId,
48
+ };
49
+ let confirmationRequest = axios.delete(
50
+ `api/v1/templates/template/releases/release`,
51
+ {
52
+ data: requestData,
53
+ headers: { authorization: token },
54
+ }
55
+ );
56
+ confirmationRequest
57
+ .then((response) => {
58
+ resolve(response.data);
59
+ })
60
+ .catch((error) => {
61
+ reject(error);
62
+ });
63
+ });
64
+ },
65
+
66
+ /**
67
+ * Update an existing release
68
+ *
69
+ * @param {string} templateId - template id
70
+ * @param {string} releaseId - release id
71
+ * @param {Object} data - data containing the updated document information
72
+ * @param {string} token - authorization token
73
+ *
74
+ */
75
+ update(templateId, releaseId, data, token) {
76
+ return new Promise(function (resolve, reject) {
77
+ const requestData = {
78
+ templateId: templateId,
79
+ releaseId: releaseId,
80
+ data: data,
81
+ };
82
+ let confirmationRequest = axios.patch(
83
+ "api/v1/templates/template/releases/release",
84
+ requestData,
85
+ {
86
+ headers: { authorization: token },
87
+ }
88
+ );
89
+ confirmationRequest
90
+ .then((response) => {
91
+ resolve(response.data);
92
+ })
93
+ .catch((error) => {
94
+ reject(error);
95
+ });
96
+ });
97
+ },
98
+ };
@@ -0,0 +1,159 @@
1
+ import axios from "./axios";
2
+
3
+ export default {
4
+ axios: axios,
5
+
6
+ /**
7
+ *
8
+ * Create template and set information
9
+ *
10
+ * @param {Object} data New template data information
11
+ * @param {String} token Authorization token
12
+ *
13
+ */
14
+ createTemplate(data, token) {
15
+ return new Promise(function (resolve, reject) {
16
+ const requestData = {
17
+ data: data,
18
+ };
19
+ let confirmationRequest = axios.put("api/v1/templates", requestData, {
20
+ headers: { authorization: token },
21
+ });
22
+ confirmationRequest
23
+ .then((response) => {
24
+ resolve(response.data);
25
+ })
26
+ .catch((error) => {
27
+ reject(error);
28
+ });
29
+ });
30
+ },
31
+
32
+ /**
33
+ * Delete template
34
+ *
35
+ * @param {number} id The id of the template to be deleted
36
+ * @param {String} token Authorization token
37
+ *
38
+ */
39
+ deleteTemplate(id, token) {
40
+ return new Promise(function (resolve, reject) {
41
+ const requestData = {
42
+ id: id,
43
+ };
44
+ let confirmationRequest = axios.delete(`api/v1/templates/`, {
45
+ headers: { authorization: token },
46
+ data: requestData,
47
+ });
48
+ confirmationRequest
49
+ .then((response) => {
50
+ resolve(response);
51
+ })
52
+ .catch((error) => {
53
+ reject(error);
54
+ });
55
+ });
56
+ },
57
+
58
+ /**
59
+ * Get template information
60
+ *
61
+ * @param {number} id The id of the template
62
+ * @param {String} token Authorization token
63
+ *
64
+ */
65
+ getTemplateInformationById(id, version, token) {
66
+ return new Promise(function (resolve, reject) {
67
+ let confirmationRequest = axios.get(`api/v1/templates/${id}/${version}`, {
68
+ headers: { authorization: token },
69
+ });
70
+ confirmationRequest
71
+ .then((response) => {
72
+ resolve(response.data);
73
+ })
74
+ .catch((error) => {
75
+ reject(error);
76
+ });
77
+ });
78
+ },
79
+
80
+ /**
81
+ * Get template information
82
+ *
83
+ * @param {Object} filter The filter used to select the template
84
+ * @param {String} token Authorization token
85
+ */
86
+ getTemplateList(filter, version, token) {
87
+ return new Promise(function (resolve, reject) {
88
+ const requestData = {
89
+ filter: filter ? filter : "",
90
+ version: version,
91
+ };
92
+ let confirmationRequest = axios.post(`api/v1/templates`, requestData, {
93
+ headers: { authorization: token },
94
+ });
95
+ confirmationRequest
96
+ .then((response) => {
97
+ resolve(response.data);
98
+ })
99
+ .catch((error) => {
100
+ reject(error);
101
+ });
102
+ });
103
+ },
104
+
105
+ /**
106
+ * Publish template
107
+ *
108
+ * @param {number} id The id of the template to be published
109
+ * @param {String} token Authorization token
110
+ */
111
+ publishTemplate(id, token) {
112
+ return new Promise(function (resolve, reject) {
113
+ let confirmationRequest = axios.post(
114
+ `api/v1/templates/publish/${id}`,
115
+ {},
116
+ {
117
+ headers: { authorization: token },
118
+ }
119
+ );
120
+ confirmationRequest
121
+ .then((response) => {
122
+ resolve(response.data);
123
+ })
124
+ .catch((error) => {
125
+ reject(error);
126
+ });
127
+ });
128
+ },
129
+
130
+ /**
131
+ * Set template profile information
132
+ *
133
+ * @param {String} id The id of the template to be updated
134
+ * @param {Object} data Data used to update the template
135
+ * @param {String} token Authorization token
136
+ *
137
+ */
138
+ setTemplateInformation(id, data, token) {
139
+ return new Promise(function (resolve, reject) {
140
+ const requestData = {
141
+ data: data,
142
+ };
143
+ let confirmationRequest = axios.post(
144
+ `api/v1/templates/${id}`,
145
+ requestData,
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
+ },
159
+ };
package/lib/tenants.js ADDED
@@ -0,0 +1,60 @@
1
+ import axios from "./axios";
2
+
3
+ export default {
4
+ axios: axios,
5
+
6
+ /**
7
+ * Get tenant information
8
+ *
9
+ * @param {String} category Tenant information category
10
+ * @param {String} token Authorization token
11
+ */
12
+ getTenantInformation(categories, token) {
13
+ return new Promise(function (resolve, reject) {
14
+ const requestData = {
15
+ categories: categories,
16
+ };
17
+ let request = axios.post("api/v1/tenants/tenant/get", requestData, {
18
+ headers: { authorization: token },
19
+ });
20
+ request
21
+ .then((response) => {
22
+ resolve(response.data ? response.data : null);
23
+ })
24
+ .catch((error) => {
25
+ reject(error);
26
+ });
27
+ });
28
+ },
29
+
30
+ /**
31
+ * Set tenant profile information
32
+ *
33
+ * @param {String} category Tenant information category
34
+ * @param {String} data New or updated tenant data information
35
+ * @param {Object} token Authorization token
36
+ *
37
+ */
38
+ setTenantInformation(category, data, token) {
39
+ return new Promise(function (resolve, reject) {
40
+ const requestData = {
41
+ category: category,
42
+ data: data,
43
+ };
44
+ let confirmationRequest = axios.post(
45
+ "api/v1/tenants/tenant/set",
46
+ requestData,
47
+ {
48
+ headers: { authorization: token },
49
+ }
50
+ );
51
+ confirmationRequest
52
+ .then((response) => {
53
+ resolve(response.data);
54
+ })
55
+ .catch((error) => {
56
+ reject(error);
57
+ });
58
+ });
59
+ },
60
+ };