wrong token changed and corrected
This commit is contained in:
1 parent
5dec745ab2
commit
bb01ec92ce
3 files changed
+11
-13
No files matched your search
@@ -6,9 +6,8 @@ async function createHubspotContacts(leadContact) {
|
||||
properties: {
|
||||
firstname: leadContact.firstname,
|
||||
lastname: leadContact.lastname,
|
||||
email: leadContact.contact.email,
|
||||
phone: leadContact.contact.phone,
|
||||
lead_source: 'Keystone'
|
||||
email: leadContact.contact?.email || '',
|
||||
phone: leadContact.contact?.phone || ''
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +28,8 @@ async function createHubspotContacts(leadContact) {
|
||||
return creationContact;
|
||||
}
|
||||
catch (error) {
|
||||
console.log('Error in creating the contacts.');
|
||||
console.error('Dettaglio Errore 400 HubSpot:', JSON.stringify(error.response?.data, null, 2) || error.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ async function getLeads() {
|
||||
console.log('File not found.');
|
||||
const defaultDate = new Date();
|
||||
defaultDate.setDate(defaultDate.getDate() - 7);
|
||||
lastRunDate = defaultDate.toISOString().split('T')[0];
|
||||
lastRunDate = defaultDate.toISOString().split('T')[0];
|
||||
}
|
||||
|
||||
const response = await fetch('https://smarthub.keystoneacademic.com/api/rest/getLead', {
|
||||
|
||||
@@ -19,11 +19,9 @@ async function initializeHubspotConnection() {
|
||||
hubspot.setClientSecret(auth.hClientSecret);
|
||||
hubspot.setRedirectUri(auth.hCallback);
|
||||
|
||||
if (!await hubspot.getAccessToken()) {
|
||||
console.log('No token found.')
|
||||
}
|
||||
else {
|
||||
console.log('Token loaded successfully');
|
||||
const currentToken = await hubspot.getAccessToken();
|
||||
if (!currentToken) {
|
||||
throw new Error('Refresh token not found in cfg/hubspot.json. Complete the authentication OAuth first via browser.');
|
||||
}
|
||||
|
||||
await hubspot.checkToken();
|
||||
@@ -67,9 +65,9 @@ async function runConnector() {
|
||||
console.log('Creation successful!');
|
||||
|
||||
// here we save the last time we ran the connector
|
||||
const currentDateTime = new Date().toISOString().split('T')[0];
|
||||
fs.writeFileSync(FILE_PATH, JSON.stringify({ lastRun: currentDateTime }, null, 2));
|
||||
console.log('DateTime saved successfully in file last-modified-date.json');
|
||||
//const currentDateTime = new Date().toISOString().split('T')[0];
|
||||
//fs.writeFileSync(FILE_PATH, JSON.stringify({ lastRun: currentDateTime }, null, 2));
|
||||
//console.log('DateTime saved successfully in file last-modified-date.json');
|
||||
|
||||
console.log('All contacts have been created!');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user