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 | 76 | 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 string $rootDomain |
||
60 | * @param string $apiKey |
||
61 | * @param string $apiVersion |
||
62 | * @param string $username |
||
63 | * @param string $password |
||
64 | * @param array $options |
||
65 | * @return Client |
||
66 | */ |
||
67 | 75 | public static function build($rootDomain, $apiKey, $apiVersion, $username = '', $password = '', $options = []) |
|
71 | |||
72 | /** |
||
73 | * Set up the handler stack with middleware, configure options and instantiate the Guzzle client. |
||
74 | * |
||
75 | * @return Client |
||
76 | */ |
||
77 | 75 | public function createClient() |
|
95 | |||
96 | /** |
||
97 | * Return the base URL string for the API call. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | 75 | public function baseUrl() |
|
105 | |||
106 | /** |
||
107 | * Build the base 64 encoded string that contains authentication credentials. |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 76 | protected function buildAuthenticationValue() |
|
117 | } |
||
118 |