jhoffland/natec-php-sdk

Natec Klantportaal API 客户端库 for PHP

1.0.0 2023-05-11 20:29 UTC

This package is not auto-updated.

Last update: 2024-09-28 01:35:58 UTC


README

Run tests codecov

用法

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' ]));

贡献

请随意为此库做出贡献。通过在 GitHub 仓库中进行分支并提交拉取请求来贡献。在提交拉取请求时,请确保以下条件:

  • 拉取请求标题清晰;
  • 拉取请求不包含过多(不必要的/小的)提交;
  • 添加或更新测试以测试新增/改进的功能;
  • 代码符合编码标准,通过代码分析和所有测试(《composer run-tests》)
    • PHP_CodeSniffer(《vendor/bin/phpcs》);
    • PHPStan(《vendor/bin/phpstan》);
    • PHPUnit(《vendor/bin/phpunit》)。

待办事项

  • 为测试中的每个断言提供描述性消息。
  • 添加对 NatecSdk\Client::getPdf()NatecSdk\Resources\Order::confirmation() 的测试。
  • 是否为每个资源添加测试?