Skip to content

Commit

Permalink
Remove redundant teapot/status-code dependency
Browse files Browse the repository at this point in the history
Fixes #391
  • Loading branch information
const-cloudinary committed Nov 19, 2023
1 parent 1c7d6c4 commit 03986cb
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 5 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"guzzlehttp/guzzle": "^6.5.8|^7.4.5",
"guzzlehttp/promises": "^1.5.3|^2.0",
"guzzlehttp/psr7": "^1.9.1|^2.5",
"teapot/status-code": "^1|^2",
"ext-json": "*",
"monolog/monolog": "^1|^2|^3",
"psr/log" : "^1|^2|^3"
Expand Down
4 changes: 1 addition & 3 deletions src/Api/BaseApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
use InvalidArgumentException;
use JsonSerializable;
use Psr\Http\Message\ResponseInterface;
use Teapot\StatusCode\Http as HttpStatusCode;
use Teapot\StatusCode\Vendor\Twitter as TwitterStatusCode;

/**
* Class BaseApiClient
Expand All @@ -60,7 +58,7 @@ class BaseApiClient
HttpStatusCode::FORBIDDEN => NotAllowed::class,
HttpStatusCode::NOT_FOUND => NotFound::class,
HttpStatusCode::CONFLICT => AlreadyExists::class,
TwitterStatusCode::ENHANCE_YOUR_CALM => RateLimited::class, // RFC6585::TOO_MANY_REQUESTS
HttpStatusCode::ENHANCE_YOUR_CALM => RateLimited::class, // RFC6585::TOO_MANY_REQUESTS
HttpStatusCode::INTERNAL_SERVER_ERROR => GeneralError::class,
];

Expand Down
104 changes: 104 additions & 0 deletions src/Api/Utils/HttpStatusCode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

namespace Cloudinary\Api;

/**
* Class HttpStatusCode
*
* HTTP request status codes.
*/
class HttpStatusCode
{
/**
* The 200 (OK) status code indicates that the request has succeeded.
*
* @link https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1
*
* @var int
*/
const OK = 200;


/**
* The 400 (Bad Request) status code indicates that the server cannot or
* will not process the request due to something that is perceived to be a
* client error (e.g., malformed request syntax, invalid request message
* framing, or deceptive request routing).
*
* @link https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1
*
* @var int
*/
const BAD_REQUEST = 400;

/**
* The 401 (Unauthorized) status code indicates that the request has not
* been applied because it lacks valid authentication credentials for the
* target resource. The server generating a 401 response must send a
* WWW-Authenticate header field (Section 4.1) containing at least one
* challenge applicable to the target resource.
*
* @link https://datatracker.ietf.org/doc/html/rfc7235#section-3.1
*
* @var int
*/
const UNAUTHORIZED = 401;

/**
* The 403 (Forbidden) status code indicates that the server understood the
* request but refuses to authorize it. A server that wishes to make public
* why the request has been forbidden can describe that reason in the
* response payload (if any).
*
* @link https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.3
*
* @var int
*/
const FORBIDDEN = 403;

/**
* The 404 (Not Found) status code indicates that the origin server did not
* find a current representation for the target resource or is not willing
* to disclose that one exists.
*
* @link https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.4
*
* @var int
*/
const NOT_FOUND = 404;

/**
* The 409 (Conflict) status code indicates that the request could not be
* completed due to a conflict with the current state of the target
* resource. This code is used in situations where the user might be able to
* resolve the conflict and resubmit the request. The server should generate
* a payload that includes enough information for a user to recognize the
* source of the conflict.¶
*
* @link https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8
*
* @var int
*/
const CONFLICT = 409;

/**
* Returned when you are being rate limited.
*
* @link https://dev.twitter.com/docs/rate-limiting/1
*
* @var int
*/
const ENHANCE_YOUR_CALM = 420;

/**
* The 500 (Internal Server Error) status code indicates that the server
* encountered an unexpected condition that prevented it from fulfilling the
* request.
*
* @link https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1
*
* @var int
*/
const INTERNAL_SERVER_ERROR = 500;

}
2 changes: 1 addition & 1 deletion tests/Integration/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Cloudinary\Api\Admin\AdminApi;
use Cloudinary\Api\ApiResponse;
use Cloudinary\Api\Exception\ApiError;
use Cloudinary\Api\HttpStatusCode;
use Cloudinary\Api\Upload\UploadApi;
use Cloudinary\ArrayUtils;
use Cloudinary\Asset\AssetType;
Expand All @@ -31,7 +32,6 @@
use PHPUnit\Framework\Constraint\IsType;
use ReflectionClass;
use RuntimeException;
use Teapot\StatusCode\Http as HttpStatusCode;

/**
* Class IntegrationTestCase
Expand Down

0 comments on commit 03986cb

Please sign in to comment.