1 <?php
2 /*
3  * DokuWiki ActiveCollab Ticket Plugin
4  * Copyright (C) 2011  Tobias Sarnowski
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 require_once DOKU_INC . 'inc/HTTPClient.php';
22 require_once DOKU_INC . 'inc/JSON.php';
23 
24 /**
25  * Partially copied from Adrian Lang's syntax_plugin_ac_ac.
26  *
27  * @author Tobias Sarnowski
28  */
29 class actickets_acclient {
30 	private $base_url;
31 	private $client;
32 
33 	public function __construct($url, $token) {
34 		if (substr($url, -1) != '/') {
35 			$url .= '/';
36 		}
37 		$url .= 'public/api.php';
38 		$this->base_url = "{$url}?token={$token}&format=json";
39 		$this->client = new DokuHTTPClient();
40 	}
41 
42 	public function get($path, $data = array()) {
43 		$json = new JSON();
44 		return $json->decode($this->client->get($this->base_url . '&' .
45 			"path_info=/{$path}&" .
46 			buildURLparams($data, '&')));
47 	}
48 }
49