mezon / custom-client
Small custom client routine
Installs: 8 276
Dependents: 5
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: >=7.2.0
Requires (Dev)
- phpunit/php-token-stream: 3.1.2
- phpunit/phpunit: ^8.5
- vimeo/psalm: ^4.2
README
Installation
Just print
composer require mezon/custom-client
Reasons to use
- it will help ypu to create REST API clients lightning fast! Just look at this example of creation Jira API Client
- is has 100% code coverage
- it has 10.0 points on Scrutinizer
Sending requests
You can send different types of requests.
$client = new \Mezon\CustomClient\CustomClient(); // sending get request $client->sendGetRequest('https://your-api/end/point/?param=1'); // sending post request $client->sendPostRequest('https://your-api/end/point/', ['param' => 1]); // sending put request $client->sendPutRequest('https://your-api/end/point/', ['param' => 1]); // sending delete request $client->sendDeleteRequest('https://your-api/end/point/', ['param' => 1]);
Idempotency keys
To be sure that your data modification request are executed only once - use idempotency keys.
They are passed in the headers and can be set like this:
$client->setIdempotencyKey('some hash, like md5 or GUID or something like that');
After that in all of your requests the header Idempotency-Key will be added.
Note that this key will not be dropped automatically. You shold drop it manually:
$client->setIdempotencyKey(''); // this call drops the key
Learn more
More information can be found here: