I've been doing some work in Perl as well. I didn't find any packages out there to be much help. I ended up using the REST::Client module available on cpan. It works pretty well. Here's my (modified) code I use to add a Deal if it helps.
sub addOrder {
# This function is part of a custom module, so grab the instance of the REST::Client
# class and the hash containing the properties to be added to the Deal
# So, any reference to $self is a reference to the REST::Client class.
my ($self, $properties) = @_;
# Grab the company id and then delete it. Need to save it so we can associate the company with the
# deal after we create the deal. Don't need the company id when creating the Deal.
my $companyId = $properties->{company_id};
delete $properties->{company_id};
# Build the query and the JSON payload then add the deal
my $query = qq(/crm/v3/objects/deals?hapikey=$hapikey);
my %dataHash = ( 'properties' => $properties );
# My custom module includes a JSON module instance
my $data = $self->{json}->encode(\%dataHash);
$self->POST($query, $data);
my $response = $self->{json}->decode( $self->responseContent() );
my $responseCode = $self->responseCode();
if( substr($responseCode, 0, 1) ne '2' ) {
die qq(HubSpot API Error Creating a Deal - HTTP Code $responseCode:\n$self->responseContent()\n\n$data\n );
}
my $dealId = $response->{id};
# Associate the deal and company using the id from the newly created deal
# and the company id saved earlier
$query = qq(/crm/v3/objects/deals/$response->{id}/associations/companies/$companyId/deal_to_company?hapikey=$hapikey);
$query =~ s/[\n\t]//g;
$self->PUT($query);
$responseCode = $self->responseCode();
if( substr($responseCode, 0, 1) ne '2' ) {
die qq(HubSpot API Error Associating Company to Deal - HTTP Code $responseCode:\n$data\n );
}
} #end addOrder()
So, it's a pretty simple module to use and access the HS API with.
Could you please share the other part of the script where you call the function "addOrder", I want to understand how the properties are pass into function and collected here. Need to work on the Ticket object to create the case.
I know we don't have an API package option for Perl on HubSpot, So I have to do it REST API call only!
Thanks, @SCatlin. However, I have a lot of work to do from Perl to HubSpot such as updating Asset info, Creating tickets, adding comments on Tickets, collecting companies' info, and many more.