2018-03-17 18:26:18 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import VueResource from 'vue-resource';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
Vue.use(VueResource);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
export default class CycleAnalyticsService {
|
2017-08-17 22:00:37 +05:30
|
|
|
constructor(options) {
|
|
|
|
this.requestPath = options.requestPath;
|
2018-03-17 18:26:18 +05:30
|
|
|
this.cycleAnalytics = Vue.resource(this.requestPath);
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
fetchCycleAnalyticsData(options = { startDate: 30 }) {
|
|
|
|
return this.cycleAnalytics.get({ cycle_analytics: { start_date: options.startDate } });
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
fetchStageData(options) {
|
|
|
|
const {
|
|
|
|
stage,
|
|
|
|
startDate,
|
|
|
|
} = options;
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
return Vue.http.get(`${this.requestPath}/events/${stage.name}.json`, {
|
|
|
|
params: {
|
|
|
|
cycle_analytics: {
|
|
|
|
start_date: startDate,
|
|
|
|
},
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|