UNPKG

get-top-countries-of-clients-hubspot

Version:

A demo package that allows you to match retrieve top countries of clients from IP Pilot's database and save it for every company in your Hubspot account.

22 lines (17 loc) 756 B
'use strict'; const { getAllHubspotCompanies } = require('get-all-hubspot-companies'); const hsCompaniesProps = ['name', 'hubspot_owner_id', 'hs_object_id', 'master', 'ip_pilot_name']; const getHubspotCompanies = async (hubspotApiKey) => { const hsCompanies = await getAllHubspotCompanies(hubspotApiKey, hsCompaniesProps); return hsCompanies .filter( (company) => company.properties.name && company.properties.ip_pilot_name && company.properties.ip_pilot_name.value.length ) .map((el) => ({ companyName: el.properties.name.value, companyId: Number(el.companyId), targets: el.properties.ip_pilot_name.value.split('\n'), })) .filter((el) => el.targets.length); }; module.exports = { getHubspotCompanies };