diff --git a/lib/Client.php b/lib/Client.php index 1cf9b0c..de1437b 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -54,20 +54,21 @@ class Client /** * Initialize the client * - * @param string $host the base url (e.g. https://api.sendgrid.com) - * @param array $headers global request headers - * @param string $version api version (configurable) - * @param array $path holds the segments of the url path + * @param string $host the base url (e.g. https://api.sendgrid.com) + * @param array $headers global request headers + * @param string $version api version (configurable) - this is specific to the SendGrid API + * @param array $path holds the segments of the url path + * @param array $curlOptions extra options to set during curl initialization + * @param bool $retryOnLimit set default retry on limit flag */ - public function __construct($host, $headers = [], $version = '/v3', $path = []) + public function __construct($host, $headers = null, $version = null, $path = null, $curlOptions = null, $retryOnLimit = false) { $this->host = $host; - $this->headers = $headers; + $this->headers = $headers ?: []; $this->version = $version; - $this->path = $path; - - $this->curlOptions = []; - $this->retryOnLimit = false; + $this->path = $path ?: []; + $this->curlOptions = $curlOptions ?: []; + $this->retryOnLimit = $retryOnLimit; $this->isConcurrentRequest = false; $this->savedRequests = []; } diff --git a/test/unit/ClientTest.php b/test/unit/ClientTest.php index 43cebfe..2d39f67 100644 --- a/test/unit/ClientTest.php +++ b/test/unit/ClientTest.php @@ -20,7 +20,7 @@ protected function setUp() 'Content-Type: application/json', 'Authorization: Bearer SG.XXXX' ]; - $this->client = new MockClient($this->host, $this->headers); + $this->client = new MockClient($this->host, $this->headers, '/v3'); } public function testConstructor() @@ -91,7 +91,7 @@ public function testGetVersion() $this->assertSame('/v3', $client->getVersion()); $client = new Client('https://localhost:4010'); - $this->assertSame('/v3', $client->getVersion()); + $this->assertSame(null, $client->getVersion()); } public function testGetPath()