Download the PHP package paysera/lib-rest-client-common without Composer
On this page you can find all versions of the php package paysera/lib-rest-client-common. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download paysera/lib-rest-client-common
More information about paysera/lib-rest-client-common
Files in paysera/lib-rest-client-common
Package lib-rest-client-common
Short Description Base classes/helpers used in REST Clients
License
Informations about the package lib-rest-client-common
lib-rest-client-common 
Generic library for RESTful API clients
Usage
You should create ClientFactory class, which extends ClientFactoryAbstract.
In ClientFactory you can override any parent configuration if needed.
Simple example of ClientFactory:
Using this pattern you can reuse same ApiClient with it's authentication and other options in different APIs.
In addition to ClientFactory, you should create also the Client itself.
Finally you will use the Client itself, so it should contain all the methods your API provides.
Simple example of TestClient:
You should implement mapping or data transformation where applicable in TestClient methods.
Example:
- Please note that only single authentication mechanism is supported.
Middleware
You can add custom Guzzle middleware to client factories. Middleware must be a callable (e.g. a class with __invoke):
Register middleware on the factory:
Middleware can also be added after client creation (e.g., via Symfony DI addMethodCall). It is pushed onto the existing HandlerStack and takes effect on subsequent requests.
In case you want to change some configuration options at runtime, use TestClient::withOptions():
Here for $client2 only user_id in parameters will be changed. Other configuration, like mac_id, mac_secret will
be left intact.
All versions of lib-rest-client-common with dependencies
psr/http-message Version ^1.0|^2.0
guzzlehttp/guzzle Version ^6.0 | ^7.0
fig/http-message-util Version ^1.0
guzzlehttp/psr7 Version ^1.4|^2.0
ext-json Version *