1 | <?php |
||
16 | class GuzzleClientFactory |
||
17 | { |
||
18 | /** @var string */ |
||
19 | protected $apiKey; |
||
20 | |||
21 | /** @var string */ |
||
22 | protected $apiVersion; |
||
23 | |||
24 | /** @var string */ |
||
25 | protected $username; |
||
26 | |||
27 | /** @var string */ |
||
28 | protected $password; |
||
29 | |||
30 | /** @var string */ |
||
31 | protected $rootDomain; |
||
32 | |||
33 | /** @var array */ |
||
34 | protected $userOptions; |
||
35 | |||
36 | /** |
||
37 | * GuzzleClientFactory constructor. |
||
38 | * |
||
39 | * @param string $rootDomain |
||
40 | * @param string $apiKey |
||
41 | * @param string $apiVersion |
||
42 | * @param string $username |
||
43 | * @param string $password |
||
44 | * @param array $options |
||
45 | */ |
||
46 | 89 | public function __construct($rootDomain, $apiKey, $apiVersion, $username = '', $password = '', $options = []) |
|
55 | |||
56 | /** |
||
57 | * Static method for easily creating a client. Requires the same parameters as the class constructor. |
||
58 | * |
||
59 | * @param array ...$args |
||
60 | * @return Client |
||
61 | */ |
||
62 | 88 | public static function build(...$args) |
|
66 | |||
67 | /** |
||
68 | * Set up the handler stack with middleware, configure options and instantiate the Guzzle client. |
||
69 | * |
||
70 | * @return Client |
||
71 | */ |
||
72 | 88 | public function createClient() |
|
90 | |||
91 | /** |
||
92 | * Return the base URL string for the API call. |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | 88 | public function baseUrl() |
|
100 | |||
101 | /** |
||
102 | * Build the base 64 encoded string that contains authentication credentials. |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | 89 | protected function buildAuthenticationValue() |
|
112 | } |
||
113 |