Skip to content

Commit a8506cf

Browse files
committed
update README further + remove unneeded header setter
1 parent 71726e3 commit a8506cf

File tree

4 files changed

+7
-57
lines changed

4 files changed

+7
-57
lines changed

README.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Uses [Redmine API](http://www.redmine.org/projects/redmine/wiki/Rest_api/).
3030

3131
## Todo
3232

33-
* API entry points :
3433
* Check header's response code (especially for POST/PUT/DELETE requests)
3534
* See http://stackoverflow.com/questions/9183178/php-curl-retrieving-response-headers-and-body-in-a-single-request/9183272#9183272
3635
* Maybe Guzzle for handling http connections
@@ -108,6 +107,7 @@ $client->setImpersonateUser(null);
108107

109108
### Thanks!
110109

111-
- Thanks to [Thomas Spycher](https://github.com/tspycher/) for the 1st version of the class.
112-
- Thanks to [Thibault Duplessis aka. ornicar](https://github.com/ornicar) for the php-github-api library, great source of inspiration!
113-
- And all the [contributors](https://github.com/kbsali/php-redmine-api/graphs/contributors) and specially [JanMalte](https://github.com/JanMalte) for his impressive contribution to the test coverage! :)
110+
* Thanks to [Thomas Spycher](https://github.com/tspycher/) for the 1st version of the class.
111+
* Thanks to [Thibault Duplessis aka. ornicar](https://github.com/ornicar) for the php-github-api library, great source of inspiration!
112+
* And all the [contributors](https://github.com/kbsali/php-redmine-api/graphs/contributors)
113+
* specially [JanMalte](https://github.com/JanMalte) for his impressive contribution to the test coverage! :)

example.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
* @file
55
* This file holds example commands for reading, creating, updating and deleting redmine components.
66
*/
7-
7+
88
// As this is only an example file, we make sure, this is not accidently executed and may destroy real
99
// life content.
1010
return;
1111

12-
1312
require_once 'vendor/autoload.php';
1413

1514
// ----------------------------

lib/Redmine/Client.php

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ class Client
3434
*/
3535
private $apikeyOrUsername;
3636

37-
/**
38-
* @var string
39-
*/
40-
private $apikeyHeaderName = 'X-Redmine-API-Key';
41-
4237
/**
4338
* @var string or null
4439
*/
@@ -263,29 +258,6 @@ public function setPort($port = null)
263258
return $this;
264259
}
265260

266-
/**
267-
* Set the name of the HTTP header used to set the API key for authentication
268-
* @param string $name
269-
* @return Client
270-
*/
271-
public function setApikeyHeaderName($name = null)
272-
{
273-
if (null !== $name) {
274-
$this->apikeyHeaderName = $name;
275-
}
276-
277-
return $this;
278-
}
279-
280-
/**
281-
* Returns the name of the HTTP header used to set the API key for authentication
282-
* @return string
283-
*/
284-
public function getApikeyHeaderName()
285-
{
286-
return $this->apikeyHeaderName;
287-
}
288-
289261
/**
290262
* Returns Redmine response code
291263
* @return int
@@ -380,13 +352,14 @@ protected function runRequest($path, $method = 'GET', $data = '')
380352
$httpHeader[] = 'Content-Type: application/json';
381353
}
382354

355+
// Redmine specific headers
383356
if ($this->impersonateUser) {
384357
$httpHeader[] = 'X-Redmine-Switch-User: ' . $this->impersonateUser;
385358
}
386359

387360
if (!empty($httpHeader)) {
388361
if (null === $this->pass) {
389-
$httpHeader[] = $this->apikeyHeaderName.': '.$this->apikeyOrUsername;
362+
$httpHeader[] = 'X-Redmine-API-Key: '.$this->apikeyOrUsername;
390363
}
391364
curl_setopt($curl, CURLOPT_HTTPHEADER, $httpHeader);
392365
}

test/Redmine/Tests/ClientTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,28 +107,6 @@ public function testGetResponseCodeIsInitialNull()
107107
$this->assertEquals(0, $client->getResponseCode());
108108
}
109109

110-
/**
111-
* @covers Redmine\Client
112-
* @test
113-
*/
114-
public function testGetApikeyHeaderNameReturnsSetApikeyHeaderName()
115-
{
116-
// Test values
117-
$headerName = 'X-Header-Redmine-API-Auth';
118-
$otherHeaderName = 'X-Header-API-Auth';
119-
120-
$client = new Client('http://test.local', 'asdf');
121-
122-
$this->assertSame($client, $client->setApikeyHeaderName($headerName));
123-
$this->assertSame($headerName, $client->getApikeyHeaderName());
124-
125-
$this->assertSame($client, $client->setApikeyHeaderName(null));
126-
$this->assertSame($headerName, $client->getApikeyHeaderName());
127-
128-
$this->assertSame($client, $client->setApikeyHeaderName($otherHeaderName));
129-
$this->assertSame($otherHeaderName, $client->getApikeyHeaderName());
130-
}
131-
132110
/**
133111
* @covers Redmine\Client
134112
* @test

0 commit comments

Comments
 (0)