2017-09-25 07:23:29 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import VueResource from 'vue-resource';
|
2016-10-20 00:34:16 -04:00
|
|
|
|
2017-09-25 07:23:29 -04:00
|
|
|
Vue.use(VueResource);
|
2016-10-20 00:34:16 -04:00
|
|
|
|
2017-09-25 07:23:29 -04:00
|
|
|
export default class CycleAnalyticsService {
|
2017-04-10 21:02:55 -04:00
|
|
|
constructor(options) {
|
|
|
|
this.requestPath = options.requestPath;
|
2017-09-25 07:23:29 -04:00
|
|
|
this.cycleAnalytics = Vue.resource(this.requestPath);
|
2017-04-10 21:02:55 -04:00
|
|
|
}
|
2016-10-20 19:24:36 -04:00
|
|
|
|
2017-09-25 07:23:29 -04:00
|
|
|
fetchCycleAnalyticsData(options = { startDate: 30 }) {
|
|
|
|
return this.cycleAnalytics.get({ cycle_analytics: { start_date: options.startDate } });
|
2017-04-10 21:02:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fetchStageData(options) {
|
|
|
|
const {
|
|
|
|
stage,
|
|
|
|
startDate,
|
|
|
|
} = options;
|
|
|
|
|
2017-09-25 07:23:29 -04:00
|
|
|
return Vue.http.get(`${this.requestPath}/events/${stage.name}.json`, {
|
|
|
|
params: {
|
|
|
|
cycle_analytics: {
|
|
|
|
start_date: startDate,
|
|
|
|
},
|
2017-04-10 21:02:55 -04:00
|
|
|
},
|
|
|
|
});
|
2016-11-18 19:38:29 -05:00
|
|
|
}
|
2017-04-10 21:02:55 -04:00
|
|
|
}
|