2019-08-14 09:48:44 +00:00
|
|
|
/* global axios */
|
2019-10-27 13:31:59 +00:00
|
|
|
import ApiClient from '../ApiClient';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-10-27 13:31:59 +00:00
|
|
|
class ConversationApi extends ApiClient {
|
|
|
|
constructor() {
|
2020-03-09 17:57:10 +00:00
|
|
|
super('conversations', { accountScoped: true });
|
2019-10-27 13:31:59 +00:00
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2020-06-25 15:34:03 +00:00
|
|
|
get({ inboxId, status, assigneeType, page, labels }) {
|
2019-10-27 13:31:59 +00:00
|
|
|
return axios.get(this.url, {
|
|
|
|
params: {
|
|
|
|
inbox_id: inboxId,
|
2019-12-01 04:46:51 +00:00
|
|
|
status,
|
2020-02-26 15:45:01 +00:00
|
|
|
assignee_type: assigneeType,
|
|
|
|
page,
|
2020-06-25 15:34:03 +00:00
|
|
|
labels,
|
2019-10-27 13:31:59 +00:00
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
});
|
2019-10-27 13:31:59 +00:00
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-10-27 13:31:59 +00:00
|
|
|
toggleStatus(conversationId) {
|
|
|
|
return axios.post(`${this.url}/${conversationId}/toggle_status`, {});
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-10-27 13:31:59 +00:00
|
|
|
assignAgent({ conversationId, agentId }) {
|
|
|
|
axios.post(
|
|
|
|
`${this.url}/${conversationId}/assignments?assignee_id=${agentId}`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2020-08-03 08:10:20 +00:00
|
|
|
markMessageRead({ id }) {
|
|
|
|
return axios.post(`${this.url}/${id}/update_last_seen`);
|
2019-10-27 13:31:59 +00:00
|
|
|
}
|
2020-05-04 17:37:56 +00:00
|
|
|
|
|
|
|
toggleTyping({ conversationId, status }) {
|
|
|
|
return axios.post(`${this.url}/${conversationId}/toggle_typing_status`, {
|
|
|
|
typing_status: status,
|
|
|
|
});
|
|
|
|
}
|
2020-05-26 12:13:59 +00:00
|
|
|
|
|
|
|
mute(conversationId) {
|
|
|
|
return axios.post(`${this.url}/${conversationId}/mute`);
|
|
|
|
}
|
2020-06-09 10:56:33 +00:00
|
|
|
|
2020-06-25 15:34:03 +00:00
|
|
|
meta({ inboxId, status, assigneeType, labels }) {
|
2020-06-09 10:56:33 +00:00
|
|
|
return axios.get(`${this.url}/meta`, {
|
|
|
|
params: {
|
|
|
|
inbox_id: inboxId,
|
|
|
|
status,
|
|
|
|
assignee_type: assigneeType,
|
2020-06-25 15:34:03 +00:00
|
|
|
labels,
|
2020-06-09 10:56:33 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2020-08-17 05:55:13 +00:00
|
|
|
|
|
|
|
sendEmailTranscript({ conversationId, email }) {
|
|
|
|
return axios.post(`${this.url}/${conversationId}/transcript`, { email });
|
|
|
|
}
|
2019-10-27 13:31:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default new ConversationApi();
|