summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jira_connect/api.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/jira_connect/api.js')
-rw-r--r--app/assets/javascripts/jira_connect/api.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/assets/javascripts/jira_connect/api.js b/app/assets/javascripts/jira_connect/api.js
new file mode 100644
index 00000000000..d689a2d1962
--- /dev/null
+++ b/app/assets/javascripts/jira_connect/api.js
@@ -0,0 +1,33 @@
+import axios from 'axios';
+
+const getJwt = async () => {
+ return AP.context.getToken();
+};
+
+export const addSubscription = async (addPath, namespace) => {
+ const jwt = await getJwt();
+
+ return axios.post(addPath, {
+ jwt,
+ namespace_path: namespace,
+ });
+};
+
+export const removeSubscription = async (removePath) => {
+ const jwt = await getJwt();
+
+ return axios.delete(removePath, {
+ params: {
+ jwt,
+ },
+ });
+};
+
+export const fetchGroups = async (groupsPath, { page, perPage }) => {
+ return axios.get(groupsPath, {
+ params: {
+ page,
+ per_page: perPage,
+ },
+ });
+};