Compare commits
No commits in common. "526c016b997bbc77dca748de62da1a5e1c992fb3" and "f05bfa4047fbb84348712848544e093f3b93f960" have entirely different histories.
526c016b99
...
f05bfa4047
|
@ -1,154 +0,0 @@
|
||||||
{
|
|
||||||
"authentication": {
|
|
||||||
"type": "oauth2",
|
|
||||||
"crmClientId": "3MVG97ZwUE6kNctcTD24tyRZJXLWfClkMmmH5wvnTw8b6EW92uMPeaYOpyyWyzjx_klDcVt7F2nF2jbluycT4",
|
|
||||||
"crmClientSecret": "FBA2860ECEAC86A3CED77841A0BD6B26AFD3E7F202C0241D534716B90E8C12AD",
|
|
||||||
"crmScopes": "full refresh_token",
|
|
||||||
"crmPhoneTest": "5511988334455"
|
|
||||||
},
|
|
||||||
"crmRest": [
|
|
||||||
{
|
|
||||||
"authorizationEndpoint": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "empty",
|
|
||||||
"requestEncoding": "empty",
|
|
||||||
"requestType": "Get",
|
|
||||||
"responseType": "empty",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/oauth2/authorize?response_type=code&client_id=crmClientId&code_challenge=bDXEJ0wxr0s369lGxHwewLULiOuyl6Y3W7QZABmn2S4&redirect_uri=crmRedirectURI&scope=crmScopes&code_challenge_method=S256"
|
|
||||||
},
|
|
||||||
"body": {},
|
|
||||||
"response": {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tokenEndpoint": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "none",
|
|
||||||
"requestEncoding": "Json",
|
|
||||||
"requestType": "Post",
|
|
||||||
"responseType": "Json",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/oauth2/token"
|
|
||||||
},
|
|
||||||
"body": {},
|
|
||||||
"response": {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"createContactRecord": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "application/json",
|
|
||||||
"requestEncoding": "Json",
|
|
||||||
"requestType": "Post",
|
|
||||||
"responseType": "Json",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/data/v61.0/sobjects/Contact"
|
|
||||||
},
|
|
||||||
"body": {
|
|
||||||
"Phone": "crmPhone",
|
|
||||||
"LastName": "crmLastName",
|
|
||||||
"FirstName": "crmFirstName",
|
|
||||||
"Time_Zone__c": "America/Sao_Paulo"
|
|
||||||
},
|
|
||||||
"response": {
|
|
||||||
"id": "id"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"lookupContactByPhone": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "application/json",
|
|
||||||
"requestEncoding": "Json",
|
|
||||||
"requestType": "Get",
|
|
||||||
"responseType": "Json",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/data/v61.0/query/?q=SELECT+Id,+Phone+FROM+Contact+WHERE+Phone='crmPhone'"
|
|
||||||
},
|
|
||||||
"response": {
|
|
||||||
"phone": "records[0].Phone",
|
|
||||||
"id": "records[0].Id"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"callJournaling": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "application/json",
|
|
||||||
"requestEncoding": "Json",
|
|
||||||
"requestType": "Post",
|
|
||||||
"responseType": "Json",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/data/v61.0/sobjects/Task"
|
|
||||||
},
|
|
||||||
"calls": [
|
|
||||||
{
|
|
||||||
"inboundAnsweredCall": {
|
|
||||||
"Subject": "Call Journal",
|
|
||||||
"WhoId": "crmContactId",
|
|
||||||
"Description": "Ligação recebida",
|
|
||||||
"Status": "Completed",
|
|
||||||
"Priority": "Normal",
|
|
||||||
"CallType": "Outbound",
|
|
||||||
"CallDurationInSeconds": {
|
|
||||||
"_prop": "crmCallDuration",
|
|
||||||
"_type": "number",
|
|
||||||
"_format": "seconds"
|
|
||||||
},
|
|
||||||
"ActivityDate": "YYYY-MM-DD",
|
|
||||||
"TaskSubtype": "Call"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"inboundMissedCall": {
|
|
||||||
"Subject": "Call Journal",
|
|
||||||
"WhoId": "crmContactId",
|
|
||||||
"Description": "Ligação recebida perdida",
|
|
||||||
"Status": "Completed",
|
|
||||||
"Priority": "Normal",
|
|
||||||
"CallType": "Outbound",
|
|
||||||
"CallDurationInSeconds": {
|
|
||||||
"_prop": "crmCallDuration",
|
|
||||||
"_type": "number",
|
|
||||||
"_format": "seconds"
|
|
||||||
},
|
|
||||||
"ActivityDate": "YYYY-MM-DD",
|
|
||||||
"TaskSubtype": "Call"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"outboundAnsweredCall": {
|
|
||||||
"Subject": "Call Journal",
|
|
||||||
"WhoId": "crmContactId",
|
|
||||||
"Description": "Ligação realizada",
|
|
||||||
"Status": "Completed",
|
|
||||||
"Priority": "Normal",
|
|
||||||
"CallType": "Outbound",
|
|
||||||
"CallDurationInSeconds": {
|
|
||||||
"_prop": "crmCallDuration",
|
|
||||||
"_type": "number",
|
|
||||||
"_format": "seconds"
|
|
||||||
},
|
|
||||||
"ActivityDate": "YYYY-MM-DD",
|
|
||||||
"TaskSubtype": "Call"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"outboundUnansweredCall": {
|
|
||||||
"Subject": "Call Journal",
|
|
||||||
"WhoId": "crmContactId",
|
|
||||||
"Description": "Ligação realizada nao atendida",
|
|
||||||
"Status": "Completed",
|
|
||||||
"Priority": "Normal",
|
|
||||||
"CallType": "Outbound",
|
|
||||||
"CallDurationInSeconds": {
|
|
||||||
"_prop": "crmCallDuration",
|
|
||||||
"_type": "number",
|
|
||||||
"_format": "seconds"
|
|
||||||
},
|
|
||||||
"ActivityDate": "YYYY-MM-DD",
|
|
||||||
"TaskSubtype": "Call"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"response": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,201 +0,0 @@
|
||||||
{
|
|
||||||
"authentication": {
|
|
||||||
"type": "oauth2",
|
|
||||||
"crmClientId": "3MVG97ZwUE6kNctcTD24tyRZJXLWfClkMmmH5wvnTw8b6EW92uMPeaYOpyyWyzjx_klDcVt7F2nF2jbluycT4",
|
|
||||||
"crmClientSecret": "FBA2860ECEAC86A3CED77841A0BD6B26AFD3E7F202C0241D534716B90E8C12AD",
|
|
||||||
"crmScopes": "full refresh_token",
|
|
||||||
"crmPhoneTest": "5517988335455"
|
|
||||||
},
|
|
||||||
"crmRest": [
|
|
||||||
{
|
|
||||||
"authorizationEndpoint": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "empty",
|
|
||||||
"requestEncoding": "empty",
|
|
||||||
"requestType": "Get",
|
|
||||||
"responseType": "empty",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/oauth2/authorize?response_type=code&client_id=crmClientId&code_challenge=bDXEJ0wxr0s369lGxHwewLULiOuyl6Y3W7QZABmn2S4&redirect_uri=crmRedirectURI&scope=crmScopes&code_challenge_method=S256"
|
|
||||||
},
|
|
||||||
"body": {},
|
|
||||||
"response": {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tokenEndpoint": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "none",
|
|
||||||
"requestEncoding": "Json",
|
|
||||||
"requestType": "Post",
|
|
||||||
"responseType": "Json",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/oauth2/token"
|
|
||||||
},
|
|
||||||
"body": {},
|
|
||||||
"response": {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"createContactRecord": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "application/json",
|
|
||||||
"requestEncoding": "Json",
|
|
||||||
"requestType": "Post",
|
|
||||||
"responseType": "Json",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/data/v61.0/sobjects/Lead"
|
|
||||||
},
|
|
||||||
"body": {
|
|
||||||
"Phone": "crmPhone",
|
|
||||||
"LastName": "crmLastName",
|
|
||||||
"FirstName": "crmFirstName",
|
|
||||||
"LeadSource": "WhatsApp",
|
|
||||||
"Country_Segmentation__c": "Brazil",
|
|
||||||
"CurrencyIsoCode": "BRL",
|
|
||||||
"RecordTypeId": "0120b000000OhSqAAK"
|
|
||||||
},
|
|
||||||
"response": {
|
|
||||||
"id": "id"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"lookupContactByPhone": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "application/json",
|
|
||||||
"requestEncoding": "Json",
|
|
||||||
"requestType": "Get",
|
|
||||||
"responseType": "Json",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/data/v61.0/query/?q=SELECT+Id,Phone+FROM+Lead+WHERE+Phone='crmPhone'"
|
|
||||||
},
|
|
||||||
"response": {
|
|
||||||
"phone": "records[0].Phone",
|
|
||||||
"id": "records[0].Id"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"callJournaling": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "application/json",
|
|
||||||
"requestEncoding": "Json",
|
|
||||||
"requestType": "Post",
|
|
||||||
"responseType": "Json",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/data/v61.0/sobjects/Task"
|
|
||||||
},
|
|
||||||
"calls": [
|
|
||||||
{
|
|
||||||
"inboundAnsweredCall": {
|
|
||||||
"Subject": "Call Journal",
|
|
||||||
"WhoId": "crmContactId",
|
|
||||||
"Description": "Ligação recebida",
|
|
||||||
"Status": "Completed",
|
|
||||||
"Priority": "Normal",
|
|
||||||
"CallType": "Outbound",
|
|
||||||
"CallDurationInSeconds": {
|
|
||||||
"_prop": "crmCallDuration",
|
|
||||||
"_type": "number",
|
|
||||||
"_format": "seconds"
|
|
||||||
},
|
|
||||||
"ActivityDate": "YYYY-MM-DD",
|
|
||||||
"TaskSubtype": "Call"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"inboundMissedCall": {
|
|
||||||
"Subject": "Call Journal",
|
|
||||||
"WhoId": "crmContactId",
|
|
||||||
"Description": "Ligação recebida perdida",
|
|
||||||
"Status": "Completed",
|
|
||||||
"Priority": "Normal",
|
|
||||||
"CallType": "Outbound",
|
|
||||||
"CallDurationInSeconds": {
|
|
||||||
"_prop": "crmCallDuration",
|
|
||||||
"_type": "number",
|
|
||||||
"_format": "seconds"
|
|
||||||
},
|
|
||||||
"ActivityDate": "YYYY-MM-DD",
|
|
||||||
"TaskSubtype": "Call"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"outboundAnsweredCall": {
|
|
||||||
"Subject": "Call Journal",
|
|
||||||
"WhoId": "crmContactId",
|
|
||||||
"Description": "Ligação realizada",
|
|
||||||
"Status": "Completed",
|
|
||||||
"Priority": "Normal",
|
|
||||||
"CallType": "Outbound",
|
|
||||||
"CallDurationInSeconds": {
|
|
||||||
"_prop": "crmCallDuration",
|
|
||||||
"_type": "number",
|
|
||||||
"_format": "seconds"
|
|
||||||
},
|
|
||||||
"ActivityDate": "YYYY-MM-DD",
|
|
||||||
"TaskSubtype": "Call"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"outboundUnansweredCall": {
|
|
||||||
"Subject": "Call Journal",
|
|
||||||
"WhoId": "crmContactId",
|
|
||||||
"Description": "Ligação realizada nao atendida",
|
|
||||||
"Status": "Completed",
|
|
||||||
"Priority": "Normal",
|
|
||||||
"CallType": "Outbound",
|
|
||||||
"CallDurationInSeconds": {
|
|
||||||
"_prop": "crmCallDuration",
|
|
||||||
"_type": "number",
|
|
||||||
"_format": "seconds"
|
|
||||||
},
|
|
||||||
"ActivityDate": "YYYY-MM-DD",
|
|
||||||
"TaskSubtype": "Call"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"response": {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"chatJournaling": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "application/json",
|
|
||||||
"requestEncoding": "Json",
|
|
||||||
"requestType": "Post",
|
|
||||||
"responseType": "Json",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/data/v61.0/sobjects/Task"
|
|
||||||
},
|
|
||||||
"chats": [
|
|
||||||
{
|
|
||||||
"chatDone": {
|
|
||||||
"WhoId": "crmContactId",
|
|
||||||
"Subject": "Other",
|
|
||||||
"Description": "Conversation started via WhatsApp. Conversation link: chatLink",
|
|
||||||
"ActivityDate": "YYYY-MM-DD",
|
|
||||||
"Status": "Completed",
|
|
||||||
"Priority": "Normal"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"createCase": {
|
|
||||||
"request": {
|
|
||||||
"requestContentType": "application/json",
|
|
||||||
"requestEncoding": "Json",
|
|
||||||
"requestType": "Post",
|
|
||||||
"responseType": "Json",
|
|
||||||
"url": "https://berlitz--blzlatam.sandbox.my.salesforce.com/services/data/v61.0/sobjects/Case"
|
|
||||||
},
|
|
||||||
"body": {
|
|
||||||
"Subject": "Assunto do Caso teste",
|
|
||||||
"Description": "Descrição detalhada do caso test",
|
|
||||||
"Status": "Novo",
|
|
||||||
"Priority": "Alta",
|
|
||||||
"Departamento__c": "Financeiro"
|
|
||||||
},
|
|
||||||
"response": {
|
|
||||||
"id": "id"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -12,8 +12,7 @@ const { createCRMContact,
|
||||||
journalingRequest,
|
journalingRequest,
|
||||||
createContact,
|
createContact,
|
||||||
lookupContactByPhone,
|
lookupContactByPhone,
|
||||||
templateValidator,
|
templateValidator } = require('../utils')
|
||||||
loadCRM } = require('../utils')
|
|
||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const { URL } = require('url')
|
const { URL } = require('url')
|
||||||
const { oauth2 } = require('../utils')
|
const { oauth2 } = require('../utils')
|
||||||
|
@ -36,53 +35,16 @@ const getSalesforceUser = require('../utils/getSalesforceUser')
|
||||||
|
|
||||||
const contactCreate = async (req, res) => {
|
const contactCreate = async (req, res) => {
|
||||||
|
|
||||||
const { companyId, crmFirstName, crmLastName, crmPhone, crmEmail, dynamicBodyRequest } = req.body
|
const { companyId, crmFirstName, crmLastName, crmPhone, crmEmail } = req.body
|
||||||
|
|
||||||
mustContainProperties(req, ['companyId', 'crmPhone',])
|
mustContainProperties(req, ['companyId', 'crmPhone',])
|
||||||
|
|
||||||
await createCRMContact(companyId, crmFirstName, crmPhone, crmEmail, crmLastName, dynamicBodyRequest)
|
await createCRMContact(companyId, crmFirstName, crmPhone, crmEmail, crmLastName)
|
||||||
|
|
||||||
res.status(StatusCodes.OK).send()
|
res.status(StatusCodes.OK).send()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkContact = async (req, res) => {
|
|
||||||
|
|
||||||
const { companyId, crmPhone } = req.body
|
|
||||||
|
|
||||||
mustContainProperties(req, ['companyId', 'crmPhone',])
|
|
||||||
|
|
||||||
const crmFiles = await loadCRM(companyId)
|
|
||||||
|
|
||||||
if (crmFiles.length > 0) {
|
|
||||||
const { crmRest: rest, authentication } = crmFiles[0].crm
|
|
||||||
|
|
||||||
const contact = await lookupContactByPhone(rest, authentication, crmPhone, companyId)
|
|
||||||
|
|
||||||
if (contact && contact.exist) {
|
|
||||||
return res.status(StatusCodes.OK).json({ exist: contact.exist })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
res.status(StatusCodes.OK).json({ exist: false })
|
|
||||||
}
|
|
||||||
|
|
||||||
const contactActivity = async (req, res) => {
|
|
||||||
const { companyId, crmPhone, ticketId } = req.body
|
|
||||||
|
|
||||||
mustContainProperties(req, ['companyId', 'crmPhone', 'ticketId'])
|
|
||||||
|
|
||||||
await whatsappJournalingCRM(
|
|
||||||
companyId,
|
|
||||||
crmPhone,
|
|
||||||
'0000',
|
|
||||||
crmFirstName = "unnamed",
|
|
||||||
ticketId
|
|
||||||
)
|
|
||||||
|
|
||||||
res.status(StatusCodes.OK).send()
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteCrm = async (req, res) => {
|
const deleteCrm = async (req, res) => {
|
||||||
|
|
||||||
let { companyId, crmBaseURL } = req.body
|
let { companyId, crmBaseURL } = req.body
|
||||||
|
@ -607,9 +569,7 @@ module.exports = {
|
||||||
webhook_crm,
|
webhook_crm,
|
||||||
sfCreateCase,
|
sfCreateCase,
|
||||||
sfUpdateCase,
|
sfUpdateCase,
|
||||||
createTicket,
|
createTicket
|
||||||
checkContact,
|
|
||||||
contactActivity
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
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 } = require('../controllers/crmController')
|
const { contactCreate, 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)
|
||||||
|
|
||||||
router.route('/find-contact').post(authorization, checkContact)
|
|
||||||
router.route('/contact-activity').post(authorization, contactActivity)
|
|
||||||
|
|
||||||
router.route('/create-ticket').post(authorization, createTicket)
|
router.route('/create-ticket').post(authorization, createTicket)
|
||||||
router.route('/call-journaling').post(authorization, callJournaling)
|
router.route('/call-journaling').post(authorization, callJournaling)
|
||||||
router.route('/upload').post(fileUpload.single('crm'), authorization, uploadCrmConfig)
|
router.route('/upload').post(fileUpload.single('crm'), authorization, uploadCrmConfig)
|
||||||
|
|
|
@ -2,7 +2,7 @@ const lookupContactByPhone = require('./lookupCRMContactByPhone')
|
||||||
const createContact = require('./createContact')
|
const createContact = require('./createContact')
|
||||||
const loadCRM = require('./loadCRM')
|
const loadCRM = require('./loadCRM')
|
||||||
|
|
||||||
async function createCRMContact(companyId, crmFirstName, crmPhone, crmEmail = '', crmLastName = '', dynamicBodyRequest = {}) {
|
async function createCRMContact(companyId, crmFirstName, crmPhone, crmEmail = '', crmLastName = '',) {
|
||||||
|
|
||||||
const crmFiles = await loadCRM(companyId)
|
const crmFiles = await loadCRM(companyId)
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ async function createCRMContact(companyId, crmFirstName, crmPhone, crmEmail = ''
|
||||||
|
|
||||||
if (contact.exist) continue
|
if (contact.exist) continue
|
||||||
|
|
||||||
await createContact(companyId, rest, authentication, crmPhone, crmFirstName, crmLastName, crmEmail, {}, dynamicBodyRequest)
|
await createContact(companyId, rest, authentication, crmPhone, crmFirstName, crmLastName, crmEmail,)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ const CRM = require('../models/CRM')
|
||||||
const requestConfigHeader = require('./requestConfigHeader')
|
const requestConfigHeader = require('./requestConfigHeader')
|
||||||
const sendMessageSocket = require('./sendMessageSocket')
|
const sendMessageSocket = require('./sendMessageSocket')
|
||||||
|
|
||||||
async function createContact(companyId, rest, authentication, crmPhone, crmFirstName = 'Username', crmLastName = 'Last name', crmEmail = '', test = {}, dynamicBodyRequest = {}) {
|
async function createContact(companyId, rest, authentication, crmPhone, crmFirstName = 'Username', crmLastName = 'Last name', crmEmail = '', test = {}) {
|
||||||
let { request, body, response } = findProperty(rest, 'createContactRecord')
|
let { request, body, response } = findProperty(rest, 'createContactRecord')
|
||||||
|
|
||||||
const { requestContentType, requestEncoding, requestType, responseType, url } = request
|
const { requestContentType, requestEncoding, requestType, responseType, url } = request
|
||||||
|
@ -42,7 +42,7 @@ async function createContact(companyId, rest, authentication, crmPhone, crmFirst
|
||||||
const { type, userName, passWord, token, crmClientId } = authentication
|
const { type, userName, passWord, token, crmClientId } = authentication
|
||||||
|
|
||||||
//url, crmPhone, requestType, requestContentType, type, userName, passWord, token, crmClientId, data = '', ticketId = '', companyId
|
//url, crmPhone, requestType, requestContentType, type, userName, passWord, token, crmClientId, data = '', ticketId = '', companyId
|
||||||
let config = await requestConfigHeader(url, crmPhone, requestType, requestContentType, type, userName, passWord, token, crmClientId, body, '', companyId)
|
const config = await requestConfigHeader(url, crmPhone, requestType, requestContentType, type, userName, passWord, token, crmClientId, body, '', companyId)
|
||||||
|
|
||||||
if (test?.testing) {
|
if (test?.testing) {
|
||||||
msg = `Tentanto criar contato de numero ${crmPhone} no crm`
|
msg = `Tentanto criar contato de numero ${crmPhone} no crm`
|
||||||
|
@ -53,13 +53,6 @@ async function createContact(companyId, rest, authentication, crmPhone, crmFirst
|
||||||
console.log('CREATE CONTACT PAYLOAD: ', JSON.stringify(config, null, 6))
|
console.log('CREATE CONTACT PAYLOAD: ', JSON.stringify(config, null, 6))
|
||||||
console.log('#####################')
|
console.log('#####################')
|
||||||
|
|
||||||
if (dynamicBodyRequest && Object.keys(dynamicBodyRequest) !== 0) {
|
|
||||||
config.data = { ...config.data, ...dynamicBodyRequest }
|
|
||||||
console.log('#####################')
|
|
||||||
console.log('CREATE CONTACT PAYLOAD UPDATED BY DYNAMIC BODY REQUEST: ', JSON.stringify(config, null, 6))
|
|
||||||
console.log('#####################')
|
|
||||||
}
|
|
||||||
|
|
||||||
let data
|
let data
|
||||||
try {
|
try {
|
||||||
let { data: _data } = await axios(config)
|
let { data: _data } = await axios(config)
|
||||||
|
|
Loading…
Reference in New Issue