Feature: Website SDK (#653)
Add SDK functions Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
import authEndPoint from 'widget/api/endPoints';
|
||||
import { API } from 'widget/helpers/axios';
|
||||
|
||||
export const updateContact = async ({ messageId, email }) => {
|
||||
const urlData = authEndPoint.updateContact(messageId);
|
||||
const result = await API.patch(urlData.url, {
|
||||
contact: { email },
|
||||
});
|
||||
return result;
|
||||
};
|
||||
12
app/javascript/widget/api/contacts.js
Normal file
12
app/javascript/widget/api/contacts.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { API } from 'widget/helpers/axios';
|
||||
|
||||
const buildUrl = endPoint => `/api/v1/${endPoint}${window.location.search}`;
|
||||
|
||||
export default {
|
||||
update(identifier, userObject) {
|
||||
return API.patch(buildUrl('widget/contact'), {
|
||||
identifier,
|
||||
...userObject,
|
||||
});
|
||||
},
|
||||
};
|
||||
12
app/javascript/widget/api/conversationLabels.js
Normal file
12
app/javascript/widget/api/conversationLabels.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { API } from 'widget/helpers/axios';
|
||||
|
||||
const buildUrl = endPoint => `/api/v1/${endPoint}${window.location.search}`;
|
||||
|
||||
export default {
|
||||
create(label) {
|
||||
return API.post(buildUrl('widget/labels'), { label });
|
||||
},
|
||||
destroy(label) {
|
||||
return API.delete(buildUrl(`widget/labels/${label}`));
|
||||
},
|
||||
};
|
||||
11
app/javascript/widget/api/message.js
Executable file
11
app/javascript/widget/api/message.js
Executable file
@@ -0,0 +1,11 @@
|
||||
import authEndPoint from 'widget/api/endPoints';
|
||||
import { API } from 'widget/helpers/axios';
|
||||
|
||||
export default {
|
||||
update: ({ messageId, email }) => {
|
||||
const urlData = authEndPoint.updateContact(messageId);
|
||||
return API.patch(urlData.url, {
|
||||
contact: { email },
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user