Skip to content

Commit

Permalink
Merge pull request #47 from utopia-php/feat-hubspot-adapter
Browse files Browse the repository at this point in the history
Add HubSpot adapter
  • Loading branch information
abnegate authored Sep 26, 2023
2 parents 14c8051 + 2494ca5 commit b2ced60
Show file tree
Hide file tree
Showing 4 changed files with 468 additions and 498 deletions.
10 changes: 6 additions & 4 deletions src/Analytics/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,23 @@ public function call(string $method, string $path = '', array $headers = [], arr
$responseType = $responseHeaders['Content-Type'] ?? '';
$responseStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);

switch(substr($responseType, 0, strpos($responseType, ';'))) {
switch (substr($responseType, 0, strpos($responseType, ';'))) {
case 'application/json':
$responseBody = json_decode($responseBody, true);
break;
}

if (curl_errno($ch)) {
throw new \Exception(curl_error($ch));
throw new \Exception(curl_error($ch), $responseStatus);
}

curl_close($ch);

if ($responseStatus >= 400) {
if (is_array($responseBody)) {
throw new \Exception(json_encode($responseBody));
throw new \Exception(json_encode($responseBody), $responseStatus);
} else {
throw new \Exception($responseStatus.': '.$responseBody);
throw new \Exception($responseStatus.': '.$responseBody, $responseStatus);
}
}

Expand Down Expand Up @@ -225,5 +225,7 @@ protected function logError(Exception $e)
Console::error('[Error] Message: '.$e->getMessage());
Console::error('[Error] File: '.$e->getFile());
Console::error('[Error] Line: '.$e->getLine());
Console::error('[Error] Trace: ');
Console::error($e->getTraceAsString());
}
}
Loading

0 comments on commit b2ced60

Please sign in to comment.