Skip to content

Commit 281a760

Browse files
Merge pull request #96 from sendgrid/fix_constructor_sig
Fix Constructor Signature
2 parents 15fa0d2 + 83de466 commit 281a760

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

lib/Client.php

+11-10
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,21 @@ class Client
5454
/**
5555
* Initialize the client
5656
*
57-
* @param string $host the base url (e.g. https://api.sendgrid.com)
58-
* @param array $headers global request headers
59-
* @param string $version api version (configurable)
60-
* @param array $path holds the segments of the url path
57+
* @param string $host the base url (e.g. https://api.sendgrid.com)
58+
* @param array $headers global request headers
59+
* @param string $version api version (configurable) - this is specific to the SendGrid API
60+
* @param array $path holds the segments of the url path
61+
* @param array $curlOptions extra options to set during curl initialization
62+
* @param bool $retryOnLimit set default retry on limit flag
6163
*/
62-
public function __construct($host, $headers = [], $version = '/v3', $path = [])
64+
public function __construct($host, $headers = null, $version = null, $path = null, $curlOptions = null, $retryOnLimit = false)
6365
{
6466
$this->host = $host;
65-
$this->headers = $headers;
67+
$this->headers = $headers ?: [];
6668
$this->version = $version;
67-
$this->path = $path;
68-
69-
$this->curlOptions = [];
70-
$this->retryOnLimit = false;
69+
$this->path = $path ?: [];
70+
$this->curlOptions = $curlOptions ?: [];
71+
$this->retryOnLimit = $retryOnLimit;
7172
$this->isConcurrentRequest = false;
7273
$this->savedRequests = [];
7374
}

test/unit/ClientTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function setUp()
2020
'Content-Type: application/json',
2121
'Authorization: Bearer SG.XXXX'
2222
];
23-
$this->client = new MockClient($this->host, $this->headers);
23+
$this->client = new MockClient($this->host, $this->headers, '/v3');
2424
}
2525

2626
public function testConstructor()
@@ -91,7 +91,7 @@ public function testGetVersion()
9191
$this->assertSame('/v3', $client->getVersion());
9292

9393
$client = new Client('https://localhost:4010');
94-
$this->assertSame('/v3', $client->getVersion());
94+
$this->assertSame(null, $client->getVersion());
9595
}
9696

9797
public function testGetPath()

0 commit comments

Comments
 (0)