emonsite / ems-api-php-client
ems api php client
Installs: 2 833
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- phpunit/phpunit: ^7.3
- rygilles/openapi-php-client-generator: ^v0.1
This package is not auto-updated.
Last update: 2025-01-24 03:16:51 UTC
README
Requirements
The only lib required is Guzzle, PHP HTTP client.
Installation
composer require emonsite/ems-api-php-client
OpenAPI specification file
This PHP client lib was generated using the openapi.json file located in the root directory. Copy this file content in editor.swagger.io to see all the possibilities.
Use
Initialize the client
ems-api uses OAuth2 access authentication.
The first parameter must be a valid access token. The second parameter is the API entry point url. The third one is optional and is an array of headers that will be apply to every requests of the internal Guzzle client, allowing to specify the accepted language for errors eg.
/** @var \Emonsite\Api\ApiClient $apiClient */ $apiClient = new \Emonsite\Api\ApiClient( $token, 'https://ems-api-entry-point.tld', ['Accept-Language' => 'en'] );
Request resources with managers
Handle resources requesting with the main API client object like this :
/** @var \Emonsite\Api\Resources\UserResponse $userResponse */ $userResponse = $apiClient->MeManager()->getUser(); /** @var \Emonsite\Api\Resources\User $me */ $me = $userResponse->data;
TODO
More documentation to come with the first release...
Features to come :
- Link to the main documentation