Skip to content

Commit

Permalink
[Release] Upgrade API to v2 (#16)
Browse files Browse the repository at this point in the history
* Update package and PHP versions

* Upgrade to v2

* Update README

* Make rootcertificate nullable

* Fix styling

* Add more search options

* Fix styling

* Update README

* Add PHPStan

* Fix styling

* Add upgrade docs

---------

Co-authored-by: Baspa <[email protected]>
  • Loading branch information
Baspa and Baspa authored Aug 30, 2024
1 parent 3d635c9 commit a747233
Show file tree
Hide file tree
Showing 10 changed files with 311 additions and 81 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: PHPStan

on:
pull_request:
paths:
- "**.php"
- "phpstan.neon.dist"
push:
branches:
- main

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: ./vendor/bin/phpstan analyse --error-format=github --debug
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ phpunit.xml
psalm.xml
vendor
.php-cs-fixer.cache

!docs
46 changes: 39 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

# KvK API client (Dutch Chamber of Commerce)

[![Latest Version on Packagist](https://img.shields.io/packagist/v/vormkracht10/kvk-api.svg?style=flat-square)](https://packagist.org/packages/vormkracht10/kvk-api)
[![Tests](https://github.com/vormkracht10/kvk-api/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/vormkracht10/kvk-api/actions/workflows/run-tests.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/vormkracht10/kvk-api.svg?style=flat-square)](https://packagist.org/packages/vormkracht10/kvk-api)

PHP package to communicate with the business register of the Dutch Chamber of Commerce.
PHP package to communicate with the business register of the Dutch Chamber of Commerce.

At the moment it is only possible to search by company name. The result will contain the following data:
At the moment it is only possible to search by company name. The result will contain the following data:

<ul>
<li>KvK number</li>
Expand All @@ -25,21 +24,54 @@ You can install the package via composer:
composer require vormkracht10/kvk-api
```

## Upgrade guide

See the [upgrade guide](docs/upgrade.md) for more information on what has changed recently.

## Usage

> Note: if you don't have an API key yet, get yours at the [developer portal](https://developers.kvk.nl/) of the Chamber of Commerce
```php
use Vormkracht10\KvkApi\ClientFactory;

$apiKey = '<KVK_API_KEY>';

// Optional SSL certificate
$rootCertificate = '<PATH_TO_SSL_CERT>';

$kvk = ClientFactory::create($apiKey, $rootCertificate);

// Search by company name
$companies = $kvk->search('Vormkracht10');
```
> Note: if you don't have an API key yet, get yours at the [developer portal](https://developers.kvk.nl/) of the Chamber of Commerce

### Search with additional parameters

```php
$companies = $kvk->search('Vormkracht10', [
'pagina' => 1,
'resultatenPerPagina' => 10
]);
```

### Set page and results per page before searching

```php
$kvk->setPage(2);
$kvk->setResultsPerPage(20);
```

### Search by KvK number

```php
$companies = $kvk->searchByKvkNumber('12345678');
```

### Search by RSIN

```php
$companies = $kvk->searchByRSIN('12345678');
```

## Testing

Expand All @@ -53,8 +85,8 @@ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed re

## Credits

- [Bas van Dinther](https://github.com/Baspa)
- [All Contributors](../../contributors)
- [Bas van Dinther](https://github.com/Baspa)
- [All Contributors](../../contributors)

## License

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
}
],
"require": {
"php": "^7.4|^8.0",
"php": "^7.4|^8.0|^8.1|^8.2|^8.3",
"guzzlehttp/guzzle": "^7.0",
"illuminate/support": "^8.0|^9.0|^10.0"
"illuminate/support": "^8.0|^9.0|^10.0|^11.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"pestphp/pest": "^1.20",
"phpstan/phpstan": "^1.12",
"spatie/ray": "^1.28"
},
"autoload": {
Expand Down
62 changes: 62 additions & 0 deletions docs/upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Upgrading from v1.x to v2.x

## Changes in Search Results

In the new version, the search results have been expanded to include more detailed information. The Company object now contains the following data:

- KvK number
- Establishment number
- Tradename
- Address(es) (including type, full address, street, house number, zip code, city, and country)
- Website(s)

## New Search Methods

1. Search by KvK Number
The new version introduces the ability to search by KvK number:

```php
$companies = $kvk->searchByKvkNumber('12345678');
```

2. Search by RSIN
You can now search by RSIN (Rechtspersonen en Samenwerkingsverbanden Informatienummer):

```php
$companies = $kvk->searchByRSIN('12345678');
```

## Pagination Support

The new version adds support for pagination in search results:

```php
$kvk->setPage(2);
$kvk->setResultsPerPage(20);
```

Alternatively, you can pass these parameters directly to the search method:

```php
$companies = $kvk->search('Vormkracht10', [
'pagina' => 1,
'resultatenPerPagina' => 10
]);
```

## Updating dependencies

```bash
{
"require": {
"vormkracht10/kvk-api": "^2.0"
}
}
```

Then run `composer update` to install the new version.

## Breaking changes

- The structure of the Company object has changed. Make sure to update any code that relies on the specific structure of the search results.
- The method signatures for creating the client and performing searches have been updated. Review and update your code accordingly.
7 changes: 7 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
level: 8
paths:
- src
tmpDir: build/phpstan
parallel:
maximumNumberOfProcesses: 1
Loading

0 comments on commit a747233

Please sign in to comment.