added API/Error class to hold error keys as constants
- re-added Setting::getAll() to API/Setting::set() in response - updated settings/setup tests
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace MailPoet\API\Endpoints;
|
||||
use \MailPoet\API\Endpoint as APIEndpoint;
|
||||
use \MailPoet\API\Error as APIError;
|
||||
use \MailPoet\Models\Setting;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
@ -10,18 +11,20 @@ class Settings extends APIEndpoint {
|
||||
}
|
||||
|
||||
function get() {
|
||||
$settings = Setting::getAll();
|
||||
return $this->successResponse($settings);
|
||||
return $this->successResponse(Setting::getAll());
|
||||
}
|
||||
|
||||
function set($settings = array()) {
|
||||
if(empty($settings)) {
|
||||
return $this->badRequest();
|
||||
return $this->badRequest(array(
|
||||
APIError::BAD_REQUEST =>
|
||||
__("You have not specified any settings to be saved.")
|
||||
));
|
||||
} else {
|
||||
foreach($settings as $name => $value) {
|
||||
Setting::setValue($name, $value);
|
||||
}
|
||||
return $this->successResponse();
|
||||
return $this->successResponse(Setting::getAll());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class Setup extends APIEndpoint {
|
||||
return $this->successResponse();
|
||||
} catch(\Exception $e) {
|
||||
return $this->errorResponse(array(
|
||||
$e->getMessage()
|
||||
$e->getCode() => $e->getMessage()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user