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() {
|
|
|
|
super('conversations');
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2019-12-01 04:46:51 +00:00
|
|
|
get({ inboxId, status, assigneeType }) {
|
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,
|
|
|
|
assignee_type_id: assigneeType,
|
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
|
|
|
|
|
|
|
markMessageRead({ id, lastSeen }) {
|
2019-10-27 13:31:59 +00:00
|
|
|
return axios.post(`${this.url}/${id}/update_last_seen`, {
|
|
|
|
agent_last_seen_at: lastSeen,
|
2019-08-14 09:48:44 +00:00
|
|
|
});
|
2019-10-27 13:31:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default new ConversationApi();
|