1.0.9 • Published 3 months ago

lightgate-hubspot-adapter v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

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

ObjectFeatureReturnsDescription
ContactlistAll()ArrayLists all contacts
ContactfindOne(id)ArrayFinds one contact by the email address
ContactfindOneOrCreate(data)ArrayFinds one contact by the email address and if not found creates a new contact
ContactassociateToCompany(data)booleanAssociates a contact to a hubspot company
ContactremoveOne(id)ArrayArchives a contact by an id

Company

ObjectFeatureReturnsDescription
CompanylistAll()ArrayLists all companies
CompanyfindOne(id)ArrayFinds one company by the domain example: boomi.com
CompanyfindOneOrCreate(data)ArrayFinds one company by the domain and if not found create one.
CompanyremoveOne(id)ArrayArchives a ccompany by the id

Deal

ObjectFeatureReturnsDescription
DeallistAll()ArrayLists all deals
1.0.9

3 months ago

1.0.8

3 months ago