Created
February 26, 2022 16:06
-
-
Save NickDeckerDevs/010706d73417610e133564544dd38b5e to your computer and use it in GitHub Desktop.
some comment/psuedo code for companies api to hubdb with google geocode location update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hubspot = require('@hubspot/api-client'); | |
exports.main = (event, callback) => { | |
const hubspotClient = new hubspot.Client({ | |
apiKey: process.env.HAPIKEY | |
}); | |
hubspotClient.crm.companies.basicApi.getById(event.object.objectId, ['name', 'address', 'zip', 'etc']) | |
.then(results => { | |
// break down items and combine into a full address | |
const googleAddress = '1401 SW 14th Ter., Cape Coral, FL 33991' | |
const url = `https://maps.googleapis.com/maps/api/geocode/json?address=${googleAddress}&key=${GAPIKEY}` | |
// send async/await call to geocode api | |
// this returns the latitude and longitude | |
const returnValue = `26.625833,-82.003223` | |
// now use hubdb api to send the data to the table | |
// https://legacydocs.hubspot.com/docs/methods/hubdb/v2/create_row | |
hubspotClient.... | |
// if successful change property company.location_sent to updated | |
// if not successful, then change property company.location to error | |
}) | |
.catch(err => { | |
console.error(err); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment