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