praftr / wimi-api-client
PHP Wimi Api Client
Requires
- guzzlehttp/guzzle: ^7.8
- psr/http-client: ^1.0
Requires (Dev)
- phpunit/phpunit: ^10
- symfony/css-selector: ^6.3
- symfony/dom-crawler: ^6.3
README
This PHP package is a client for the Wimi API. Please refer to the official API documentation.
Every target implementation is automatically generated, please see "Generate request classes" section down below to learn more.
Requirements
- PHP 8.1 and above
Installation
composer require praftr/wimi-api-client
Usage
<?php require 'vendor/autoload.php'; use Praftr\WimiApiClient\ApiClient; use Praftr\WimiApiClient\Request\Main\Account\GetProjectsRequest; $accountId = 1; $userId = 1; $apiClient = new ApiClient('account_name', 'username', 'password', 'app_token'); $apiClient->handle(new GetProjectsRequest($accountId, $userId)); // ['projects' => ['project_id: 1, ...
Optionally, you can override the HTTP client with any implementation of psr/http-client.
For instance using Symfony HttpClient component
composer require symfony/http-client
<?php require 'vendor/autoload.php'; use Symfony\Component\HttpClient\Psr18Client; use Praftr\WimiApiClient\ApiClient; $httpClient = new Psr18Client(); $apiClient = new ApiClient('account_name', 'username', 'password', 'app_token', $httpClient);
Default is Guzzle
Generate request classes
Every class in Request directory (except Abstract and Interface) is automatically generated by scrapping and parsing the online API documentation.
The code that generates classes can be found under src/Generator/
.
Feel free to test it out and submit a PR if you notice any update in the API documentation.
First, delete generated request classes
php bin/generate_requests.php
Test
php ./vendor/bin/phpunit
Code analysis
php tools/php-cs-fixer/vendor/bin/php-cs-fixer --config=.php-cs-fixer.php.dist --allow-risky=yes fix
License
This package is made available under the MIT License (MIT). Please see License File for more information.