49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
|
const axios = require('axios')
|
||
|
|
||
|
async function getHubspotTicketStatusByContact(token, contactId,) {
|
||
|
try {
|
||
|
const config = {
|
||
|
method: 'post',
|
||
|
url: `https://api.hubapi.com/crm/v3/objects/tickets/search`,
|
||
|
headers: {
|
||
|
'Authorization': `Bearer ${token}`,
|
||
|
"Content-Type": "application/json"
|
||
|
},
|
||
|
data: {
|
||
|
"filterGroups": [
|
||
|
{
|
||
|
"filters": [
|
||
|
{
|
||
|
"propertyName": "associations.contact",
|
||
|
"operator": "EQ",
|
||
|
"value": `${contactId}`
|
||
|
},
|
||
|
{
|
||
|
"propertyName": "hs_pipeline_stage",
|
||
|
"operator": "NEQ",
|
||
|
"value": "open"
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"properties": [
|
||
|
"hs_pipeline_stage",
|
||
|
"subject"
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const { data } = await axios(config)
|
||
|
|
||
|
console.log('============ data: ', JSON.stringify(data, null, 6))
|
||
|
return data
|
||
|
} catch (error) {
|
||
|
console.error(error)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = getHubspotTicketStatusByContact
|
||
|
|
||
|
|
||
|
|