Skip to content

Commit

Permalink
fix: docs for auth (#14)
Browse files Browse the repository at this point in the history
* fix: docs for auth

* feat: wrap original client

* Apply php-cs-fixer changes

---------

Co-authored-by: cedricziel <cedricziel@users.noreply.github.com>
  • Loading branch information
cedricziel and cedricziel authored Aug 5, 2024
1 parent 2ec915c commit 0b20cc1
Show file tree
Hide file tree
Showing 7 changed files with 2,846 additions and 328 deletions.
16 changes: 8 additions & 8 deletions .github/README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ composer require cedricziel/baserow
## Docs

```php
use CedricZiel\Baserow\Generated\Client;
use CedricZiel\Baserow\Client;

$baserow = Client::create(null, [
// optional, default is baserow.io
new AddHostPlugin(new Uri('https://my-baserow.example.com')),
$token = 'my-token';
$authRegistry = new AuthenticationRegistry([
new DatabaseTokenAuthentication($token),
]);

// use ONE of DatabaseTokenAuthentication
new DatabaseTokenAuthentication('YOUR_TOKEN'),
// OR JWTAuthentication
new JWTAuthentication('JWT Token'),
$client = Client::create(null, [
new AddHostPlugin(new Uri('https://baserow.example.com')),
$authRegistry,
]);

// list all rows in table id 42
Expand Down
13 changes: 12 additions & 1 deletion .regen-docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ function underscoreToCamelCase($string, $capitalizeFirstCharacter = false)
$doc .= $method['description'] ?? '';
$doc .= "\n\n";
$doc .= '```php'."\n";
$doc .= '$client = \\CedricZiel\\Baserow\\Client::create();'."\n";
$doc .= <<<EOF
\$token = 'my-token';
\$authRegistry = new AuthenticationRegistry([
new DatabaseTokenAuthentication(\$token),
]);
\$client = \CedricZiel\Baserow\Client::create(null, [
new AddHostPlugin(new Uri('https://baserow.example.com')),
\$authRegistry,
]);
EOF;
$doc .= '$client->'."{$methodName}();\n";
$doc .= '```'."\n";
$doc .= "\n";
Expand Down
Loading

0 comments on commit 0b20cc1

Please sign in to comment.