- Updates the check for invalid API endpoint

This commit is contained in:
Vlad
2016-07-07 14:20:27 -04:00
parent 150364de3a
commit c78b2088eb

View File

@ -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.'));
} }