88use GuzzleHttp \ClientInterface ;
99use GuzzleHttp \Command \Guzzle \GuzzleClient ;
1010use GuzzleHttp \Command \Guzzle \Description ;
11+ use GuzzleHttp \Command \Result ;
12+ use GuzzleHttp \Command \ResultInterface ;
1113use GuzzleHttp \HandlerStack ;
1214use GuzzleHttp \Subscriber \Oauth \Oauth1 ;
15+ use GuzzleHttp \Utils ;
1316use InvalidArgumentException ;
17+ use Psr \Http \Message \RequestInterface ;
18+ use Psr \Http \Message \ResponseInterface ;
1419
1520class ClientFactory
1621{
@@ -48,8 +53,16 @@ private static function createGuzzleClient(array $config, string $authType): Guz
4853 $ serviceDescription = new Description ($ serviceDescriptionContents );
4954
5055 return new GuzzleClient (
51- $ httpClient ,
52- $ serviceDescription ,
56+ client: $ httpClient ,
57+ description: $ serviceDescription ,
58+ responseToResultTransformer: function (
59+ ResponseInterface $ response ,
60+ RequestInterface $ request
61+ ): ResultInterface {
62+ return new Result ([
63+ 'response ' => Utils::jsonDecode ((string ) $ response ->getBody (), true )
64+ ]);
65+ }
5366 );
5467 }
5568
@@ -72,6 +85,7 @@ private static function createOAuthHttpClient(array $config): ClientInterface
7285 'token ' => $ config ['token ' ],
7386 'token_secret ' => $ config ['token_secret ' ],
7487 ]));
88+
7589 $ config ['handler ' ] = $ stack ;
7690 $ config ['auth ' ] = 'oauth ' ;
7791
0 commit comments