Return the error response when a rate limit has been reached on a given endpoint.

@return Array Includes the 'tts' in case this is run from a CLI and you want to
sleep the process till the rate limit is gone.

@author Julio Foulquié <jfoulquie@gmail.com>
543333
private function rateLimit()
    {
        return [
            'code'      => $this->response['code'],
            'errors'    => $this->response['response'],
            'tts'       => isset($this->response['headers']['x-rate-limit-reset']) ? // Time To Sleep
                            ($this->response['headers']['x-rate-limit-reset'] - time()) :
                            false,
        ];
    }
416672
protected function getLimit()
    {
        $limit = $this->activeState()->getLimit();
        if (!in_array($limit, $this->limits)) {
            //We are using lowest limit by default
            return $this->limits[0];
        }

        return $limit;
    }
75554
public function getMessage()
    {
        if ($this->displayErrorDetails() && $this->hasThrown()) {
            return $this->getThrown()->getMessage();
        } else {
            return $this->translator()->translate(
                'The server encountered a problem. Sorry for the temporary inconvenience.',
                [],
                'charcoal'
            );
        }
    }
645787
public function getLastError()
    {
        if($this->redis instanceof \Swoole\Coroutine\Redis)
        {
            return $this->redis->errMsg;
        }
        else
        {
            return $this->redis->getLastError();
        }
    }
321314
public function getLastError(): string
    {
        if ($this->isConnected() && $this->socket) {
            $err = @socket_last_error($this->socket);
            if ($err) {
                $err = socket_strerror($err);
            }
            if (!$err) {
                $err = 'Unknown error';
            }
            return $err;
        } else {
            return 'Not connected';
        }
    }
371896
public function getRateLimit()
    {
        $result = null;
        $config = $this->app->make('community_translation/config');
        $maxRequests = (int) $config->get('options.api.rateLimit.maxRequests');
        if ($maxRequests > 0) {
            $timeWindow = (int) $config->get('options.api.rateLimit.timeWindow');
            if ($timeWindow > 0) {
                $result = [$maxRequests, $timeWindow];
            }
        }

        return $result;
    }
903266
protected function GetErrorCodesFromResponse()
    {
        $sReturnMessage = false;
        $oGlobal = TGlobal::instance();
        $this->sRefNo = $oGlobal->GetUserData('refno');
        $sReturnState = $oGlobal->GetUserData('status');
        if ($this->bIsCorrectPaymentType()) {
            $oBasket = TShopBasket::GetInstance();
            if ($this->sRefNo == crc32($oBasket->sBasketIdentifier.'__'.$this->GetRefNoPaymentId().'__'.$this->sRefNoCount)) {
                if ('error' == $sReturnState) {
                    $sResponseHash = $this->GetSecurityHash($this->GetTestLiveModeParameter('sign'), $oGlobal->GetUserData('merchantId'), $oGlobal->GetUserData('amount'), $oGlobal->GetUserData('currency'), $oGlobal->GetUserData('refno'));
                    if ($sResponseHash == $oGlobal->GetUserData('sign')) {
                        $sReturnMessage = $oGlobal->GetUserData('errorDetail');
                        $sReturnMessage = $this->TransformDataTransMessages($oGlobal->GetUserData('errorCode'));
                    } else {
                        $sReturnMessage = 'ERROR_PAYMENT_DATA_TRANS_SECURITY_CHECK_ERROR';
                    }
                } elseif ('cancel' == $sReturnState) {
                    $sResponseHash = $this->GetSecurityHash($this->GetTestLiveModeParameter('sign'), $oGlobal->GetUserData('merchantId'), $oGlobal->GetUserData('amount'), $oGlobal->GetUserData('currency'), $oGlobal->GetUserData('refno'));
                    if ($sResponseHash == $oGlobal->GetUserData('sign')) {
                        $sReturnMessage = 'ERROR_PAYMENT_DATA_TRANS_PAYMENT_CANCEL';
                    } else {
                        $sReturnMessage = 'ERROR_PAYMENT_DATA_TRANS_SECURITY_CHECK_ERROR';
                    }
                } else {
                    $sTransactionId = $oGlobal->GetUserData('uppTransactionId');
                    $sAuthorisedAmount = $oGlobal->GetUserData('amount');
                    $sResponseHash = $this->GetSecurityHash($this->GetTestLiveModeParameter('sign2'), $oGlobal->GetUserData('merchantId'), $oGlobal->GetUserData('amount'), $oGlobal->GetUserData('currency'), $oGlobal->GetUserData('uppTransactionId'));
                    if ($sResponseHash == $oGlobal->GetUserData('sign2')) {
                        if (strlen($sTransactionId) <= 0 || strlen($sAuthorisedAmount) <= 0) {
                            $sReturnMessage = 'ERROR_PAYMENT_DATA_TRANS_MISSING_PARAMETER_IN_RESPONSE';
                            TTools::WriteLogEntrySimple('Payment DataTrans: Beim Autorisierungsresponse wurden benötigte Daten nicht zurückgegeben', 1, __FILE__, __LINE__);
                        } else {
                            $this->sTransactionId = $sTransactionId;
                            $this->sAuthorisedAmount = $sAuthorisedAmount;
                        }
                    } else {
                        $sReturnMessage = 'ERROR_PAYMENT_DATA_TRANS_SECURITY_CHECK_ERROR';
                    }
                }
            } else {
                $sReturnMessage = 'ERROR_PAYMENT_DATA_TRANS_REFERENCE_NUMER_NOT_VALID';
            }
        } else {
            $sReturnMessage = 'ERROR_PAYMENT_DATA_TRANS_PAYMEN_SELECTION_NOT_VALID';
        }

        return $sReturnMessage;
    }
