Skip to content

Fix Constructor Signature #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions lib/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down