Created
June 17, 2022 07:23
-
-
Save aasumitro/ef4a1c352dbf764cd791306b3bb61fdf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msgApiUrl = https://accounts.livechat.com/v2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) => {}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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