2018-03-17 18:26:18 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import VueResource from 'vue-resource';
|
2018-03-27 19:54:05 +05:30
|
|
|
import * as constants from '../constants';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
Vue.use(VueResource);
|
|
|
|
|
|
|
|
export default {
|
2018-11-08 19:23:39 +05:30
|
|
|
fetchDiscussions(endpoint) {
|
2018-03-17 18:26:18 +05:30
|
|
|
return Vue.http.get(endpoint);
|
|
|
|
},
|
|
|
|
deleteNote(endpoint) {
|
|
|
|
return Vue.http.delete(endpoint);
|
|
|
|
},
|
|
|
|
replyToDiscussion(endpoint, data) {
|
|
|
|
return Vue.http.post(endpoint, data, { emulateJSON: true });
|
|
|
|
},
|
|
|
|
updateNote(endpoint, data) {
|
|
|
|
return Vue.http.put(endpoint, data, { emulateJSON: true });
|
|
|
|
},
|
|
|
|
createNewNote(endpoint, data) {
|
|
|
|
return Vue.http.post(endpoint, data, { emulateJSON: true });
|
|
|
|
},
|
2018-03-27 19:54:05 +05:30
|
|
|
toggleResolveNote(endpoint, isResolved) {
|
|
|
|
const { RESOLVE_NOTE_METHOD_NAME, UNRESOLVE_NOTE_METHOD_NAME } = constants;
|
2018-11-08 19:23:39 +05:30
|
|
|
const method = isResolved ? UNRESOLVE_NOTE_METHOD_NAME : RESOLVE_NOTE_METHOD_NAME;
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
return Vue.http[method](endpoint);
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
poll(data = {}) {
|
2018-03-27 19:54:05 +05:30
|
|
|
const endpoint = data.notesData.notesPath;
|
2018-11-08 19:23:39 +05:30
|
|
|
const { lastFetchedAt } = data;
|
2018-03-17 18:26:18 +05:30
|
|
|
const options = {
|
|
|
|
headers: {
|
2018-03-27 19:54:05 +05:30
|
|
|
'X-Last-Fetched-At': lastFetchedAt ? `${lastFetchedAt}` : undefined,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return Vue.http.get(endpoint, options);
|
|
|
|
},
|
|
|
|
toggleAward(endpoint, data) {
|
|
|
|
return Vue.http.post(endpoint, data, { emulateJSON: true });
|
|
|
|
},
|
2018-03-27 19:54:05 +05:30
|
|
|
toggleIssueState(endpoint, data) {
|
|
|
|
return Vue.http.put(endpoint, data);
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
};
|