function __construct(Server $server, StorageInterface $storage) { $this->_server = $server; $this->_storage = $storage; $this->_basketService = new BasketService($storage); $server->attach($this); }
use Kanboard\Api\Comment; use Kanboard\Api\File; use Kanboard\Api\Link; use Kanboard\Api\Project; use Kanboard\Api\ProjectPermission; use Kanboard\Api\Subtask; use Kanboard\Api\Swimlane; use Kanboard\Api\Task; use Kanboard\Api\TaskLink; use Kanboard\Api\User; use Kanboard\Api\Group; use Kanboard\Api\GroupMember; $server = new Server(); $server->setAuthenticationHeader(API_AUTHENTICATION_HEADER); $server->before(array(new Auth($container), 'checkCredentials')); $server->attach(new Me($container)); $server->attach(new Action($container)); $server->attach(new App($container)); $server->attach(new Board($container)); $server->attach(new Column($container)); $server->attach(new Category($container)); $server->attach(new Comment($container)); $server->attach(new File($container)); $server->attach(new Link($container)); $server->attach(new Project($container)); $server->attach(new ProjectPermission($container)); $server->attach(new Subtask($container)); $server->attach(new Swimlane($container)); $server->attach(new Task($container)); $server->attach(new TaskLink($container)); $server->attach(new User($container));
use Kanboard\Api\CommentApi; use Kanboard\Api\FileApi; use Kanboard\Api\LinkApi; use Kanboard\Api\ProjectApi; use Kanboard\Api\ProjectPermissionApi; use Kanboard\Api\SubtaskApi; use Kanboard\Api\SwimlaneApi; use Kanboard\Api\TaskApi; use Kanboard\Api\TaskLinkApi; use Kanboard\Api\UserApi; use Kanboard\Api\GroupApi; use Kanboard\Api\GroupMemberApi; $server = new Server(); $server->setAuthenticationHeader(API_AUTHENTICATION_HEADER); $server->before(array(new AuthApi($container), 'checkCredentials')); $server->attach(new MeApi($container)); $server->attach(new ActionApi($container)); $server->attach(new AppApi($container)); $server->attach(new BoardApi($container)); $server->attach(new ColumnApi($container)); $server->attach(new CategoryApi($container)); $server->attach(new CommentApi($container)); $server->attach(new FileApi($container)); $server->attach(new LinkApi($container)); $server->attach(new ProjectApi($container)); $server->attach(new ProjectPermissionApi($container)); $server->attach(new SubtaskApi($container)); $server->attach(new SwimlaneApi($container)); $server->attach(new TaskApi($container)); $server->attach(new TaskLinkApi($container)); $server->attach(new UserApi($container));
public function testBatchOk() { $server = new Server('[ {"jsonrpc": "2.0", "method": "sum", "params": [1,2,4], "id": "1"}, {"jsonrpc": "2.0", "method": "notify_hello", "params": [7]}, {"jsonrpc": "2.0", "method": "subtract", "params": [42,23], "id": "2"}, {"foo": "boo"}, {"jsonrpc": "2.0", "method": "foo.get", "params": {"name": "myself"}, "id": "5"}, {"jsonrpc": "2.0", "method": "get_data", "id": "9"}, {"jsonrpc": "2.0", "method": "doSomething", "id": 10}, {"jsonrpc": "2.0", "method": "doStuff", "id": 15} ]'); $server->register('sum', function ($a, $b, $c) { return $a + $b + $c; }); $server->register('subtract', function ($minuend, $subtrahend) { return $minuend - $subtrahend; }); $server->register('get_data', function () { return array('hello', 5); }); $server->attach(new C()); $server->bind('doStuff', 'C', 'doSomething'); $response = $server->execute(); $this->assertEquals(json_decode('[ {"jsonrpc": "2.0", "result": 7, "id": "1"}, {"jsonrpc": "2.0", "result": 19, "id": "2"}, {"jsonrpc": "2.0", "error": {"code": -32600, "message": "Invalid Request"}, "id": null}, {"jsonrpc": "2.0", "error": {"code": -32601, "message": "Method not found"}, "id": "5"}, {"jsonrpc": "2.0", "result": ["hello", 5], "id": "9"}, {"jsonrpc": "2.0", "result": "something", "id": "10"}, {"jsonrpc": "2.0", "result": "something", "id": "15"} ]', true), json_decode($response, true)); }