The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

HubSpot::Contact -- A read-only representation of a contact object in HubSpot

SYNOPSIS

my $client = HubSpot::Client->new({ api_key => $hub_api_key }); 
# Retrieve 50 contacts
my $contacts = $client->contacts(50);

DESCRIPTION

This is the class returned by HubSpot::Client when it you execute methods that return contact objects. It is created from a blob of JSON taken from the HubSpot API, and so goes stale immediately.

METHODS

new({json => <blob_of_json_from_hubspot_api> }) (constructor)

Instances of this object are usually created bu HubSpot::Client, which instnatiates them with a blob of JSON retrieved from the HubSpot API. When you access properties on this object the relevant data is pulled out rom the blob of JSON and returned.

Returns: new instance of this class.

new({primaryEmail => 'foo@bar.com', firstName => 'John', lastName => 'Smith'}) (constructor)

You can create instances of contacts and populate properties like this, but it will not cause the contact to be created in HubSpot. That will likely be implemented in future. Patches welcome.

Returns: new instance of this class.

getProperty('prop_name')

Retrieve a named property. Might not be set depending upon how this was retrieved. See "properties".

PROPERTIES

All properties can be retrieved by calling the relevant method, with no parameters. Setting properties is not currently supported.

my $email = $contact->primaryEmail
my $email = $contact->primaryEmail()

for example. Both do the same thing.

id

The ID of the contact as it is known in HubSpot. You can use this to retrieve a specific contact only, rather than multiple contacts. See contact

firstName

Returns the contact's first name, which is a mandatory field in HubSpot so this will always return something.

lastName

Returns the contact's first name, which is a mandatory field in HubSpot so this will always return something.

company

Returns the contact's associated company name, if set, or undef otherwise.

lastModifiedDateTime

Returns the date and time that the contact was last modified, as a DateTime, Time zone is UTC, but you can use that module's methods to change that.

primaryEmail

Returns the email address set as the primary email, if set, or undef otherwise.

properties

Returns a hash reference of all the other properties set on this object. Which properties these are depends not only on what is set in HubSpot for that object, but also how this object was retrieved. If it was retrieved via a call that returns multiple objects, like HubSpot::Client->contacts(), then by default this will only contain the properties listed above (additional properties have to be requested specifically). If it was retrieved on its own, then all properties with a value will be set.

Properties not returned by the API, or returned with not set value, or returned as the empty string will not exist in this hash - such that exists($key) would return false.