Added API/Endpoint abstract class
- (re)Added Endpoints folder to both API and Router - fixed syntax in namespaces - xhr.responseJSON is returned to the fail() - fixed Router endpoints (view in browser, cron,...)
This commit is contained in:
25
lib/API/Endpoint.php
Normal file
25
lib/API/Endpoint.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace MailPoet\API;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
abstract class Endpoint {
|
||||
|
||||
function successResponse(
|
||||
$data = array(), $meta = array(), $status = Response::STATUS_OK
|
||||
) {
|
||||
|
||||
return new SuccessResponse($data, $meta, $status);
|
||||
}
|
||||
|
||||
function errorResponse(
|
||||
$errors = array(), $meta = array(), $status = Response::STATUS_NOT_FOUND
|
||||
) {
|
||||
|
||||
return new ErrorResponse($errors, $meta, $status);
|
||||
}
|
||||
|
||||
function badRequest($errors = array(), $meta = array()) {
|
||||
return new ErrorResponse($errors, $meta, Response::STATUS_BAD_REQUEST);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user