- Updates the check for invalid API endpoint
This commit is contained in:
@ -29,19 +29,19 @@ class API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
$endpoint = self::ENDPOINT_NAMESPACE . ucfirst($this->endpoint);
|
||||||
if(!$this->api_request) return;
|
if(!$this->api_request) return;
|
||||||
if(!$this->endpoint) {
|
if(!$this->endpoint || !class_exists($endpoint)) {
|
||||||
$this->terminateRequest(self::API_RESPONSE_CODE_ERROR, __('Invalid API endpoint.'));
|
$this->terminateRequest(self::API_RESPONSE_CODE_ERROR, __('Invalid API endpoint.'));
|
||||||
}
|
}
|
||||||
$this->callEndpoint(
|
$this->callEndpoint(
|
||||||
$this->endpoint,
|
$endpoint,
|
||||||
$this->action,
|
$this->action,
|
||||||
$this->data
|
$this->data
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function callEndpoint($endpoint, $action, $data) {
|
function callEndpoint($endpoint, $action, $data) {
|
||||||
$endpoint = self::ENDPOINT_NAMESPACE . ucfirst($endpoint);
|
|
||||||
if(!method_exists($endpoint, $action)) {
|
if(!method_exists($endpoint, $action)) {
|
||||||
$this->terminateRequest(self::API_RESPONSE_CODE_ERROR, __('Invalid API action.'));
|
$this->terminateRequest(self::API_RESPONSE_CODE_ERROR, __('Invalid API action.'));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user