public function __construct(LoopInterface $loop, Transport $transport = null) { if (!$transport instanceof Transport) { $transport = Factory::create($loop, ['resource_namespace' => 'Async'] + ApiSettings::TRANSPORT_OPTIONS); } $this->transport = $transport; }
public function __construct(Transport $transport = null) { $loop = LoopFactory::create(); if (!$transport instanceof Transport) { $transport = Factory::create($loop, ['resource_namespace' => 'Sync'] + ApiSettings::TRANSPORT_OPTIONS); } $this->transport = $transport; $this->client = new AsyncClient($loop, $this->transport); }
/** * @param LoopInterface $loop * @param string $token * @param Transport|null $transport */ public function __construct(LoopInterface $loop, string $token = '', Transport $transport = null) { if (!$transport instanceof Transport) { $options = ['resource_namespace' => 'Async'] + ApiSettings::TRANSPORT_OPTIONS; if ($token !== '') { $options['headers']['Authorization'] = 'token ' . $token; } $transport = Factory::create($loop, $options); } $this->transport = $transport; }