Changed according to Rubens suggestions

This commit is contained in:
Tobias Nyholm 2015-10-12 22:46:30 +02:00
parent 61d03262a9
commit 4131802de2

View File

@ -39,28 +39,30 @@ class RestClient
* @param string $apiHost * @param string $apiHost
* @param string $apiVersion * @param string $apiVersion
* @param bool $ssl * @param bool $ssl
* @param HttpAdapter $adapter
*/ */
public function __construct($apiKey, $apiHost, $apiVersion, $ssl, HttpAdapter $adapter = null) public function __construct($apiKey, $apiHost, $apiVersion, $ssl, HttpAdapter $adapter = null)
{ {
$this->apiKey = $apiKey; $this->apiKey = $apiKey;
$this->httpAdapter = $httpAdapter; $this->httpAdapter = $adapter;
$this->apiEndpoint = $this->generateEndpoint($apiHost, $apiVersion, $ssl); $this->apiEndpoint = $this->generateEndpoint($apiHost, $apiVersion, $ssl);
} }
/** /**
* @param string $method * @param string $method
* @param string $uri * @param string $uri
* @param array $headers
* @param array $body * @param array $body
* @param array $files * @param array $files
* @param array $headers
* *
* @return \stdClass * @return \stdClass
*
* @throws GenericHTTPError * @throws GenericHTTPError
* @throws InvalidCredentials * @throws InvalidCredentials
* @throws MissingEndpoint * @throws MissingEndpoint
* @throws MissingRequiredParameters * @throws MissingRequiredParameters
*/ */
protected function send($method, $uri, array $headers = [], $body = [], $files = []) protected function send($method, $uri, $body = null, $files = [], array $headers = [])
{ {
if ($this->httpAdapter === null) { if ($this->httpAdapter === null) {
$this->httpAdapter = HttpAdapterDiscovery::find(); $this->httpAdapter = HttpAdapterDiscovery::find();
@ -126,7 +128,7 @@ class RestClient
} }
} }
return $this->send('POST', $endpointUrl, [], [], array_merge($postDataMultipart, $postFiles)); return $this->send('POST', $endpointUrl, [], array_merge($postDataMultipart, $postFiles));
} }
/** /**
@ -173,7 +175,7 @@ class RestClient
*/ */
public function put($endpointUrl, $putData) public function put($endpointUrl, $putData)
{ {
return $this->send('PUT', $endpointUrl, [], $putData); return $this->send('PUT', $endpointUrl, $putData);
} }
/** /**