1
|
|
|
<?php
|
2
|
|
|
/* zKillboard
|
3
|
|
|
* Copyright (C) 2012-2015 EVE-KILL Team and EVSCO.
|
4
|
|
|
*
|
5
|
|
|
* This program is free software: you can redistribute it and/or modify
|
6
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
7
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
8
|
|
|
* (at your option) any later version.
|
9
|
|
|
*
|
10
|
|
|
* This program is distributed in the hope that it will be useful,
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
|
|
* GNU Affero General Public License for more details.
|
14
|
|
|
*
|
15
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
16
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
|
|
*/
|
18
|
|
|
|
19
|
|
|
class api_help implements apiEndpoint
|
20
|
|
|
{
|
21
|
|
|
public function getDescription()
|
22
|
|
|
{
|
23
|
|
|
return array("type" => "description", "message" =>
|
24
|
|
|
"Shows the help description for an endpoint."
|
25
|
|
|
);
|
26
|
|
|
}
|
27
|
|
|
|
28
|
|
|
public function getAcceptedParameters()
|
29
|
|
|
{
|
30
|
|
|
return array("type" => "parameters", "parameters" =>
|
31
|
|
|
array(
|
32
|
|
|
"/api/help/<endPoint>/" => "Lists the help description for an endpoint."
|
33
|
|
|
)
|
34
|
|
|
);
|
35
|
|
|
}
|
36
|
|
|
public function execute($parameters)
|
|
|
|
|
37
|
|
|
{
|
38
|
|
|
$endPoint = isset($parameters["help"]) ? $parameters["help"] : NULL;
|
39
|
|
|
|
40
|
|
|
if(!$endPoint)
|
41
|
|
|
return array(
|
42
|
|
|
"type" => "error",
|
43
|
|
|
"message" => "No endpoint selected"
|
44
|
|
|
);
|
45
|
|
|
|
46
|
|
|
try
|
47
|
|
|
{
|
48
|
|
|
$fileName = __DIR__ . "/$endPoint.php";
|
49
|
|
|
if(!file_exists($fileName))
|
50
|
|
|
throw new Exception();
|
51
|
|
|
|
52
|
|
|
require_once $fileName;
|
53
|
|
|
$className = "api_$endPoint";
|
54
|
|
|
$class = new $className();
|
55
|
|
|
|
56
|
|
|
if(!is_a($class, "apiEndpoint"))
|
57
|
|
|
{
|
58
|
|
|
$data = array(
|
59
|
|
|
"type" => "error",
|
60
|
|
|
"message" => "Endpoint does not implement apiEndpoint"
|
61
|
|
|
);
|
62
|
|
|
}
|
63
|
|
|
|
64
|
|
|
$data = $class->getDescription();
|
65
|
|
|
}
|
66
|
|
|
catch (Exception $e)
|
67
|
|
|
{
|
68
|
|
|
$data = array(
|
69
|
|
|
"type" => "error",
|
70
|
|
|
"message" => "$endpoint ended with error: " . $e->getMessage()
|
|
|
|
|
71
|
|
|
);
|
72
|
|
|
}
|
73
|
|
|
|
74
|
|
|
return $data;
|
75
|
|
|
}
|
76
|
|
|
}
|
77
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.