-
Notifications
You must be signed in to change notification settings - Fork 125
/
Client.php
34 lines (32 loc) · 1.74 KB
/
Client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
namespace Jane\OpenApi\Tests\Expected;
class Client extends \Jane\OpenApiRuntime\Client\Psr7HttplugClient
{
/**
* @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE)
*
* @return null|\Jane\OpenApi\Tests\Expected\Model\Foo|\Psr\Http\Message\ResponseInterface
*/
public function getFoo(string $fetch = self::FETCH_OBJECT)
{
return $this->executePsr7Endpoint(new \Jane\OpenApi\Tests\Expected\Endpoint\GetFoo(), $fetch);
}
public static function create($httpClient = null, \Jane\OpenApiRuntime\Client\Authentication $authentication = null)
{
if (null === $httpClient) {
$httpClient = \Http\Discovery\HttpClientDiscovery::find();
$plugins = array();
$uri = \Http\Discovery\UriFactoryDiscovery::find()->createUri('https://www.foo-host.com/base-path');
$plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($uri);
$plugins[] = new \Http\Client\Common\Plugin\AddPathPlugin($uri);
if (null !== $authentication) {
$plugins[] = $authentication->getPlugin();
}
$httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins);
}
$messageFactory = \Http\Discovery\MessageFactoryDiscovery::find();
$streamFactory = \Http\Discovery\StreamFactoryDiscovery::find();
$serializer = new \Symfony\Component\Serializer\Serializer(\Jane\OpenApi\Tests\Expected\Normalizer\NormalizerFactory::create(), array(new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode())));
return new static($httpClient, $messageFactory, $serializer, $streamFactory);
}
}