PHP code example of glook / pecom-sdk

1. Go to this page and download the library: Download glook/pecom-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/ */

    

glook / pecom-sdk example snippets




use glook\PecomSdk\Client\PecomClientFactory;
use glook\PecomSdk\Exception\PecomApiException;
use glook\PecomSdk\Exception\PecomValidationException;

h) {
        echo $branch->getTitle() . PHP_EOL;
    }
} catch (PecomValidationException $e) {
    // 4xx — невалидные данные запроса
    echo 'Validation error: ' . $e->getMessage();
    print_r($e->getPayload());
} catch (PecomApiException $e) {
    // прочие ошибки API ПЭК
    echo 'API error: ' . $e->getMessage();
}

$client = PecomClientFactory::create($login, $password, $myHttpClient);
text
src/
  Client/
    PecomClient.php           # фасад поверх Generated\Client
    PecomClientFactory.php    # сборка HTTP-стека и аутентификации
  Http/
    PecomErrorAwareHttpClient.php   # PSR-18 декоратор: бросает Pecom*Exception
  Exception/
    PecomApiException.php
    PecomValidationException.php

generated/                     # Jane-сгенерированный код, namespace glook\PecomSdk\Generated
  Client.php
  Endpoint/
  Model/
  Normalizer/
  Runtime/
  Authentication/
  Exception/
bash
cd packages/php-sdk
composer generate