Skip to content

Commit

Permalink
Wefact response now returns array if resource is not found (#2)
Browse files Browse the repository at this point in the history
* Wefact response now returns array if resource is not found
  • Loading branch information
Casmo authored Jun 13, 2023
1 parent e47c206 commit 4a4c312
Show file tree
Hide file tree
Showing 11 changed files with 259 additions and 138 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

All notable changes to `wefact-php` will be documented in this file.
## v0.5.0 - 2023-06-13

Removed `InvalidRequestException` and use Guzzle Client Exceptions.

## v0.4.0 - 2023-06-08

Expand Down
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
10 changes: 0 additions & 10 deletions src/Exceptions/InvalidRequestException.php

This file was deleted.

6 changes: 4 additions & 2 deletions src/Resources/Debtor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Vormkracht10\WeFact\Resources;

use Vormkracht10\WeFact\Exceptions\InvalidRequestException;
use Vormkracht10\WeFact\Exceptions\MethodNotAvailableException;

class Debtor extends Resource
Expand All @@ -14,7 +13,10 @@ public function getResourceName(): string
return self::CONTROLLER_NAME;
}

public function delete(array $params = []): array|MethodNotAvailableException|InvalidRequestException
/**
* @return array<mixed, string>
*/
public function delete(array $params = []): array
{
throw new MethodNotAvailableException(
sprintf('%s is not available for this resource.', __METHOD__)
Expand Down
Loading

0 comments on commit 4a4c312

Please sign in to comment.