Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wefact response now returns array if resource is not found #2

Merged
merged 9 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update readme
  • Loading branch information
Casmo committed Jun 13, 2023
commit fa00154f13ce92b2553ee2656e3915e7366f6d7c
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ Then you can use the package like this:
```php
$weFact = new \Vormkracht10\WeFact\WeFact('your-api-key');

$invoices = $weFact->invoices()->list();
$response = $weFact->invoices()->list();
if (isset($response['invoices'])) {
print_r($response['invoices']);
}
```

## Available methods
Expand All @@ -124,28 +127,39 @@ $invoices = $weFact->invoices()->list();
#### List creditors

```php
$weFact->creditors()->list();
$response = $weFact->creditors()->list();
if (isset($response['creditors'])) {
print_r($response['creditors']);
}
```

#### Create creditor

Required parameters: `CompanyName` or `SurName`.

```php
$weFact->creditors()->create([
$response = $weFact->creditors()->create([
'CompanyName' => 'Your company name',
])
]);
if ($result['status'] == 'success') {
print_r($response['company']);
}
```

#### Update creditor

Required parameter: `Identifier` or `CreditorCode`.

```php
$weFact->creditors()->edit([
$result = $weFact->creditors()->edit([
'Identifier' => $creditorId,
'CompanyName' => 'Your company name',
])
]);

if ($result['status'] == 'error') {
// Something went wrong
print_r($result['errors']);
}
```

#### Show creditor
Expand Down
11 changes: 5 additions & 6 deletions src/Traits/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
trait Request
{
/**
* @param array<string, mixed> $params
* @param array<string, mixed> $params
* @return array<string, mixed>
*/
public function sendRequest(string $controller, string $action, array $params): array
Expand All @@ -25,13 +25,12 @@ public function sendRequest(string $controller, string $action, array $params):
}

/**
* @param array<string, mixed> $params
* @return array<string, mixed>
*
* @throws ClientException;
* @throws ServerException;
* @throws JsonException;
* @throws BadResponseException;
* @throws \GuzzleHttp\Exception\ClientException;
* @throws \GuzzleHttp\Exception\ServerException;
* @throws \JsonException;
* @throws \GuzzleHttp\Exception\BadResponseException;
*/
public function parseResponse(ResponseInterface $response): array
{
Expand Down