765354
public function getErrorDataFromResponse()
    {
        $aErrorData = array();
        $aResponse  = (array) $this->getResponse();

        foreach ( $aResponse as $sKey => $sValue ) {
            if ( mb_strpos( $sKey, 'error_', null, 'UTF-8' ) === 0 ) {
                $aErrorData[$sKey] = $sValue;
            }
        }

        return $aErrorData;
    }
984532
private function getError() {
        if (!curl_errno($this->curl)) return array();
        return array('error_no' => curl_errno($this->curl), 'error' => curl_error($this->curl));
    }
1035670
private function tokenExpired()
    {
        $tokenExpirationTime = $this->requestTimestamp
            + $this->data[static::RESPONSE_KEY_ACCESS_TOKEN_TTL]
            - static::TTL_CORRECTION_TIME_SEC;

        return $this->tokenExists() && time() > $tokenExpirationTime;
    }
730716
public function limit()
    {
        // get limit from config file
        $limit = $this->getMaximumLimit();
        // get the limit from the request if available else get the the default predefined limit from the config file
        if (Input::get('limit') && is_numeric(Input::get('limit'))) {
            $limit = Input::get('limit');
        }

        // validate the limit does not exceed the allowed value
        return $this->validateRequestedLimitValue($limit);
    }
269245
public function limit() 
    {
        $url = self::HOST . self::LIMIT;

        $params = $this->get_default_params();
        $result = $this->request($url, $params);
        $result = explode("\n", $result);

        return array(
            'code' => $result[0],
            'total' => $result[1],
            'current' => $result[2]
        );
    }
1261060
protected function getError() {
		if ($this->_error === false) {
			if (is_resource($this->_dbh)) {
				$this->_error = @oci_error($this->_dbh);
			}
			else {
				$this->_error = @oci_error();
			}
		}

		return $this->_error;
	}
1068698
protected function GetErrorCodesFromResponse()
    {
        $SReturnMessage = false;
        if ($this->bIsCorrectIPaymentType()) {
            $oGlobal = TGlobal::instance();
            $SReturnState = $oGlobal->GetUserData('ret_status');
            if ('ERROR' == $SReturnState) {
                $SReturnMessage = $oGlobal->GetUserData('ret_errormsg');
                $SReturnMessage = utf8_encode($SReturnMessage);
            }
        }

        return $SReturnMessage;
    }
233732
public function error()
    {
        $this->errors = [
            'code'    => curl_errno($this->curl),
            'message' => curl_error($this->curl)
        ];

        return $this->error();
    }
821515
protected function getTimeLimit()
    {
        $timeLimit = self::DEFAULT_TIME_LIMIT;
        if($this->hasOption(self::TIME_LIMIT_OPT)){
            $timeLimit = (int)$this->getOption(self::TIME_LIMIT_OPT);
        }
        return $timeLimit;
    }
1321406
function getRateLimiter()
    {
        if ($this->rateLimiter) {
            return $this->rateLimiter;
        }

        $app = $this->auth->getApp();
        $class = $app['config']->get('auth.loginRateLimiter', NullRateLimiter::class);

        $this->rateLimiter = new $class();
        if (method_exists($this->rateLimiter, 'setApp')) {
            $this->rateLimiter->setApp($app);
        }

        return $this->rateLimiter;
    }