Chatwoot/app/javascript/dashboard/api/reports.js
Pranav Raj S 52fad886b8
feat: Add business hours in downloadable reports (#4674)
Co-authored-by: Aswin Dev P.S <aswindevps@gmail.com>
2022-05-27 09:26:59 +05:30

81 lines
1.8 KiB
JavaScript

/* global axios */
import ApiClient from './ApiClient';
const getTimeOffset = () => -new Date().getTimezoneOffset() / 60;
class ReportsAPI extends ApiClient {
constructor() {
super('reports', { accountScoped: true, apiVersion: 'v2' });
}
getReports(
metric,
since,
until,
type = 'account',
id,
group_by,
business_hours
) {
return axios.get(`${this.url}`, {
params: {
metric,
since,
until,
type,
id,
group_by,
business_hours,
timezone_offset: getTimeOffset(),
},
});
}
getSummary(since, until, type = 'account', id, group_by, business_hours) {
return axios.get(`${this.url}/summary`, {
params: {
since,
until,
type,
id,
group_by,
business_hours,
},
});
}
getConversationMetric(type = 'account', page = 1) {
return axios.get(`${this.url}/conversations`, {
params: {
type,
page,
},
});
}
getAgentReports({ from: since, to: until, businessHours }) {
return axios.get(`${this.url}/agents`, {
params: { since, until, business_hours: businessHours },
});
}
getLabelReports({ from: since, to: until, businessHours }) {
return axios.get(`${this.url}/labels`, {
params: { since, until, business_hours: businessHours },
});
}
getInboxReports({ from: since, to: until, businessHours }) {
return axios.get(`${this.url}/inboxes`, {
params: { since, until, business_hours: businessHours },
});
}
getTeamReports({ from: since, to: until, businessHours }) {
return axios.get(`${this.url}/teams`, {
params: { since, until, business_hours: businessHours },
});
}
}
export default new ReportsAPI();