Skip to content

Commit

Permalink
fix existance check
Browse files Browse the repository at this point in the history
  • Loading branch information
scott grayson authored and scott grayson committed May 8, 2024
1 parent 19fcece commit d6733be
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Models/HubspotContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ public static function bootHubspotContact(): void

public static function createHubspotContact($model): void
{
$hubspotContact = Hubspot::crm()->contacts()->basicApi()->create($model->hubspotPropertiesObject());
try {
$hubspotContact = Hubspot::crm()->contacts()->basicApi()->create($model->hubspotPropertiesObject());

$model->hubspot_id = $hubspotContact['id'];
$model->hubspot_id = $hubspotContact['id'];
} catch (ApiException $e) {
Log::error('Error creating hubspot contact: ' . $e->getResponseBody());
}

// TODO associate company from email domain with contact
// $domain = preg_replace('/[^@]+@/i', '', $email);
Expand Down Expand Up @@ -59,7 +63,7 @@ public static function updateOrCreateHubspotContact($model)
{
try {
if ($model->hubspot_id) {
$hubspotContact = Hubspot::crm()->contacts()->basicApi()->getById($model->id, null, null, null, false, 'email');
$hubspotContact = Hubspot::crm()->contacts()->basicApi()->getById($model->id, null, null, null, false, 'id');
} else {
$hubspotContact = Hubspot::crm()->contacts()->basicApi()->getById($model->email, null, null, null, false, 'email');

Expand Down

0 comments on commit d6733be

Please sign in to comment.