| @@ -10,9 +10,8 @@ | ||
| 10 | 10 | |
| 11 | 11 | namespace Parsely\RemoteAPI; |
| 12 | 12 | |
| 13 | 13 | use WP_Error; |
| 14 | -use WP_REST_Request; | |
| 15 | 14 | |
| 16 | 15 | /** |
| 17 | 16 | * Caching Decorator for remote API endpoints. |
| 18 | 17 | */ |
| @@ -22,9 +21,9 @@ | ||
| 22 | 21 | |
| 23 | 22 | /** |
| 24 | 23 | * The Remote API instance which we will cache. |
| 25 | 24 | * |
| 26 | - * @var Base_Endpoint_Remote | |
| 25 | + * @var Remote_API_Base | |
| 27 | 26 | */ |
| 28 | 27 | private $remote_api; |
| 29 | 28 | |
| 30 | 29 | /** |
| @@ -36,12 +35,12 @@ | ||
| 36 | 35 | |
| 37 | 36 | /** |
| 38 | 37 | * Constructor. |
| 39 | 38 | * |
| 40 | - * @param Base_Endpoint_Remote $remote_api The remote api object to cache. | |
| 41 | - * @param Cache $cache An object cache instance. | |
| 39 | + * @param Remote_API_Base $remote_api The remote api object to cache. | |
| 40 | + * @param Cache $cache An object cache instance. | |
| 42 | 41 | */ |
| 43 | - public function __construct( Base_Endpoint_Remote $remote_api, Cache $cache ) { | |
| 42 | + public function __construct( Remote_API_Base $remote_api, Cache $cache ) { | |
| 44 | 43 | $this->remote_api = $remote_api; |
| 45 | 44 | $this->cache = $cache; |
| 46 | 45 | } |
| 47 | 46 | |
| @@ -48,14 +47,14 @@ | ||
| 48 | 47 | /** |
| 49 | 48 | * Implements caching for the Remote API interface. |
| 50 | 49 | * |
| 51 | 50 | * @param array<string, mixed> $query The query arguments to send to the remote API. |
| 52 | - * @param bool $associative Always `false`, just present to make definition compatible | |
| 53 | - * with interface. | |
| 54 | - * @return array<string, mixed>|object|WP_Error The response from the remote API, or false if the | |
| 55 | - * response is empty. | |
| 51 | + * @param bool $associative Always `false`, just present to make definition compatible with interface. | |
| 52 | + * | |
| 53 | + * @return array<string, mixed>|WP_Error|false The response from the remote API, or false if the | |
| 54 | + * response is empty. | |
| 56 | 55 | */ |
| 57 | - public function get_items( array $query, bool $associative = false ) { | |
| 56 | + public function get_items( $query, $associative = false ) { | |
| 58 | 57 | $cache_key = 'parsely_api_' . |
| 59 | 58 | wp_hash( $this->remote_api->get_endpoint() ) . '_' . |
| 60 | 59 | wp_hash( (string) wp_json_encode( $query ) ); |
| 61 | 60 | |
| @@ -74,18 +73,14 @@ | ||
| 74 | 73 | return $items; |
| 75 | 74 | } |
| 76 | 75 | |
| 77 | 76 | /** |
| 78 | - * Returns whether the endpoint is available for access by the current | |
| 79 | - * user. | |
| 77 | + * Checks if the current user is allowed to make the API call. | |
| 80 | 78 | * |
| 81 | 79 | * @since 3.7.0 |
| 82 | - * @since 3.14.0 Renamed from `is_user_allowed_to_make_api_call()`. | |
| 83 | - * @since 3.16.0 Added the `$request` parameter. | |
| 84 | 80 | * |
| 85 | - * @param WP_REST_Request|null $request The request object. | |
| 86 | 81 | * @return bool |
| 87 | 82 | */ |
| 88 | - public function is_available_to_current_user( $request = null ): bool { | |
| 89 | - return $this->remote_api->is_available_to_current_user( $request ); | |
| 83 | + public function is_user_allowed_to_make_api_call(): bool { | |
| 84 | + return $this->remote_api->is_user_allowed_to_make_api_call(); | |
| 90 | 85 | } |
| 91 | 86 | } |