Skip to content

Instantly share code, notes, and snippets.

@aasumitro
Created June 17, 2022 07:23
Show Gist options
  • Save aasumitro/ef4a1c352dbf764cd791306b3bb61fdf to your computer and use it in GitHub Desktop.
Save aasumitro/ef4a1c352dbf764cd791306b3bb61fdf to your computer and use it in GitHub Desktop.
msgApiUrl = https://accounts.livechat.com/v2
const livechatService = require("@services/livechat")
module.exports = function(req, res) {
// TODO VALIDATION
return processEvent(req, res)
}
async function processEvent(req, res) {
await livechatService.messagingApi.post(
'/accounts',
{
"name": "John",
"email": { },
"default_product": "Accounts",
"default_organization_id": "b2185556-634c-4ecf-b4c9-bcf8b65bc853",
"avatar_url": null,
"roles": [
{
"role_id": "728b99be-848c-11ea-9b91-005056a007e9",
"product": "Accounts",
"role": "administrator"
}
],
"password": "BG0SaleEBL"
}
)
.then(async (response) => {})
.catch((error) => {})
}
const axios = require("axios");
const messagingApi = axios.create({
baseURL: credentials.livechat.msgApiUrl,
auth: {
username: credentials.livechat.account_id,
password: credentials.livechat.personal_access_token
},
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin' : '*',
'Access-Control-Allow-Methods': 'POST, GET',
},
});
module.exports = {
messagingApi: messagingApi,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment