1 | <?php |
||
14 | class Builder |
||
15 | { |
||
16 | use DiscoveryTrait; |
||
17 | |||
18 | /** |
||
19 | * @var \Http\Client\HttpClient |
||
20 | */ |
||
21 | private $httpClient; |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | private $plugins = []; |
||
27 | |||
28 | /** |
||
29 | * @var string $username |
||
30 | */ |
||
31 | private $username; |
||
32 | |||
33 | /** |
||
34 | * @var string $password |
||
35 | */ |
||
36 | private $password; |
||
37 | |||
38 | /** |
||
39 | * @param HttpClient|null $httpClient HTTP Client for sending requests. |
||
40 | */ |
||
41 | public function __construct( |
||
46 | |||
47 | /** |
||
48 | * @return \Http\Client\Common\PluginClient HTTP client with configured plugins. |
||
49 | */ |
||
50 | public function createConfiguredClient() |
||
56 | |||
57 | /** |
||
58 | * Add username and password to client. |
||
59 | * |
||
60 | * @param string $username API username. |
||
61 | * @param string $password API password. |
||
62 | * |
||
63 | * @return \IBM\Watson\Common\HttpClient\Builder |
||
64 | */ |
||
65 | public function withCredentials($username, $password) |
||
71 | |||
72 | /** |
||
73 | * Add username to client. |
||
74 | * |
||
75 | * @param string $username API username. |
||
76 | * |
||
77 | * @return $this |
||
78 | */ |
||
79 | public function withUsername($username) |
||
85 | |||
86 | /** |
||
87 | * Add password to client. |
||
88 | * |
||
89 | * @param string $password API password. |
||
90 | * |
||
91 | * @return $this |
||
92 | */ |
||
93 | public function withPassword($password) |
||
99 | |||
100 | /** |
||
101 | * Add BasicAuth authentication plugin to client. |
||
102 | * |
||
103 | * @return $this |
||
104 | */ |
||
105 | private function addAuthenticationPlugin() |
||
113 | } |
||
114 |