55use GuzzleHttp \Client ;
66use GuzzleHttp \ClientInterface ;
77use GuzzleHttp \Middleware as GuzzleMiddleware ;
8+ use OpenCloud \Common \Auth \IdentityService ;
89use OpenCloud \Common \Auth \Token ;
910use OpenCloud \Common \Transport \HandlerStack ;
1011use OpenCloud \Common \Transport \Middleware ;
1112use OpenCloud \Common \Transport \Utils ;
12- use OpenCloud \Identity \v3 \Service ;
1313
1414/**
1515 * A Builder for easily creating OpenCloud services.
@@ -54,7 +54,7 @@ public function __construct(array $globalOptions = [], $rootNamespace = 'OpenClo
5454 *
5555 * @return array
5656 */
57- private function getClasses (string $ serviceName , string $ serviceVersion )
57+ private function getClasses (string $ serviceName , int $ serviceVersion )
5858 {
5959 $ rootNamespace = sprintf ("%s \\%s \\v%d " , $ this ->rootNamespace , $ serviceName , $ serviceVersion );
6060
@@ -82,7 +82,6 @@ public function createService(string $serviceName, int $serviceVersion, array $s
8282 {
8383 $ options = $ this ->mergeOptions ($ serviceOptions );
8484
85- $ this ->stockIdentityService ($ options );
8685 $ this ->stockAuthHandler ($ options );
8786 $ this ->stockHttpClient ($ options , $ serviceName );
8887
@@ -121,14 +120,6 @@ private function addDebugMiddleware(array $options, HandlerStack &$stack)
121120 }
122121 }
123122
124- private function stockIdentityService (array &$ options )
125- {
126- if (!isset ($ options ['identityService ' ])) {
127- $ httpClient = $ this ->httpClient ($ options ['authUrl ' ], HandlerStack::create ());
128- $ options ['identityService ' ] = Service::factory ($ httpClient );
129- }
130- }
131-
132123 /**
133124 * @param array $options
134125 *
@@ -166,6 +157,12 @@ private function mergeOptions(array $serviceOptions): array
166157 throw new \InvalidArgumentException ('"authUrl" is a required option ' );
167158 }
168159
160+ if (!isset ($ options ['identityService ' ]) || !($ options ['identityService ' ] instanceof IdentityService)) {
161+ throw new \InvalidArgumentException (sprintf (
162+ '"identityService" must be specified and implement %s ' , IdentityService::class
163+ ));
164+ }
165+
169166 return $ options ;
170167 }
171- }
168+ }
0 commit comments