Commit cc897bef authored by Josep Salvà's avatar Josep Salvà
Browse files

Minor fixes

parent 98fc65a5
Showing with 22 additions and 10 deletions
+22 -10
......@@ -19,9 +19,17 @@ class ResponseException extends SharpspringException
{
$this->response = $response;
$error = $response->getError()[0];
$error = $response->getError();
if (is_array($response->getError())) {
$error = $response->getError()[0];
}
$this->data = $error->data;
if (str_contains($error->message, 'Invalid parameters')) {
dd($this->data);
}
parent::__construct($error->message, $error->code, $previous);
}
......
......@@ -51,6 +51,7 @@ class Lead extends ModelWithCustom
'description',
'industry',
'isUnsubscribed',
'isOptedIn',
'updateTimestamp',
'createTimestamp'
];
......
<?php
namespace Rw\SharpspringApi;
use Exception;
use Illuminate\Support\Facades\Log;
use Rw\SharpspringApi\Exceptions\ResponseException;
/**
......@@ -47,20 +49,21 @@ class Response
public function getResult()
{
return $this->getBody()->result;
try {
return $this->getBody()->result;
} catch (Exception $e) {
Log::error($e->getMessage());
return null;
}
}
public function getError()
{
if (!is_null($this->getBody())) {
if (isset($this->getBody()->error)) {
return (array) $this->getBody()->error;
}
return (array) $this->getBody();
if (!is_null($this->getBody()) && (isset($this->getBody()->error) && !empty($this->getBody()->error))) {
return $this->getBody()->error;
}
return [];
return null;
}
public function getId()
......@@ -85,7 +88,7 @@ class Response
public function isError()
{
return ! empty($this->getError());
return !is_null($this->getError());
}
public function makeException()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment