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
|
|
|
|
2021-02-13 09:28:05 +00:00
|
|
|
get({ inboxId, status, assigneeType, page, labels, teamId }) {
|
2019-10-27 13:31:59 +00:00
|
|
|
return axios.get(this.url, {
|
|
|
|
params: {
|
|
|
|
inbox_id: inboxId,
|
2021-02-13 09:28:05 +00:00
|
|
|
team_id: teamId,
|
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
|
|
|
|
2020-11-07 20:16:45 +00:00
|
|
|
search({ q }) {
|
|
|
|
return axios.get(`${this.url}/search`, {
|
|
|
|
params: {
|
|
|
|
q,
|
|
|
|
page: 1,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-07-23 09:54:07 +00:00
|
|
|
toggleStatus({ conversationId, status, snoozedUntil = null }) {
|
2021-04-07 06:14:58 +00:00
|
|
|
return axios.post(`${this.url}/${conversationId}/toggle_status`, {
|
|
|
|
status,
|
2021-07-23 09:54:07 +00:00
|
|
|
snoozed_until: snoozedUntil,
|
2021-04-07 06:14:58 +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
|
|
|
assignAgent({ conversationId, agentId }) {
|
2021-03-15 13:07:03 +00:00
|
|
|
return axios.post(
|
2019-10-27 13:31:59 +00:00
|
|
|
`${this.url}/${conversationId}/assignments?assignee_id=${agentId}`,
|
|
|
|
{}
|
|
|
|
);
|
|
|
|
}
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2021-03-15 13:07:03 +00:00
|
|
|
assignTeam({ conversationId, teamId }) {
|
|
|
|
const params = { team_id: teamId };
|
|
|
|
return axios.post(`${this.url}/${conversationId}/assignments`, params);
|
|
|
|
}
|
|
|
|
|
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-10-08 06:32:08 +00:00
|
|
|
unmute(conversationId) {
|
|
|
|
return axios.post(`${this.url}/${conversationId}/unmute`);
|
|
|
|
}
|
|
|
|
|
2021-02-13 09:28:05 +00:00
|
|
|
meta({ inboxId, status, assigneeType, labels, teamId }) {
|
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,
|
2021-02-13 09:28:05 +00:00
|
|
|
team_id: teamId,
|
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();
|