Entry Point
The way you can use any layer of these contracts is standardized by the EasyClientContract
interface.
The main class for each layer must implement the following interface.
This contract is the entry point for all implementations. Take a look at the following example.
$client = new MyClient();
$response = $client->call('GET', 'https://api.ratesapi.io/api/2020-07-24/?base=USD');
We've created an instance of MyClient
and have executed the call
method of the interface EasyClientContract
.
You can do any request with a class that implements this contract.
When you perform a request, a class that implements the HttpClientRequest
prepares all data to the client adapter to make the request.
In the same way, when you get a response, you'll get an instance of a class that implements the HttpClientResponse
interface.
However, you don't have to create a HttpClientRequest
to perform a request. It should be as simple as passing method
and uri
to the call
method
or use prepared requests to build a more complex request.