Better handle responses missing expected keys
This commit is contained in:
parent
403d2168c1
commit
947e1358b5
@ -198,7 +198,7 @@ final class API
|
||||
|
||||
$x = $this->execute('query',$parameters);
|
||||
|
||||
if ((! $x->QueryResponse) || (! $x->QueryResponse->Customer) || (count($x->QueryResponse->Customer) !== 1))
|
||||
if ((! $x->QueryResponse) || (! object_get($x->QueryResponse,'Customer')) || (count($x->QueryResponse->Customer) !== 1))
|
||||
throw new InvalidQueryResultException(sprintf('%s:Query response malformed',self::LOGKEY));
|
||||
|
||||
return new Customer($x->QueryResponse);
|
||||
@ -251,8 +251,8 @@ final class API
|
||||
|
||||
$x = $this->execute('query',$parameters);
|
||||
|
||||
if ((! $x->QueryResponse) || (! $x->QueryResponse->Invoice) || (count($x->QueryResponse->Invoice) !== 1))
|
||||
throw new InvalidQueryResultException(sprintf('%s:Query response malformed',self::LOGKEY));
|
||||
if ((! $x->QueryResponse) || (! object_get($x->QueryResponse,'Invoice')) || (count($x->QueryResponse->Invoice) !== 1))
|
||||
throw new InvalidQueryResultException(sprintf('%s:Query response malformed [%s]',self::LOGKEY,serialize($x)));
|
||||
|
||||
return new Invoice($x->QueryResponse);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user