| @@ 21-31 (lines=11) @@ | ||
| 18 | ||
| 19 | public function __construct(LoopInterface $loop, string $token = '', Transport $transport = null) |
|
| 20 | { |
|
| 21 | if (!($transport instanceof Transport)) { |
|
| 22 | $options = [ |
|
| 23 | 'resource_namespace' => 'Async', |
|
| 24 | ] + ApiSettings::TRANSPORT_OPTIONS; |
|
| 25 | ||
| 26 | if ($token !== '') { |
|
| 27 | $options['headers']['Authorization'] = 'token ' . $token; |
|
| 28 | } |
|
| 29 | ||
| 30 | $transport = Factory::create($loop, $options); |
|
| 31 | } |
|
| 32 | $this->transport = $transport; |
|
| 33 | } |
|
| 34 | ||
| @@ 23-33 (lines=11) @@ | ||
| 20 | public function __construct(string $token = '', Transport $transport = null) |
|
| 21 | { |
|
| 22 | $loop = LoopFactory::create(); |
|
| 23 | if (!($transport instanceof Transport)) { |
|
| 24 | $options = [ |
|
| 25 | 'resource_namespace' => 'Async', |
|
| 26 | ] + ApiSettings::TRANSPORT_OPTIONS; |
|
| 27 | ||
| 28 | if ($token !== '') { |
|
| 29 | $options['headers']['Authorization'] = 'token ' . $token; |
|
| 30 | } |
|
| 31 | ||
| 32 | $transport = Factory::create($loop, $options); |
|
| 33 | } |
|
| 34 | $this->transport = $transport; |
|
| 35 | $this->client = new AsyncClient($loop, $token, $this->transport); |
|
| 36 | } |
|