lightgate-hubspot-adapter
v1.0.9
Published
Lightgate Hubspot Adapter
Downloads
7
Readme
Lightgate Hubspot Adapter
This adapter converts the Hubspot api into ORMs for LightGate Automation developers.
Installation and Configuration
Install using npm:
npm i lightgate-hubspot-adapter
Create an instance of the adapter either in an automation or test. We are using a jest here to define a test:
import {LightgateHubspotAdapter} from 'lightgate-hubspot-adapter';
describe('Hubspot contact tests', () => {
let adapterInstance;
beforeAll(async () => {
try {
adapterInstance = new LightgateHubspotAdapter({ apiKey: process.env.HUBSPOT_SECRET_KEY,
packageDir: '../../..'});
await adapterInstance.initialize();
} catch (error) {
console.error('Error:', error.stack);
expect(true).toBe(false);
}
});
test('find all contacts test', async () => {
try {
const contacts = await adapterInstance.Contact.listAll();
expect(contacts).toBeInstanceOf(Array);
expect(contacts.length).toBeGreaterThan(0);
for (const contact of contacts) {
expect(customer).toBeInstanceOf(Contact);
}
} catch (error) {
console.error('Error:', error.stack);
expect(true).toBe(false);
}
});
});
Key Features
Contacts
Object | Feature | Returns | Description --- | --- | --- | --- Contact | listAll() | Array | Lists all contacts Contact | findOne(id) | Array | Finds one contact by the email address Contact | findOneOrCreate(data) | Array | Finds one contact by the email address and if not found creates a new contact Contact | associateToCompany(data) | boolean | Associates a contact to a hubspot company Contact | removeOne(id) | Array | Archives a contact by an id
Company
Object | Feature | Returns | Description --- | --- | --- | --- Company | listAll() | Array | Lists all companies Company | findOne(id) | Array | Finds one company by the domain example: boomi.com Company | findOneOrCreate(data) | Array | Finds one company by the domain and if not found create one. Company | removeOne(id) | Array | Archives a ccompany by the id
Deal
Object | Feature | Returns | Description --- | --- | --- | --- Deal | listAll() | Array | Lists all deals