IsraelOrtuno/pipedrive

Undefined property: stdClass::$success

Closed this issue · 4 comments

(1/1) ErrorException Undefined property: stdClass::$success in Response.php line 53

at HandleExceptions->handleError(8, 'Undefined property: stdClass::$success', '\vendor\devio\pipedrive\src\Http\Response.php', 53, array())in Response.php line 53

at Response->isSuccess()in Request.php line 86
at Request->handleResponse(object(Response))in Request.php line 67
at Request->executeRequest('put', 'deals/17790', array())in Request.php line 53
at Request->performRequest('put', ':id', array())in Request.php line 134
at Request->__call('put', array(':id', array()))in Resource.php line 89
at Resource->update(17790, array())
...

Be more explicit when creating issues, a simple copy paste does not help.

Very simple exception require to handle... you just need to place a data existence check there...
in Devio\Pipedrive\Http\Response

update the method;

public function isSuccess()
    {
        if (! $this->getContent()) {
            return false;
        }
        
        return $this->getContent()->success;
    }

with

public function isSuccess()
    {
        if (! $this->getContent()) {
            return false;
        }

        if(!property_exists($this->getContent(), 'success'))
            return false;
        
        return $this->getContent()->success;
    }

That looks nice, could you submit a PR?

Could you please provide steps to reproduce this? Not sure how to make this happen