1 | <?php |
||
16 | final class Builder |
||
17 | { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $endpoint; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $username; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $password; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $apiKey; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | private $version; |
||
42 | |||
43 | /** |
||
44 | * @var \Http\Client\HttpClient |
||
45 | */ |
||
46 | private $httpClient; |
||
47 | |||
48 | /** |
||
49 | * @var \Http\Message\UriFactory |
||
50 | */ |
||
51 | private $uriFactory; |
||
52 | |||
53 | /** |
||
54 | * @var array |
||
55 | */ |
||
56 | private $pluginsAppend = []; |
||
57 | |||
58 | /** |
||
59 | * @var array |
||
60 | */ |
||
61 | private $pluginsPrepend = []; |
||
62 | |||
63 | /** |
||
64 | * @var bool |
||
65 | */ |
||
66 | private $learningOptOut; |
||
67 | |||
68 | /** |
||
69 | * Builder constructor. |
||
70 | * |
||
71 | * @param \Http\Client\HttpClient|null $httpClient |
||
72 | * @param \Http\Message\UriFactory|null $uriFactory |
||
73 | * |
||
74 | * @throws \Http\Discovery\Exception\NotFoundException |
||
75 | */ |
||
76 | public function __construct( |
||
83 | |||
84 | /** |
||
85 | * Create HTTP client with specified plugins |
||
86 | * |
||
87 | * @return \Http\Client\Common\PluginClient |
||
88 | * |
||
89 | * @throws \InvalidArgumentException |
||
90 | * @throws \RuntimeException |
||
91 | */ |
||
92 | public function createConfiguredClient() |
||
124 | |||
125 | /** |
||
126 | * Add endpoint to client |
||
127 | * |
||
128 | * @param string $endpoint |
||
129 | * |
||
130 | * @return $this |
||
131 | */ |
||
132 | public function withEndpoint($endpoint) |
||
138 | |||
139 | /** |
||
140 | * Add username to client |
||
141 | * |
||
142 | * @param string $username |
||
143 | * |
||
144 | * @return $this |
||
145 | */ |
||
146 | public function withUsername($username) |
||
152 | |||
153 | /** |
||
154 | * Add password to client |
||
155 | * |
||
156 | * @param string $password |
||
157 | * |
||
158 | * @return $this |
||
159 | */ |
||
160 | public function withPassword($password) |
||
166 | |||
167 | public function withApiKey($apiKey) |
||
173 | |||
174 | public function withVersion($version) |
||
180 | |||
181 | /** |
||
182 | * Add username and password to client |
||
183 | * |
||
184 | * @param string $username |
||
185 | * @param string $password |
||
186 | * |
||
187 | * @return $this |
||
188 | */ |
||
189 | public function withCredentials($username, $password) |
||
195 | |||
196 | /** |
||
197 | * Opt out of Watson request logging for all requests made with this client |
||
198 | * |
||
199 | * @return $this |
||
200 | */ |
||
201 | public function withLearningOptOut() |
||
207 | |||
208 | /** |
||
209 | * Add plugins to client after it has been configured |
||
210 | * |
||
211 | * @param \Http\Client\Common\Plugin|\Http\Client\Common\Plugin[] ...$plugins |
||
212 | * |
||
213 | * @return $this |
||
214 | */ |
||
215 | public function appendPlugin(Plugin ...$plugins) |
||
223 | |||
224 | /** |
||
225 | * Add plugins to client before it has been configured |
||
226 | * |
||
227 | * @param \Http\Client\Common\Plugin|\Http\Client\Common\Plugin[] ...$plugins |
||
228 | * |
||
229 | * @return $this |
||
230 | */ |
||
231 | public function prependPlugin(Plugin ...$plugins) |
||
241 | } |
||
242 |