Skip to content

Commit

Permalink
Add a basic ping test
Browse files Browse the repository at this point in the history
  • Loading branch information
ziming committed Feb 4, 2025
1 parent 958f8db commit bc595ca
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ return [

```php
$docparser = new Ziming\LaravelDocparser::make();
echo $docparser->pingV1Api();
echo $docparser->ping();

// Alternatively, you can use the facade
use Ziming\LaravelDocparser\Facades\LaravelDocparser;
LaravelDocparser::pingV1Api();
LaravelDocparser::ping();
```

Look at the source code of `src/LaravelDocparser.php` for more methods (link below):
Expand Down
2 changes: 1 addition & 1 deletion config/docparser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
// config for Ziming/LaravelDocparser
return [
'base_url' => env('DOCPARSER_BASE_URL', 'https://api.docparser.com/'),
'api_key' => env('DOCPARSER_API_KEY'),
'api_key' => env('DOCPARSER_API_KEY', ''),
];
15 changes: 1 addition & 14 deletions src/LaravelDocparser.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,9 @@ public function reIntegrateData(string $parserId, array $documentIds): PromiseIn
*
* @throws ConnectionException
*/
public function pingV1Api(): PromiseInterface|Response
public function ping(): PromiseInterface|Response
{
return Http::docparser()
->get('/v1/ping');
}

/**
* May not work, just adding since v1 has a ping method
*
* @see https://docparser.com/api/#authentication?ref=iavng
*
* @throws ConnectionException
*/
public function pingV2Api(): PromiseInterface|Response
{
return Http::docparser()
->get('/v2/ping');
}
}
7 changes: 0 additions & 7 deletions tests/ExampleTest.php

This file was deleted.

15 changes: 15 additions & 0 deletions tests/LaravelDocparserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

use Ziming\LaravelDocparser\LaravelDocparser;

test('ping docparser', function () {

$docparser = LaravelDocparser::make();

$response = $docparser->ping();

expect($response->json('error'))
->toBe('no API key found');
});

0 comments on commit bc595ca

Please sign in to comment.