Chatwoot/app/javascript/widget/api/conversationPublic.js

36 lines
813 B
JavaScript
Raw Normal View History

import { API } from 'widget/helpers/axios';
2021-09-29 08:58:32 +00:00
const buildUrl = endPoint =>
`/public/api/v1/${endPoint}${window.location.search}`;
/*
* Refer: https://www.chatwoot.com/developers/api#tag/Conversations-API
*/
export default {
2021-09-29 08:58:32 +00:00
create({ inboxIdentifier, contactIdentifier }) {
return API.post(
buildUrl(
`inboxes/${inboxIdentifier}/contacts/${contactIdentifier}/conversations`
)
);
},
get(inboxIdentifier, contactIdentifier) {
return API.get(
buildUrl(
`inboxes/${inboxIdentifier}/contacts/${contactIdentifier}/conversations`
)
);
},
update(inboxIdentifier, contactIdentifier, userObject) {
return API.patch(
buildUrl(`inboxes/${inboxIdentifier}/contacts/${contactIdentifier}`),
{
...userObject,
}
);
},
};