jhoffland / natec-php-sdk
Natec Klantportaal API Client Library for PHP
1.0.0
2023-05-11 20:29 UTC
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.5
Requires (Dev)
- phpstan/phpstan: ^1.9
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^10.0
- slevomat/coding-standard: ^8.6
- squizlabs/php_codesniffer: ^3.7
Suggests
This package is not auto-updated.
Last update: 2024-11-09 02:06:08 UTC
README
Usage
use NatecSdk\Client; use NatecSdk\Resources\Types\AssortmentUpdateType; use NatecSdk\Resources\AssortmentUpdate; use NatecSdk\Resources\Invoice; use NatecSdk\Resources\Shipment; $apiToken = 'xxx'; $client = new Client($apiToken); // Get an iterator with all resources, matching the filter (query). $assortmentUpdates = AssortmentUpdate::get($client, [ 'type' => AssortmentUpdateType::PRODUCT_EXPECTED_ARRIVAL->value ]); foreach($assortmentUpdates as $assortmentUpdate) { var_dump($assortmentUpdate); } // Get one resource, by the primary key value (id). The primary key for e.g. invoices is documentNo. var_dump(Invoice::find($client, 'GVFN22-12345')); // Save an order confirmation PDF file. $confirmationFile = fopen(__DIR__ . sprintf('/confirmation-%s.pdf', $order->no), 'w+'); $order->confirmation($client, $confirmation); // Make an API request var_dump($client->get(Shipment::endpoint())); var_dump($client->post('/orders', [ 'reference' => 'Example order' ]));
Contributing
Feel free to contribute to this library. Contribute by forking the GitHub repository and opening a pull request. When opening a pull request, please make sure that:
- The pull request has a clear title;
- The pull request does not consist of too many (unnecessary/small) commits;
- Tests are added or updated to test the added/improved functionality;
- The code complies to the coding standard, passes the code analysis and passes all the tests (
composer run-tests
):- PHP_CodeSniffer (
vendor/bin/phpcs
); - PHPStan (
vendor/bin/phpstan
); - PHPUnit (
vendor/bin/phpunit
).
- PHP_CodeSniffer (
ToDo's
- Give every assertion in the tests a descriptive message.
- Add a test for
NatecSdk\Client::getPdf()
andNatecSdk\Resources\Order::confirmation()
- Add a test for every resource?