2021-09-15 07:21:57 +00:00
|
|
|
import { API } from 'widget/helpers/axios';
|
|
|
|
|
2021-09-29 08:58:32 +00:00
|
|
|
const buildUrl = endPoint =>
|
|
|
|
`/public/api/v1/${endPoint}${window.location.search}`;
|
2021-09-15 07:21:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Refer: https://www.chatwoot.com/developers/api#tag/Conversations-API
|
|
|
|
*/
|
|
|
|
|
|
|
|
export default {
|
2021-09-29 08:58:32 +00:00
|
|
|
create({ inboxIdentifier, contactIdentifier }) {
|
2021-09-15 07:21:57 +00:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
};
|