const express = require('express')
const router = express.Router()
const { authorization, } = require('../middleware/authentication')
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")

router.route('/create-contact').post(authorization, contactCreate)

router.route('/find-contact').post(authorization, checkContact)
router.route('/contact-activity').post(authorization, contactActivity)

router.route('/create-ticket').post(authorization, createTicket)
router.route('/call-journaling').post(authorization, callJournaling)
router.route('/upload').post(fileUpload.single('crm'), authorization, uploadCrmConfig)
router.route('/delete').post(authorization, deleteCrm)
router.route('/delete-company').post(authorization, deleteCompany)
router.route('/salesforce/case').post(authorization, sfCreateCase)
router.route('/salesforce/case').patch(authorization, sfUpdateCase)
router.route('/oauth-callback').get(oauthCallBack)
router.route('/install').get(install)
router.route('/test').post(testTemplate)
router.route('/webhook').post(webhook)
router.route('/webhook-crm').post(webhook_crm)
router.route('/:companyId').get(authorization, getCrms)


module.exports = router
