Skip to content

Commit 81ef41b

Browse files
committed
Sync client and conditions example
1 parent c53f047 commit 81ef41b

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

examples/conditions.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
use ApiClients\Client\WeatherUnderground\Client;
4+
use function ApiClients\Foundation\resource_pretty_print;
5+
6+
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php';
7+
8+
$client = new Client(require 'resolve_token.php');
9+
10+
resource_pretty_print($client->conditions('Broek_op_Langedijk'));

src/Client.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ApiClients\Client\WeatherUnderground;
44

5+
use ApiClients\Client\WeatherUnderground\Resource\ConditionInterface;
56
use ApiClients\Client\WeatherUnderground\Resource\UserInterface;
67
use React\EventLoop\Factory;
78
use React\EventLoop\LoopInterface;
@@ -19,16 +20,16 @@ final class Client
1920
*/
2021
private $client;
2122

22-
public function __construct(AuthenticationInterface $auth)
23+
public function __construct(string $token)
2324
{
2425
$this->loop = Factory::create();
25-
$this->client = AsyncClient::create($this->loop, $auth);
26+
$this->client = AsyncClient::create($this->loop, $token);
2627
}
2728

28-
public function user(string $user): UserInterface
29+
public function conditions(string $location): ConditionInterface
2930
{
3031
return await(
31-
$this->client->user($user),
32+
$this->client->conditions($location),
3233
$this->loop
3334
);
3435
}

0 commit comments

Comments
 (0)