Skip to content

Commit

Permalink
Deprecate lastCallFailed. (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
icedream authored Sep 26, 2021
1 parent 1e98775 commit c5a2e37
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/kbsali/php-redmine-api/compare/v2.0.1...v2.x)

### Deprecated

- `Redmine\Api\AbstractApi::lastCallFailed()` is deprecated, use `Redmine\Client\Client::getLastResponseStatusCode()` instead

## [v2.0.1](https://github.com/kbsali/php-redmine-api/compare/v2.0.0...v2.0.1) - 2021-09-22

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ $client->stopImpersonateUser();

You can now use the `getApi()` method to create and get a specific Redmine API.

To check for failed requests you can afterwards check the status code via `$client->getLastResponseStatusCode()`.

```php
// ----------------------------
// Trackers
Expand Down
5 changes: 5 additions & 0 deletions src/Redmine/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ public function __construct(Client $client)
* Returns whether or not the last api call failed.
*
* @return bool
*
* @deprecated This method does not correctly handle 2xx codes that are not 200 or 201, use \Redmine\Client\Client::getLastResponseStatusCode() instead
* @see Client::getLastResponseStatusCode() for checking the status code directly
*/
public function lastCallFailed()
{
@trigger_error('The '.__METHOD__.' method is deprecated, use \Redmine\Client\Client::getLastResponseStatusCode() instead.', E_USER_DEPRECATED);

$code = $this->client->getLastResponseStatusCode();

return 200 !== $code && 201 !== $code;
Expand Down

0 comments on commit c5a2e37

Please sign in to comment.