1 | <?php |
||
8 | class Request |
||
9 | { |
||
10 | const API_VERSION = '1.2.7'; |
||
11 | |||
12 | private $apiKey = null; |
||
13 | private $url = null; |
||
14 | private $method; |
||
15 | private $args; |
||
16 | |||
17 | /** |
||
18 | * @param $url |
||
19 | * @param $apiKey |
||
20 | * @param $method |
||
21 | * @param array $args |
||
22 | */ |
||
23 | 35 | public function __construct($url, $apiKey, $method, $args = array()) |
|
24 | { |
||
25 | 35 | $this->url = $url; |
|
26 | 35 | $this->apiKey = $apiKey; |
|
27 | 35 | $this->method = $method; |
|
28 | 35 | $this->args = $args; |
|
29 | 35 | } |
|
30 | |||
31 | /** |
||
32 | * Send the built request url against the etherpad lite instance |
||
33 | * |
||
34 | * @return ResponseInterface |
||
35 | */ |
||
36 | public function send() |
||
37 | { |
||
38 | $client = new HttpClient($this->url); |
||
39 | |||
40 | return $client->get( |
||
41 | $this->getUrlPath(), |
||
42 | array( |
||
43 | 'query' => $this->getParams() |
||
44 | ) |
||
45 | ); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Returns the path of the request url |
||
50 | * |
||
51 | * @return string |
||
52 | */ |
||
53 | protected function getUrlPath() |
||
63 | |||
64 | /** |
||
65 | * Maps the given arguments from Client::__call to the parameter of the api method |
||
66 | * |
||
67 | * @return array |
||
68 | */ |
||
69 | 35 | public function getParams() |
|
86 | } |
||
87 |