2017-05-04 22:34:56 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import VueResource from 'vue-resource';
|
|
|
|
|
|
|
|
Vue.use(VueResource);
|
|
|
|
|
|
|
|
export default class GroupsService {
|
|
|
|
constructor(endpoint) {
|
|
|
|
this.groups = Vue.resource(endpoint);
|
|
|
|
}
|
|
|
|
|
2017-05-30 01:50:29 -04:00
|
|
|
getGroups(parentId, page) {
|
2017-05-22 13:47:05 -04:00
|
|
|
const data = {};
|
2017-05-12 04:36:08 -04:00
|
|
|
|
|
|
|
if (parentId) {
|
2017-05-22 13:47:05 -04:00
|
|
|
data.parent_id = parentId;
|
2017-05-23 13:11:51 -04:00
|
|
|
// Do not send this param for sub groups
|
2017-05-23 19:01:47 -04:00
|
|
|
} else if (page) {
|
|
|
|
data.page = page;
|
2017-05-12 04:36:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return this.groups.get(data);
|
2017-05-04 22:34:56 -04:00
|
|
|
}
|
2017-05-30 04:12:06 -04:00
|
|
|
|
2017-05-31 21:25:23 -04:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
2017-05-30 04:12:06 -04:00
|
|
|
leaveGroup(endpoint) {
|
|
|
|
return Vue.http.delete(endpoint);
|
|
|
|
}
|
2017-05-04 22:34:56 -04:00
|
|
|
}
|