Compare commits
No commits in common. "26704767ba900ea6bcd86df0a9d12786031b7178" and "526c016b997bbc77dca748de62da1a5e1c992fb3" have entirely different histories.
26704767ba
...
526c016b99
|
@ -17,7 +17,7 @@ const { createCRMContact,
|
||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const { URL } = require('url')
|
const { URL } = require('url')
|
||||||
const { oauth2 } = require('../utils')
|
const { oauth2 } = require('../utils')
|
||||||
const { exchangeForTokens, getAccessToken } = oauth2
|
const { exchangeForTokens } = oauth2
|
||||||
const Company = require('../models/Company')
|
const Company = require('../models/Company')
|
||||||
const CRM = require('../models/CRM')
|
const CRM = require('../models/CRM')
|
||||||
const CustomError = require('../errors')
|
const CustomError = require('../errors')
|
||||||
|
@ -591,23 +591,6 @@ const webhook_crm = async (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.set('Content-Type', 'text/xml').status(StatusCodes.OK).send(responseXml)
|
return res.set('Content-Type', 'text/xml').status(StatusCodes.OK).send(responseXml)
|
||||||
}
|
|
||||||
|
|
||||||
const getClientAccessToken = async (req, res) => {
|
|
||||||
const { companyId } = req.params
|
|
||||||
const { clientId } = req.body;
|
|
||||||
console.log('========> getClientAccessToken companyId: ', companyId, ' clientId: ', clientId);
|
|
||||||
|
|
||||||
mustContainProperties(req, ['clientId']);
|
|
||||||
|
|
||||||
const accessToken = await getAccessToken(clientId, companyId);
|
|
||||||
|
|
||||||
if (!accessToken) {
|
|
||||||
console.error(`Access token not found for companyId: ${companyId} and clientId: ${clientId}`);
|
|
||||||
return res.status(StatusCodes.NOT_FOUND).send({ msg: "Access token not found!" });
|
|
||||||
}
|
|
||||||
|
|
||||||
return res.status(StatusCodes.OK).json({ accessToken });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -626,8 +609,7 @@ module.exports = {
|
||||||
sfUpdateCase,
|
sfUpdateCase,
|
||||||
createTicket,
|
createTicket,
|
||||||
checkContact,
|
checkContact,
|
||||||
contactActivity,
|
contactActivity
|
||||||
getClientAccessToken
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
const { authorization, } = require('../middleware/authentication')
|
const { authorization, } = require('../middleware/authentication')
|
||||||
const { contactCreate, contactActivity, checkContact, sfCreateCase, sfUpdateCase, createTicket, testTemplate, webhook_crm, uploadCrmConfig, callJournaling, oauthCallBack, install, deleteCrm, deleteCompany, getCrms, webhook, getClientAccessToken } = require('../controllers/crmController')
|
const { contactCreate, contactActivity, checkContact, sfCreateCase, sfUpdateCase, createTicket, testTemplate, webhook_crm, uploadCrmConfig, callJournaling, oauthCallBack, install, deleteCrm, deleteCompany, getCrms, webhook } = require('../controllers/crmController')
|
||||||
const { fileUpload } = require("../utils")
|
const { fileUpload } = require("../utils")
|
||||||
|
|
||||||
router.route('/create-contact').post(authorization, contactCreate)
|
router.route('/create-contact').post(authorization, contactCreate)
|
||||||
|
@ -22,7 +22,6 @@ router.route('/test').post(testTemplate)
|
||||||
router.route('/webhook').post(webhook)
|
router.route('/webhook').post(webhook)
|
||||||
router.route('/webhook-crm').post(webhook_crm)
|
router.route('/webhook-crm').post(webhook_crm)
|
||||||
router.route('/:companyId').get(authorization, getCrms)
|
router.route('/:companyId').get(authorization, getCrms)
|
||||||
router.route('/:companyId/access-token').get(authorization, getClientAccessToken)
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|
Loading…
Reference in New Issue