public class

HubSpotConnector

extends Object
java.lang.Object
   ↳ org.mule.module.hubspot.HubSpotConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

HubSpot all-in-one marketing software helps more than 8,000 companies in 56 countries attract leads and convert them into customers. A pioneer in inbound marketing, HubSpot aims to help its customers make marketing that people actually love.

The connector is using the version "v1" of the HubSpot API.

The documentation of the API can be found in this link

The main flow of the connector is "authentication" ---> HubSpot Login Page ----> "authenticationResponse" ----> Any other process of the connector

Summary

Constants
String API_VERSION
String HUB_SPOT_URL_API
String HUB_SPOT_URL_AUTH
Fields
private static final Pattern OFFLINE_SCOPE_PATTER
private String callbackUrl The callbackUrl is the endpoint that is registered in the iApp to handle the response of the authorization call.
private String clientId Your Client ID (OAuth Client ID), which identifies who you are.
private HubSpotClientsManager clientsManager
private HubSpotCredentialsManager credentialsManager
private String hubId The HubSpot portal ID of the customer that you're re-directing.
private static final Log logger
private ObjectStore objectStore The object store to store the user credentials
private String scope The scopes (or permissions) you want.
Public Constructors
HubSpotConnector()
Public Methods
HubSpotListAddContactToListResponse addExistingContactInAList(String userId, String listId, String contactId)
Add a contact record that has already been created in the system to a contact list.
String authenticate(String userId, String callbackUrl, String clientId, String hubId, String scope, Map<String, Object> headers)
/** This process generates the URL required to authenticate against the service.
String authenticateResponse(String inputRequest)
This process is the one that handles the response of the authentication process.
Contact createContact(String userId, ContactProperties contactProperties)
Create a new contact in HubSpot with a simple HTTP POST to the Contacts API.
HubSpotList createContactList(String userId, HubSpotNewList list, List<HubSpotListFilters> filters)
Create a new list in a given HubSpot portal to populate with contacts.
CustomContactProperty createCustomProperty(String userId, CustomContactProperty contactProperty)
Create a new property in HubSpot.
CustomContactPropertyGroup createCustomPropertyGroup(String userId, CustomContactPropertyGroup customContactPropertyGroup)
For a given portal, create a new contact proprerty group.
ContactDeleted deleteContact(String userId, String contactId)
Archive an existing contact from a particular HubSpot portal.
void deleteCustomProperty(String userId, String contactPropertyName)
Delete an existing property in HubSpot.
void deleteCustomPropertyGroup(String userId, String groupName)
For a given portal, delete a contact property group based on the name of the group.
ContactList getAllContacts(String userId, String count, String contactOffset)
For a given portal, return all contacts that have been created in the portal.
List<CustomContactProperty> getAllCustomProperties(String userId)
Properties in HubSpot are fields that have been created.
String getCallbackUrl()
String getClientId()
HubSpotClientsManager getClientsManager()
Contact getContactByEmail(String userId, String contactEmail)
For a given portal, return information about a single contact by its email address.
Contact getContactById(String userId, String contactId)
For a given portal, return information about a single contact by its ID.
Contact getContactByUserToken(String userId, String contactUserToken)
For a given portal, return information about a single contact by its User Token (hubspotutk)

API link: http://developers.hubspot.com/docs/methods/contacts/get_contact_by_utk

HubSpotList getContactListById(String userId, String listId)
For a given portal, return a contact list by its unique ID.
ContactStatistics getContactStatistics(String userId)
For a given portal, return statistics about that portal's contacts.
ContactQuery getContactsByQuery(String userId, String query, String count)
For a given portal, return contacts and some data associated with those contacts by the contact's email address or name.
ContactList getContactsInAList(String userId, String listId, String count, String property, String offset)
For a given portal and a given list, identified by its unique ID, return a list of contacts that are in that list.
HubSpotListLists getContactsLists(String userId, String count, String offset)
For a given portal, return a set of contact lists that you specify with the count parameter.
HubSpotCredentialsManager getCredentialsManager()
CustomContactPropertyGroup getCustomPropertyGroup(String userId, String groupName)
For a given portal, return all contact property groups that have been created in the portal.
HubSpotListLists getDynamicContactLists(String userId, String count, String offset)
For a given portal, return a set of dynamic contact lists that you specify with the count parameter.
EmailSubscriptionStatus getEmailSubscriptionStatus(String userId, String hubId, String email)
For a given portal, return all email subscription information for the given email address and portal.
EmailSubscription getEmailSubscriptions(String userId, String hubId)
For a given portal, return all email subscription types that have been created in the portal.
String getHubId()
ObjectStore getObjectStore()
ContactList getRecentContacts(String userId, String count, String timeOffset, String contactOffset)
For a given portal, return all contacts that have been recently updated or created.
String getScope()
boolean hasUserAccessToken(String userId)
Check if the User has an Access Token.
void initialize()
void setCallbackUrl(String callbackUrl)
void setClientId(String clientId)
void setClientsManager(HubSpotClientsManager clientsManager)
void setCredentialsManager(HubSpotCredentialsManager credentialsManager)
void setHubId(String hubId)
void setObjectStore(ObjectStore objectStore)
void setScope(String scope)
ContactProperties updateContact(String userId, String contactId, ContactProperties contactProperties)
Update an existing contact in HubSpot.
CustomContactProperty updateCustomProperty(String userId, String propertyName, CustomContactProperty contactProperty)
Update an existing property in HubSpot.
CustomContactPropertyGroup updateCustomPropertyGroup(String userId, String groupName, CustomContactPropertyGroup customContactPropertyGroup)
For a given portal, update a contact property group.
EmailSubscriptionStatusResult updateEmailSubscriptionStatus(String userId, String hubId, String email, List<EmailSubscriptionStatusStatuses> statuses)
For a given email address and portal, update the email type subscription status.
EmailSubscriptionStatusResult updateEmailSubscriptionStatusUnsubscribeFromAll(String userId, String hubId, String email)
For a given email address and portal, update the email type subscription unsuscribing from all emails NOTE: it is only possible to opt email addresses OUT of subscription and there is NO UNDO for this operation.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String API_VERSION

Constant Value: "v1"

public static final String HUB_SPOT_URL_API

Constant Value: "http://hubapi.com"

public static final String HUB_SPOT_URL_AUTH

Constant Value: "https://app.hubspot.com/auth/authenticate"

Fields

private static final Pattern OFFLINE_SCOPE_PATTER

private String callbackUrl

The callbackUrl is the endpoint that is registered in the iApp to handle the response of the authorization call. This endpoint also has to direct to the handleAuthentication process of the connector

Note:This param is now optional because it can be specified in the Authenticate or in here (config)

private String clientId

Your Client ID (OAuth Client ID), which identifies who you are. You can access the client_id in your app's developer dashboard under the Summary section.

Note:This param is now optional because it can be specified in the Authenticate or in here (config)

private HubSpotClientsManager clientsManager

private HubSpotCredentialsManager credentialsManager

private String hubId

The HubSpot portal ID of the customer that you're re-directing. You will need to get the portal ID from the customer who you're making the request for.

In order to find the Hub ID follow this link: http://help.hubspot.com/articles/How_To_Doc/How-to-find-your-hub-id

Note:This param is now optional because it can be specified in the Authenticate or in here (config)

private static final Log logger

private ObjectStore objectStore

The object store to store the user credentials

private String scope

The scopes (or permissions) you want. These should match your application settings in the Marketplace. Separate more than one scope with an space character "Ex:scope-a offline"

Important: the scope offline provides the ability to refresh the token automatically once this has expired. If you do not specify this scope, once the token expires the call to a process will throw a HubSpotConnectorAccessTokenExpiredException

Note: the scope required in the authentication must be supported by the application. This can be checked in the Application Settings, under Scopes

For a complete list of the available scopes check this link: http://developers.hubspot.com/auth/oauth_scopes

Note:This param is now optional because it can be specified in the Authenticate or in here (config)

Public Constructors

public HubSpotConnector ()

Public Methods

public HubSpotListAddContactToListResponse addExistingContactInAList (String userId, String listId, String contactId)

Add a contact record that has already been created in the system to a contact list.

Please note that you cannot manually add (via this API call) contacts to dynamic lists - they can only be updated by the contacts app.

API link: http://developers.hubspot.com/docs/methods/lists/add_contact_to_list

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
listId You need to include the ID for the list you're adding the lead to. You can search for lists using the get lists method.
contactId The contact ID of the contact that you're adding to the list.
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public String authenticate (String userId, String callbackUrl, String clientId, String hubId, String scope, Map<String, Object> headers)

/** This process generates the URL required to authenticate against the service.

Important: in order for the full authentication to work, the callbackUrl in the configuration must be pointing to another flow that has the authenticateResponse process to handle the reception of the token

Parameters
userId This user identifier it is the one that will we used from now on to the successive calls to the process of this connector for this user
callbackUrl Use this callback instead the one in the configuration
clientId Use this clientId instead the one in the configuration
hubId Use this hubId instead the one in the configuration
scope Use this scope instead the one in the configuration
headers This are added implicitly by Studio. The headers of the HTTP inbound, so it can establish a redirect code (302)
Returns
  • The URL where the user will be redirected
Throws
HubSpotConnectorException If occur some error trying to generate the URL or the userId is empty it will throw this exception.
HubSpotConnectorNoAccessTokenException If there is not an access_token in the response it will throw this exception.

public String authenticateResponse (String inputRequest)

This process is the one that handles the response of the authentication process. It should be inside an HTTP inbound which url must be the same that the one pointed by the callbackUrl in the configuration in order to get the access_token provided by the service.

Parameters
inputRequest The input parameters that came with the response to the authenticate process
Returns
  • The UserID that you provided in the call to the authenticate process and that is the one that the user is going to provide in order than the connector use their credentials
Throws
HubSpotConnectorException If any one of the required parameters is empty it will throw this exception.
HubSpotConnectorNoAccessTokenException If there is not an access_token in the response it will throw this exception.

public Contact createContact (String userId, ContactProperties contactProperties)

Create a new contact in HubSpot with a simple HTTP POST to the Contacts API.

API link: http://developers.hubspot.com/docs/methods/contacts/create_contact

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
contactProperties The properties that want to modify of an existing contact
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public HubSpotList createContactList (String userId, HubSpotNewList list, List<HubSpotListFilters> filters)

Create a new list in a given HubSpot portal to populate with contacts.

API link: http://developers.hubspot.com/docs/methods/lists/create_list

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
list The new HubSpotNewList to be created. Required fields:name, portalId.
filters The list of HubSpotListFilters that the list can have
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public CustomContactProperty createCustomProperty (String userId, CustomContactProperty contactProperty)

Create a new property in HubSpot. Properties in HubSpot are fields that have been created. By default, there are many fields that come "out of the box" in a HubSpot portal, but users can also create new, custom properties as they please.

This method enables you to create a new property. If you try to create a property whose name already exists in the system, you'll get an HTTP 409 exception thrown from the API.

Currently, there is a 1,000 property limit that you can have in any given portal.

API link: https://developers.hubspot.com/docs/methods/contacts/create_property

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
contactProperty The CustomContactProperty to be created
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public CustomContactPropertyGroup createCustomPropertyGroup (String userId, CustomContactPropertyGroup customContactPropertyGroup)

For a given portal, create a new contact proprerty group.

Property groups allow you to more easily manage properties in a given portal. They also let you organize the user interface of the contacts web application in a more flexible way.

There are certain propery groups that are in place for each portal by default: 'Contact Information', 'Social Media Information', 'Company Information' and 'Email Inforamtion' are examples. This method lets you create your own custom property group in a portal.

API link: https://developers.hubspot.com/docs/methods/contacts/create_group

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
customContactPropertyGroup A CustomContactPropertyGroup to be created
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public ContactDeleted deleteContact (String userId, String contactId)

Archive an existing contact from a particular HubSpot portal. Archiving will not hard delete a contact from a portal, but will remove that contact from the HubSpot user interface.

API link: http://developers.hubspot.com/docs/methods/contacts/delete_contact

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
contactId You must pass the Contact's ID that you're archiving in the request URL.
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public void deleteCustomProperty (String userId, String contactPropertyName)

Delete an existing property in HubSpot. This method lets you delete one of many properties of a contact in HubSpot.

To delete a contact property, you should make an HTTP DELETE call to this endpoint with the name of the property you're deleting in the request URL.

API link: https://developers.hubspot.com/docs/methods/contacts/delete_property

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
contactPropertyName The name of the custom property to be deleted
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public void deleteCustomPropertyGroup (String userId, String groupName)

For a given portal, delete a contact property group based on the name of the group.

Property groups allow you to more easily manage properties in a given portal. They also let you organize the user interface of the contacts web application in a more flexible way.

There are certain property groups that are in place for each portal by default: 'Contact Information', 'Social Media Information', 'Company Information' and 'Email Inforamtion' are examples. This method lets you delete your own custom property group in a portal. You can also create new groups, update existing groups, or just get group and the properties in each group.

API link: https://developers.hubspot.com/docs/methods/contacts/delete_group

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
groupName The name of the group to be deleted
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public ContactList getAllContacts (String userId, String count, String contactOffset)

For a given portal, return all contacts that have been created in the portal. A paginated list of contacts will be returned to you, with a maximum of 100 contacts per page.

API Link: http://developers.hubspot.com/docs/methods/contacts/get_contacts

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
count This parameter lets you specify the amount of contacts to return in your API call. The default for this parameter (if it isn't specified) is 20 contacts. The maximum amount of contacts you can have returned to you via this parameter is 100.
contactOffset This parameter will offset the contacts returned to you, based on the unique ID of the contacts in a given portal. Contact unique IDs are assigned by the order that they are created in the system. This means for instance, if you specify a vidOffset offset of 5, and you have 20 contacts in the portal you're working in, the contacts with IDs 6-20 will be returned to you.
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public List<CustomContactProperty> getAllCustomProperties (String userId)

Properties in HubSpot are fields that have been created. By default, there are many fields that come "out of the box" in a HubSpot portal, but users can also create new, custom properties as they please. This method returns all of those properties to you.

API link: https://developers.hubspot.com/docs/methods/contacts/get_properties

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public String getCallbackUrl ()

public String getClientId ()

public HubSpotClientsManager getClientsManager ()

public Contact getContactByEmail (String userId, String contactEmail)

For a given portal, return information about a single contact by its email address.

API link: http://developers.hubspot.com/docs/methods/contacts/get_contact_by_email

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
contactEmail The email address for the contact that you're searching for.
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public Contact getContactById (String userId, String contactId)

For a given portal, return information about a single contact by its ID. The contact's unique ID's is stored in a field called 'vid' which stands for 'visitor ID'. This method will also return you much of the HubSpot lead "intelligence" that you may be accustomed to getting from the leads API, as properties in this new API. More of this intelligence will be available as time passes, but this call is where you can expect to find it.

API link: http://developers.hubspot.com/docs/methods/contacts/get_contact

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
contactId Unique identifier for a particular contact. In HubSpot's contact system, contact ID's are called "vid".
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public Contact getContactByUserToken (String userId, String contactUserToken)

For a given portal, return information about a single contact by its User Token (hubspotutk)

API link: http://developers.hubspot.com/docs/methods/contacts/get_contact_by_utk

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
contactUserToken The user token (HubSpot cookie) for the contact that you're searching for.
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public HubSpotList getContactListById (String userId, String listId)

For a given portal, return a contact list by its unique ID.

API link: http://developers.hubspot.com/docs/methods/lists/get_list

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
listId Unique identifier for the list that you're looking for.
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public ContactStatistics getContactStatistics (String userId)

For a given portal, return statistics about that portal's contacts.

API link: http://developers.hubspot.com/docs/methods/contacts/get_contact_statistics

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public ContactQuery getContactsByQuery (String userId, String query, String count)

For a given portal, return contacts and some data associated with those contacts by the contact's email address or name. Please note that you should expect this method to only return a small subset of data about the contact. One piece of data that the method will return is the contact ID (vid) that you can then use to look up much more data about that particular contact by its ID.

API link: http://developers.hubspot.com/docs/methods/contacts/search_contacts

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
query The search term for what you're searching for. You can use all of a word or just parts of a word as well. For example, if you we're searching for contacts with "hubspot" in their name or email, searching for "hub" would also return contacts with "hubspot" in their email address.
count This parameter lets you specify the amount of contacts to return in your API call. The default for this parameter (if it isn't specified) is 20 contacts. The maximum amount of contacts you can have returned to you via this parameter is 100.
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public ContactList getContactsInAList (String userId, String listId, String count, String property, String offset)

For a given portal and a given list, identified by its unique ID, return a list of contacts that are in that list.

API link: http://developers.hubspot.com/docs/methods/lists/get_list_contacts

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
listId Unique identifier for the list that you're looking for.
count This parameter lets you specify the amount of contacts to return in your API call. The default for this parameter (if it isn't specified) is 20 contacts. The maximum amount of contacts you can have returned to you via this parameter is 100.
property If you include the "property" parameter, then the properties in the "contact" object in the returned data will only include the property or properties that you request.
offset This parameter will offset the contacts returned to you, based on the unique ID of the contacts in a given portal. Contact unique IDs are assigned by the order that they are created in the system. This means for instance, if you specify a vidOffset offset of 5, and you have 20 contacts in the portal you're working in, the contacts with IDs 6-20 will be returned to you.
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public HubSpotListLists getContactsLists (String userId, String count, String offset)

For a given portal, return a set of contact lists that you specify with the count parameter. By default, we will only return up to 20 lists to you at a time.

API link: http://developers.hubspot.com/docs/methods/lists/get_lists

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
count An integer that represents the number of lists that you want returned to your call. By default, this call will return 20 lists to you. If you want more or different list returned to you, you'll want to use the "offset" parameter.
offset An integer that represents where to start your list pull from. For instance, if you want to return numbered lists: 50-60, your offset should be "50" and your count parameter (seen above) should be 10. You should also note that the returned JSON (seen below) includes a "has-more" field, which lets you know if there are more lists that you can pull. If "has-more" is true, you can use this offset parameter to pull lists that weren't in your initial call.
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public HubSpotCredentialsManager getCredentialsManager ()

public CustomContactPropertyGroup getCustomPropertyGroup (String userId, String groupName)

For a given portal, return all contact property groups that have been created in the portal.

Property groups allow you to more easily manage properties in a given portal. They also let you organize the user interface of the contacts web application in a more flexible way.

There are certain property groups that are in place for each portal by default: 'Contact Information', 'Social Media Information', 'Company Information' and 'Email Inforamtion' are examples.

API link: https://developers.hubspot.com/docs/methods/contacts/get_groups

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
groupName The name of the group to be retrieved
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public HubSpotListLists getDynamicContactLists (String userId, String count, String offset)

For a given portal, return a set of dynamic contact lists that you specify with the count parameter.

Dynamic lists are lists that can only be edited by the contacts app - they are meant to update themselves when new contacts are created or are updated, meaning that you can't manually add contacts to dynamic lists.

By default, we will only return 20 lists to you via this API call.

API link: http://developers.hubspot.com/docs/methods/lists/get_dynamic_lists

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
count An integer that represents the number of lists that you want returned to your call. By default, this call will return 20 lists to you. If you want more or different list returned to you, you'll want to use the "offset" parameter.
offset An integer that represents where to start your list pull from. For instance, if you want to return numbered lists: 50-60, your offset should be "50" and your count parameter (seen above) should be 10. You should also note that the returned JSON (seen below) includes a "has-more" field, which lets you know if there are more lists that you can pull. If "has-more" is true, you can use this offset parameter to pull lists that weren't in your initial call.
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public EmailSubscriptionStatus getEmailSubscriptionStatus (String userId, String hubId, String email)

For a given portal, return all email subscription information for the given email address and portal.

API link: http://developers.hubspot.com/docs/methods/email/get_status

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
hubId (portalId) The HubSpot Portal ID for the portal that you're making the call for. If left empty it will use the one stored in the credentials (authenticate operation)
email The email to check the current status subscription
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public EmailSubscription getEmailSubscriptions (String userId, String hubId)

For a given portal, return all email subscription types that have been created in the portal.

API link: http://developers.hubspot.com/docs/methods/email/get_subscriptions

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
hubId (portalId) The HubSpot Portal ID for the portal that you're making the call for. If left empty it will use the one stored in the credentials (authenticate operation)
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public String getHubId ()

public ObjectStore getObjectStore ()

public ContactList getRecentContacts (String userId, String count, String timeOffset, String contactOffset)

For a given portal, return all contacts that have been recently updated or created. A paginated list of contacts will be returned to you, with a maximum of 100 contacts per page, as specified by the "count" parameter.

API link: http://developers.hubspot.com/docs/methods/contacts/get_recently_updated_contacts

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
count This parameter lets you specify the amount of contacts to return in your API call. The default for this parameter (if it isn't specified) is 20 contacts. The maximum amount of contacts you can have returned to you via this parameter is 100.
timeOffset Used in conjunction with the vidOffset paramter to page through the recent contacts. Every call to this endpoint will return a time-offset value. This value is used in the timeOffset parameter of the next call to get the next page of contacts.
contactOffset Used in conjunction with the timeOffset paramter to page through the recent contacts. Every call to this endpoint will return a vid-offset value. This value is used in the vidOffset parameter of the next call to get the next page of contacts.
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public String getScope ()

public boolean hasUserAccessToken (String userId)

Check if the User has an Access Token. This indicate that this User can start calling the process of the connector without any problems

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
Returns
  • A boolean that indicates if the user has an access token. Id does not check if the token is or not expired

public void initialize ()

public void setCallbackUrl (String callbackUrl)

Parameters
callbackUrl

public void setClientId (String clientId)

Parameters
clientId

public void setClientsManager (HubSpotClientsManager clientsManager)

Parameters
clientsManager

public void setCredentialsManager (HubSpotCredentialsManager credentialsManager)

Parameters
credentialsManager

public void setHubId (String hubId)

Parameters
hubId

public void setObjectStore (ObjectStore objectStore)

Parameters
objectStore

public void setScope (String scope)

Parameters
scope

public ContactProperties updateContact (String userId, String contactId, ContactProperties contactProperties)

Update an existing contact in HubSpot. This method lets you update one of many fields of a contact in HubSpot.

To update a contact, you should make an HTTP POST call to this endpoint with some JSON in the request payload. This JSON should contain properties from the contact that you want to add to or update. See the sample JSON below for an example of this snippet of JSON.

If you are trying to close a contact into a customer via the API, you should be updating the 'lifecyclestage' property and setting the value of this property to 'customer'.

Remember, if a property doesn't yet exist, you can create a new custom property through the API by using the 'Create Property' method.

API link: http://developers.hubspot.com/docs/methods/contacts/update_contact

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
contactId You must pass the Contact's ID that you're updating in the request URL
contactProperties The properties of the Contact that will have the one to be created
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public CustomContactProperty updateCustomProperty (String userId, String propertyName, CustomContactProperty contactProperty)

Update an existing property in HubSpot. This method lets you update one of many properties of a contact in HubSpot.T

To update a contact property, you should make an HTTP POST call to this endpoint with some JSON in the request payload. This JSON should contain property attributes that you want to add to or update. See the sample JSON below for an example of this snippet of JSON.

Remember, if a property doesn't yet exist, you can create a new custom property through the API by using the 'Create Property' method.

API link: https://developers.hubspot.com/docs/methods/contacts/update_property

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
propertyName The name of the Custom Property to be updated
contactProperty The contactProperty to be created
Returns
  • The contactProperty recently created
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public CustomContactPropertyGroup updateCustomPropertyGroup (String userId, String groupName, CustomContactPropertyGroup customContactPropertyGroup)

For a given portal, update a contact property group.

Property groups allow you to more easily manage properties in a given portal. They also let you organize the user interface of the contacts web application in a more flexible way.

There are certain property groups that are in place for each portal by default: 'Contact Information', 'Social Media Information', 'Company Information' and 'Email Inforamtion' are examples. This method lets you update your own custom property group in a portal.

API link: https://developers.hubspot.com/docs/methods/contacts/update_group

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
groupName The name of the Custom Contact Property Group to be updated
customContactPropertyGroup A CustomContactPropertyGroup to be created
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public EmailSubscriptionStatusResult updateEmailSubscriptionStatus (String userId, String hubId, String email, List<EmailSubscriptionStatusStatuses> statuses)

For a given email address and portal, update the email type subscription status. NOTE: it is only possible to opt email addresses OUT of subscription and there is NO UNDO for this operation.

API link: http://developers.hubspot.com/docs/methods/email/update_status

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
hubId (portalId) The HubSpot Portal ID for the portal that you're making the call for. If left empty it will use the one stored in the credentials (authenticate operation)
email The email to update the current status subscription
statuses A List of EmailSubscriptionStatusStatuses to be modified
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be thrown

public EmailSubscriptionStatusResult updateEmailSubscriptionStatusUnsubscribeFromAll (String userId, String hubId, String email)

For a given email address and portal, update the email type subscription unsuscribing from all emails NOTE: it is only possible to opt email addresses OUT of subscription and there is NO UNDO for this operation.

API link: http://developers.hubspot.com/docs/methods/email/update_status

Parameters
userId The UserID of the user in the HubSpot service that was obtained from the authenticateResponse process
hubId (portalId) The HubSpot Portal ID for the portal that you're making the call for. If left empty it will use the one stored in the credentials (authenticate operation)
email The email to update the current status subscription
Returns
Throws
HubSpotConnectorException If the required parameters were not specified or occurs another type of error this exception will be thrown
HubSpotConnectorNoAccessTokenException If the user does not have an Access Token this exception will be thrown
HubSpotConnectorAccessTokenExpiredException If the user has his token already expired this exception will be throwns