Chatwoot/app/javascript/widget/api/contacts.js
Sojan Jose f71980bd95
chore: Enhance contact merge action for identified users (#4886)
- Discard conflicting keys 
- Do not merge if there is already an identified contact

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2022-06-23 15:48:56 +05:30

28 lines
774 B
JavaScript

import { API } from 'widget/helpers/axios';
const buildUrl = endPoint => `/api/v1/${endPoint}${window.location.search}`;
export default {
get() {
return API.get(buildUrl('widget/contact'));
},
update(userObject) {
return API.patch(buildUrl('widget/contact'), userObject);
},
setUser(identifier, userObject) {
return API.patch(buildUrl('widget/contact/set_user'), {
identifier,
...userObject,
});
},
setCustomAttributes(customAttributes = {}) {
return API.patch(buildUrl('widget/contact'), {
custom_attributes: customAttributes,
});
},
deleteCustomAttribute(customAttribute) {
return API.post(buildUrl('widget/contact/destroy_custom_attributes'), {
custom_attributes: [customAttribute],
});
},
};