1 | <?php |
||
28 | class Client |
||
29 | { |
||
30 | /** |
||
31 | * http client |
||
32 | * @var \Http\Client\HttpClient $httpClient |
||
33 | */ |
||
34 | private $httpClient = null; |
||
35 | |||
36 | /** |
||
37 | * message factory |
||
38 | * @var \Http\Message\MessageFactory $messageFactory |
||
39 | */ |
||
40 | private $messageFactory = null; |
||
41 | |||
42 | /** |
||
43 | * plugins |
||
44 | * @var array $plugins |
||
45 | */ |
||
46 | private $plugins = []; |
||
47 | |||
48 | /** |
||
49 | * constructor |
||
50 | * |
||
51 | * @param string $baseUri |
||
52 | * @param \Http\Client\HttpClient $httpClient |
||
53 | */ |
||
54 | 6 | public function __construct($baseUri, HttpClient $httpClient = null) |
|
63 | |||
64 | /** |
||
65 | * api |
||
66 | * |
||
67 | * @param string $name |
||
68 | * |
||
69 | * @return \Unikorp\KongAdminApi\ApiInterface |
||
70 | * |
||
71 | * @throws \InvalidArgumentException |
||
72 | */ |
||
73 | 6 | public function api($name) |
|
74 | { |
||
75 | switch ($name) { |
||
76 | 6 | case 'api': |
|
77 | 1 | return new Api\Api($this); |
|
78 | 5 | case 'cluster': |
|
79 | 1 | return new Api\Cluster($this); |
|
80 | 4 | case 'consumer': |
|
81 | 1 | return new Api\Consumer($this); |
|
82 | 3 | case 'information': |
|
83 | 1 | return new Api\Information($this); |
|
84 | 2 | case 'plugin': |
|
85 | 1 | return new Api\Plugin($this); |
|
86 | default: |
||
87 | 1 | throw new \InvalidArgumentException(sprintf('Undefined api instance called: %s', $name)); |
|
88 | } |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * add plugin |
||
93 | * |
||
94 | * @param \Http\Client\Common\Plugin $plugin |
||
95 | * |
||
96 | * @return void |
||
97 | */ |
||
98 | 6 | public function addPlugin(Plugin $plugin) |
|
102 | |||
103 | /** |
||
104 | * get http client |
||
105 | * |
||
106 | * @return \Http\Client\Common\HttpMethodsClient |
||
107 | */ |
||
108 | public function getHttpClient() |
||
115 | } |
||
116 |