diff --git a/src/LeagueAPI/Definitions/IRateLimitControl.php b/src/LeagueAPI/Definitions/IRateLimitControl.php index e67a9bfd..35eb6edd 100644 --- a/src/LeagueAPI/Definitions/IRateLimitControl.php +++ b/src/LeagueAPI/Definitions/IRateLimitControl.php @@ -34,6 +34,17 @@ interface IRateLimitControl */ public function __construct( IRegion $region ); + /** + * Returns currently stored status of limits for given API key, region and endpoint. + * + * @param string $api_key + * @param string $region + * @param string $endpoint + * + * @return array + */ + public function getCurrentStatus(string $api_key, string $region, string $endpoint): array; + /** * Determines whether or not API call can be made. * diff --git a/src/LeagueAPI/Definitions/RateLimitControl.php b/src/LeagueAPI/Definitions/RateLimitControl.php index 14460bab..ce2e96d2 100644 --- a/src/LeagueAPI/Definitions/RateLimitControl.php +++ b/src/LeagueAPI/Definitions/RateLimitControl.php @@ -50,6 +50,23 @@ public function clear(): bool return $this->storage->clear(); } + /** + * Returns currently stored status of limits for given API key, region and endpoint. + * + * @param string $api_key + * @param string $region + * @param string $endpoint + * + * @return array + */ + public function getCurrentStatus(string $api_key, string $region, string $endpoint): array + { + return [ + "app" => $this->storage->getAppLimits($api_key, $region), + "method" => $this->storage->getMethodLimits($api_key, $region, $endpoint), + ]; + } + /** * Determines whether or not API call can be made * diff --git a/src/LeagueAPI/LeagueAPI.php b/src/LeagueAPI/LeagueAPI.php index f66309d8..36b90379 100644 --- a/src/LeagueAPI/LeagueAPI.php +++ b/src/LeagueAPI/LeagueAPI.php @@ -1023,6 +1023,16 @@ public function getResultHeaders() return $this->result_headers; } + /** + * Returns current API request limits. + * + * @return array + */ + public function getCurrentLimits() + { + return $this->rlc->getCurrentStatus($this->getSetting($this->used_key), $this->getSetting(self::SET_REGION), $this->getResourceEndpoint()); + } + /** * Adds next API call to given async request group. Sending needs to be * initiated by calling commitAsync function. diff --git a/src/LeagueAPICLI/Commands/InvokeMethodLeagueAPI.php b/src/LeagueAPICLI/Commands/InvokeMethodLeagueAPI.php index 2ed33f36..bab799e3 100644 --- a/src/LeagueAPICLI/Commands/InvokeMethodLeagueAPI.php +++ b/src/LeagueAPICLI/Commands/InvokeMethodLeagueAPI.php @@ -121,6 +121,7 @@ protected function extendResultFormat(&$data) { $data = [ "headers" => $this->api->getResultHeaders(), + "limits" => $this->api->getCurrentLimits(), "result" => $data, ]; }