diff --git a/src/HGG/Pardot/Connector.php b/src/HGG/Pardot/Connector.php index 67b3454..7809f31 100644 --- a/src/HGG/Pardot/Connector.php +++ b/src/HGG/Pardot/Connector.php @@ -309,7 +309,7 @@ protected function getClient() $curlCodes = null; $plugin = BackoffPlugin::getExponentialBackoff($retries, $httpCodes, $curlCodes); - $client = new Client($this->baseUrl); + $client = new Client($this->baseUrl, $this->httpClientOptions); $client->addSubscriber($plugin); return $client; diff --git a/src/HGG/Pardot/ResponseHandler/JsonResponseHandler.php b/src/HGG/Pardot/ResponseHandler/JsonResponseHandler.php index 31ddad8..df015b0 100644 --- a/src/HGG/Pardot/ResponseHandler/JsonResponseHandler.php +++ b/src/HGG/Pardot/ResponseHandler/JsonResponseHandler.php @@ -64,16 +64,20 @@ protected function doParse() protected function parseMultiRecordResult($objectName, $data) { $this->resultCount = (int) $data['result']['total_results']; + $hasKey = array_key_exists($objectName, $data['result']); - if (0 === $this->resultCount) { + if (0 === $this->resultCount && !$hasKey) { $this->result = array(); } else { - if (array_key_exists($objectName, $data['result'])) { + if ($hasKey) { if ($this->resultHasOnlyOneRecord($objectName, $data)) { $this->result = array($data['result'][$objectName]); } else { $this->result = $data['result'][$objectName]; } + if (0 === $this->resultCount) { + $this->resultCount = count($this->result); + } } else { $msg = sprintf('The response does not contain the expected object key \'%s\'', $objectName);