vasildakov / econt
Econt API Client
Requires
- php: >=8.2
- doctrine/collections: ^2.1
- fig/http-message-util: ^1.1
- guzzlehttp/guzzle: ^7.7
- guzzlehttp/psr7: ^2.5
- jms/serializer: ^3.29
- laminas/laminas-diactoros: ^3.0
- php-http/curl-client: ^2.3
- php-http/discovery: ^1.14
- php-http/message: ^1.13
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: dev-master
- php-coveralls/php-coveralls: dev-master
- phpmd/phpmd: dev-master
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: dev-master
- squizlabs/php_codesniffer: 4.0.x-dev
- symfony/var-dumper: ^7.0
- theseer/phpdox: dev-master
- vimeo/psalm: 4.x-dev
This package is auto-updated.
Last update: 2024-12-07 21:54:11 UTC
README
Features
This library is compliant with PSR-7: HTTP message interfaces, PSR-17: HTTP Factories and PSR-18: HTTP Client
Installation
Using Composer:
$ composer require vasildakov/econt
Tests
Running unit tests:
$ ./vendor/bin/phpunit --coverage-html ./build/coverage --testsuite Unit
Configuration
The Econt API Client can be configured with any PSR-18 HTTP Client and PSR-17 HTTP Factory implementations. In the following example we use Guzzle and Diactoros to configure the client:
<?php declare(strict_types=1); use VasilDakov\Econt\Econt; use GuzzleHttp\Client; use Laminas\Diactoros\RequestFactory; /** @var Configuration $configuration */ $configuration = new Configuration('username', 'password'); /** @var \Psr\Http\Client\ClientInterface $client */ $client = new Client(); /** @var \Psr\Http\Message\RequestFactoryInterface $factory */ $factory = new RequestFactory(); $econt = new Econt($configuration, $client, $factory);
Usage
The Client provides a public API for communication with the Econt API
<?php $econt = new Econt($configuration, $client, $factory); $json = $econt->getClientProfiles(); // json
The returned json response can be decoded to associative array or php class:
<?php $array = json_decode($json); var_dump($array);
The json response can be also deserialized to an object:
<?php use VasilDakov\Econt\Serializer\SerializerFactory; $serializer = (new SerializerFactory())(); $json = $econt->getClientProfiles(); $object = $serializer->deserialize($json, GetClientProfilesResponse::class, 'json');
Notes
For more information you can check the official Econt API documentation.
The available API services can be found here.
License
Code released under the MIT license