mezon/custom-client

Small custom client routine

1.0.15 2022-01-10 15:32 UTC

This package is auto-updated.

Last update: 2024-04-10 20:43:19 UTC


README

Build Status codecov Scrutinizer Code Quality

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:

Twitter

dev.to

Slack