1 | <?php |
||
20 | final class HttpClientConfigurator |
||
21 | { |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $endpoint = 'https://api.happyr.com'; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $apiIdentifier; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | private $apiSecret; |
||
36 | |||
37 | /** |
||
38 | * @var UriFactory |
||
39 | */ |
||
40 | private $uriFactory; |
||
41 | |||
42 | /** |
||
43 | * @var HttpClient |
||
44 | */ |
||
45 | private $httpClient; |
||
46 | |||
47 | /** |
||
48 | * @var Plugin[] |
||
49 | */ |
||
50 | private $prependPlugins = []; |
||
51 | |||
52 | /** |
||
53 | * @var Plugin[] |
||
54 | */ |
||
55 | private $appendPlugins = []; |
||
56 | |||
57 | /** |
||
58 | * @param HttpClient|null $httpClient |
||
59 | * @param UriFactory|null $uriFactory |
||
60 | */ |
||
61 | public function __construct(HttpClient $httpClient = null, UriFactory $uriFactory = null) |
||
66 | |||
67 | /** |
||
68 | * @return HttpClient |
||
69 | */ |
||
70 | public function createConfiguredClient() |
||
86 | |||
87 | /** |
||
88 | * @param string $endpoint |
||
89 | * |
||
90 | * @return HttpClientConfigurator |
||
91 | */ |
||
92 | public function setEndpoint($endpoint) |
||
98 | |||
99 | /** |
||
100 | * @param string $identifier |
||
101 | * @param string $secret |
||
102 | * |
||
103 | * @return HttpClientConfigurator |
||
104 | */ |
||
105 | public function setApiCredentials($identifier, $secret) |
||
112 | |||
113 | /** |
||
114 | * @param Plugin $plugin |
||
115 | * |
||
116 | * @return HttpClientConfigurator |
||
117 | */ |
||
118 | public function appendPlugin(Plugin ...$plugin) |
||
126 | |||
127 | /** |
||
128 | * @param Plugin $plugin |
||
129 | * |
||
130 | * @return HttpClientConfigurator |
||
131 | */ |
||
132 | public function prependPlugin(Plugin ...$plugin) |
||
141 | } |
||
142 |