diff --git a/.php_cs b/.php_cs index 4baa296..2dbc90d 100644 --- a/.php_cs +++ b/.php_cs @@ -122,3 +122,5 @@ return Symfony\CS\Config\Config::create() )) ->finder($finder) ; + +// vim:ft=php diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c3d5c5..e3f3a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Eventum RPC Client Library +## [4.2.0] - 2018-05-01 + +- Move classes to `Eventum\RPC` namespace, deprecate root namespace [#4] +- Update xmlrpc methods doc, include `@method` annotation, [#4] + +[4.2.0]: https://github.com/eventum/rpc/compare/v4.1.1...v4.2.0 +[#4]: https://github.com/eventum/rpc/pull/4 + ## [4.1.1] - 2017-10-15 - add `addUserAgent` method for public access diff --git a/README.md b/README.md index 4551d1d..d999cba 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -eventum-rpc -=========== +# Eventum RPC Eventum RPC Client Library. @@ -46,18 +45,18 @@ require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php'; $rpc_url = "http://example.org/rpc/xmlrpc.php"; -$client = new Eventum_RPC($rpc_url); +$client = new \Eventum\RPC\EventumXmlRpcClient($rpc_url); $client->setCredentials("user@example.org", "password"); // add user@example.org as authorized replier in issue $issue_id belonging to project $project_id $client->addAuthorizedReplier($issue_id, $project_id, "user@example.org"); ``` -The available XMLRPC Methods can be seen from [here](XMLRPC.md). +The available XMLRPC Methods can also be seen from [XMLRPC.md](XMLRPC.md). ## Copyright and License ## -This software is Copyright (c) 2008 - 2017 Eventum Team. +This software is Copyright (c) 2008 - 2018 Eventum Team. This is free software, licensed under the GNU General Public License version 2. diff --git a/XMLRPC.md b/XMLRPC.md index ec972ef..95d3894 100644 --- a/XMLRPC.md +++ b/XMLRPC.md @@ -1,10 +1,10 @@ ## Available XMLRPC methods ## -Here are available XMLRPC methods in [Eventum](https://github.com/eventum/eventum) as of version 3.0.2. +Here are available XMLRPC methods in [Eventum](https://github.com/eventum/eventum) as of version 3.4.0. The methods themselves are defined in [RemoteApi](https://github.com/eventum/eventum/blob/master/lib/eventum/rpc/RemoteApi.php) class in Eventum codebase. This output is created with Eventum [CLI](https://github.com/eventum/cli) application [DumpMethods](https://github.com/eventum/cli/blob/master/src/Command/DumpMethodsCommand.php) command. -Methods marked `@access public` do not require authentication, while `@access restricted` (default) require that you either use `setCredentials` to pass authentication credentials, or put `login` and `password` as first two parameters for the call. +Methods marked `@access public` do not require authentication, while `@access protected` (default) require that you either use `setCredentials` to pass authentication credentials, or put `login` and `password` as first two parameters for the call. ```php /** @@ -57,6 +57,7 @@ Methods marked `@access public` do not require authentication, while `@access re * @param string $note * @return string * @access protected + * @since 3.3.0 checks user access and issue close state */ function closeIssue(int, string, int, boolean, string): string @@ -231,11 +232,11 @@ Methods marked `@access public` do not require authentication, while `@access re * @param DateTime $start * @param DateTime $end * @param struct $options - * @return string + * @return struct * @access protected * @since 3.0.2 */ - function getWeeklyReportData(int, string, string, struct): string + function getWeeklyReportData(int, string, string, struct): struct /** * @param string $email @@ -249,6 +250,7 @@ Methods marked `@access public` do not require authentication, while `@access re * @param string $command * @return string * @access protected + * @deprecated since 3.3.0 this method does nothing */ function logCommand(string): string @@ -328,3 +330,4 @@ Methods marked `@access public` do not require authentication, while `@access re * @access protected */ function unredeemIssue(int, array): string +``` diff --git a/composer.json b/composer.json index fae02a3..4343cff 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,10 @@ "phpxmlrpc/phpxmlrpc": "^4.2.2" }, "autoload": { - "classmap": [ "src" ] + "psr-4": { + "Eventum\\RPC\\": "src/" + }, + "classmap": [ "lib" ] }, "autoload-dev": { "psr-4": { diff --git a/lib/Eventum_RPC.php b/lib/Eventum_RPC.php new file mode 100644 index 0000000..abc4439 --- /dev/null +++ b/lib/Eventum_RPC.php @@ -0,0 +1,21 @@ +client->send($req); if ($result === 0) { - throw new Eventum_RPC_Exception($this->client->errstr); + throw new XmlRpcException($this->client->errstr); } if (is_object($result) && $result->faultCode()) { - throw new Eventum_RPC_Exception($result->faultString()); + throw new XmlRpcException($result->faultString(), $result->faultCode()); } return $this->encoder->decode($result->value()); diff --git a/src/XmlRpcException.php b/src/XmlRpcException.php new file mode 100644 index 0000000..13e7931 --- /dev/null +++ b/src/XmlRpcException.php @@ -0,0 +1,20 @@ +__call($method); $this->assertContains($method, $methods); + + // test that legacy exception class is catchable + try { + $client->unknownMethod($method); + $this->fail('Exception not thrown'); + } catch (Eventum_RPC_Exception $e) { + $this->assertEquals('Unknown method', $e->getMessage()); + $this->assertEquals(1, $e->getCode()); + } + + // test that new exception class is catchable + try { + $client->unknownMethod($method); + $this->fail('Exception not thrown'); + } catch (XmlRpcException $e) { + $this->assertEquals('Unknown method', $e->getMessage()); + $this->assertEquals(1, $e->getCode()); + } } }