Skip to content

Commit 77c3a95

Browse files
Refactor factory method from withBearerToken to withAuthToken
1 parent 5e64635 commit 77c3a95

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Factory.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Factory
3636
/**
3737
* The bearer token used for authentication.
3838
*/
39-
protected string $bearerToken;
39+
protected string $authToken;
4040

4141
/**
4242
* The http client to use for the requests.
@@ -87,9 +87,9 @@ public function withTenant(string $tenant): self
8787
/**
8888
* The bearer token used to authenticate requests.
8989
*/
90-
public function withBearerToken(string $bearerToken): self
90+
public function withAuthToken(string $authToken): self
9191
{
92-
$this->bearerToken = $bearerToken;
92+
$this->authToken = $authToken;
9393
return $this;
9494
}
9595

@@ -118,8 +118,8 @@ public function createApiClient() : ChromaApiClient
118118
'Accept' => 'application/json',
119119
];
120120

121-
if (!empty($this->bearerToken)) {
122-
$headers['Authorization'] = 'Bearer ' . $this->bearerToken;
121+
if (!empty($this->authToken)) {
122+
$headers['Authorization'] = 'Bearer ' . $this->authToken;
123123
}
124124

125125
$this->httpClient ??= new \GuzzleHttp\Client([

tests/ChromaDB.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
test('can connect to an API token authenticated chroma server', function () {
2525
$client = ChromaDB::factory()
2626
->withPort(8001)
27-
->withBearerToken('test-token')
27+
->withAuthToken('test-token')
2828
->connect();
2929

3030
expect($client)->toBeInstanceOf(Client::class);
@@ -33,7 +33,7 @@
3333
it('cannot connect to an API token authenticated chroma server with wrong token', function () {
3434
ChromaDB::factory()
3535
->withPort(8001)
36-
->withBearerToken('wrong-token')
36+
->withAuthToken('wrong-token')
3737
->connect();
3838
})->throws(ChromaAuthorizationException::class);
3939

0 commit comments

Comments
 (0)