Skip to content

Commit

Permalink
session
Browse files Browse the repository at this point in the history
  • Loading branch information
kawax committed Feb 21, 2024
1 parent f9f5a2e commit af82f9f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/BlueskyClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BlueskyClient implements Factory
{
use Macroable;

protected Collection $session;
protected ?Collection $session = null;

public function __construct(protected string $service = 'https://bsky.social')
{
Expand All @@ -28,9 +28,9 @@ public function service(string $service): static
return $this;
}

public function session(string $key): mixed
public function session(string $key = null): mixed
{
return $this->session->get($key);
return empty($key) ? $this->session : $this->session?->get($key);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions tests/Feature/Client/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ public function test_login()
$this->assertSame('test', $client->session('accessJwt'));
}

public function test_session()
{
Http::fake(fn () => ['accessJwt' => 'test', 'did' => 'test']);

$client = new BlueskyClient();

$client->service('https://bsky.social')
->login(identifier: 'identifier', password: 'password');

$this->assertSame(['accessJwt' => 'test', 'did' => 'test'], $client->session()->toArray());
$this->assertSame('test', $client->session('accessJwt'));
}

public function test_feed()
{
Http::fakeSequence()
Expand Down

0 comments on commit af82f9f

Please sign in to comment.