PHP code example of fostenslave / nalogka-deals-sdk
1. Go to this page and download the library: Download fostenslave/nalogka-deals-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fostenslave / nalogka-deals-sdk example snippets
use Fostenslave\NalogkaDealsSDK\ApiClient;
use Fostenslave\NalogkaDealsSDK\Serialization\SerializationComponent;
$serializationComponent = new SerializationComponent();
$apiClient = new ApiClient("https://sandbox.deals.api.nalogka.ru/", [
'headers' => [
'X-Nalogka-Auth-Token' => '9qASPlstioSjksdqpLkSF2js8Iks1CIv'
],
], $serializationComponent);
use Fostenslave\NalogkaDealsSDK\Request\DealsListRequest;
use Fostenslave\NalogkaDealsSDK\Exception\ApiErrorException;
use Fostenslave\NalogkaDealsSDK\Exception\NalogkaSdkException;
use Fostenslave\NalogkaDealsSDK\Exception\ServerErrorException;
$dealsListRequest = (new DealsListRequest($apiClient))
->page(1)
->items(3);
try {
$deals = $dealsListRequest->request();
} catch (ApiErrorException $e) {
// Ошибка от API
} catch (ServerErrorException $e) {
// Неизвестный ответ от сервера
} catch (NalogkaSdkException $e) {
// Ошибка в SDK, например проблема с десериализация
}
use Fostenslave\NalogkaDealsSDK\Request\DealGetRequest;
$dealGetRequest = (new DealGetRequest($apiClient))
->id(60);
$deal = $dealGetRequest->request();