Skip to content

Commit

Permalink
Merge pull request #4 from TappNetwork/getById
Browse files Browse the repository at this point in the history
getById instead of email
  • Loading branch information
scottgrayson authored Oct 25, 2024
2 parents 67c2c85 + a5345c7 commit 965340f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/LaravelHubspotServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function bootingPackage()
{
$this->app->bind(LaravelHubspot::class, function ($app) {

$stack = new HandlerStack();
$stack = new HandlerStack;
$stack->setHandler(Utils::chooseHandler());

$stack->push(Middleware::mapRequest(function (RequestInterface $r) {
Expand Down
13 changes: 6 additions & 7 deletions src/Models/HubspotContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ public static function updateOrCreateHubspotContact($model)
// }

try {
// TODO get by ID is unreliable (404 with api but works with web UI)
// if ($model->hubspot_id) {
// $hubspotContact = Hubspot::crm()->contacts()->basicApi()->getById($model->hubspot_id, null, null, null, false, 'id');
// } else {
$hubspotContact = Hubspot::crm()->contacts()->basicApi()->getById($model->email, null, null, null, false, 'email');
if ($model->hubspot_id) {
$hubspotContact = Hubspot::crm()->contacts()->basicApi()->getById($model->hubspot_id);
} else {
$hubspotContact = Hubspot::crm()->contacts()->basicApi()->getById($model->email, null, null, null, false, 'email');

$model->hubspot_id = $hubspotContact['id'];
// }
$model->hubspot_id = $hubspotContact['id'];
}
} catch (ApiException $e) {
// catch 404 error
Log::debug('Hubspot contact not found. Creating', ['email' => $model->email]);
Expand Down

0 comments on commit 965340f

Please sign in to comment.