Skip to content

Commit bc595ca

Browse files
committed
Add a basic ping test
1 parent 958f8db commit bc595ca

File tree

5 files changed

+19
-24
lines changed

5 files changed

+19
-24
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ return [
4242

4343
```php
4444
$docparser = new Ziming\LaravelDocparser::make();
45-
echo $docparser->pingV1Api();
45+
echo $docparser->ping();
4646

4747
// Alternatively, you can use the facade
4848
use Ziming\LaravelDocparser\Facades\LaravelDocparser;
49-
LaravelDocparser::pingV1Api();
49+
LaravelDocparser::ping();
5050
```
5151

5252
Look at the source code of `src/LaravelDocparser.php` for more methods (link below):

config/docparser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
// config for Ziming/LaravelDocparser
66
return [
77
'base_url' => env('DOCPARSER_BASE_URL', 'https://api.docparser.com/'),
8-
'api_key' => env('DOCPARSER_API_KEY'),
8+
'api_key' => env('DOCPARSER_API_KEY', ''),
99
];

src/LaravelDocparser.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,9 @@ public function reIntegrateData(string $parserId, array $documentIds): PromiseIn
158158
*
159159
* @throws ConnectionException
160160
*/
161-
public function pingV1Api(): PromiseInterface|Response
161+
public function ping(): PromiseInterface|Response
162162
{
163163
return Http::docparser()
164164
->get('/v1/ping');
165165
}
166-
167-
/**
168-
* May not work, just adding since v1 has a ping method
169-
*
170-
* @see https://docparser.com/api/#authentication?ref=iavng
171-
*
172-
* @throws ConnectionException
173-
*/
174-
public function pingV2Api(): PromiseInterface|Response
175-
{
176-
return Http::docparser()
177-
->get('/v2/ping');
178-
}
179166
}

tests/ExampleTest.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/LaravelDocparserTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Ziming\LaravelDocparser\LaravelDocparser;
6+
7+
test('ping docparser', function () {
8+
9+
$docparser = LaravelDocparser::make();
10+
11+
$response = $docparser->ping();
12+
13+
expect($response->json('error'))
14+
->toBe('no API key found');
15+
});

0 commit comments

Comments
 (0)