kbsali / php-redmine-api

A simple PHP Redmine API client, Object Oriented
MIT License
420 stars 183 forks source link

Publish HttpFactory #428

Closed Art4 closed 3 weeks ago

Art4 commented 3 weeks ago

While working on #426 I noticed that there is no convenient alternative to call \Redmine\Http\HttpClient::request() because one has to implement the \Redmine\Http\Request interface beforehand.

Internally we are using the class \Redmine\Http\HttpFactory to create Request and Response instances. This factory class is marked as internal. I propose to make this class publicly available to make the use of \Redmine\Http\HttpClient::request() much more easier.

See also https://github.com/kbsali/php-redmine-api/issues/401#issuecomment-2173137302. The HttpFactory will reduce the needed code to:

$response = $client->request(
    \Redmine\Http\HttpFactory::makeJsonRequest(
        'POST',
        '/time_entries.json',
        \Redmine\Serializer\JsonSerializer::createFromArray(['time_entry' => $data])->getEncoded(),
    ),
);

391 proposes the deprecation of this methods:

But publishing HttpFactory will allow us to deprecate even more methods:

Deprecating this methods was also kept in mind while designing the \Redmine\Http\HttpClient::request() method, see #341.