Moves current API under JSON namespace

This commit is contained in:
Vlad
2017-05-09 20:17:29 -04:00
parent b727ba423e
commit 398d7d3d80
38 changed files with 86 additions and 86 deletions

View File

@ -0,0 +1,31 @@
<?php
namespace MailPoet\API\JSON\Endpoints\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\Models\Setting;
use MailPoet\Services\Bridge;
if(!defined('ABSPATH')) exit;
class Settings extends APIEndpoint {
function get() {
return $this->successResponse(Setting::getAll());
}
function set($settings = array()) {
if(empty($settings)) {
return $this->badRequest(array(
APIError::BAD_REQUEST =>
__('You have not specified any settings to be saved.', 'mailpoet')
));
} else {
foreach($settings as $name => $value) {
Setting::setValue($name, $value);
}
$bridge = new Bridge();
$bridge->onSettingsSave($settings);
return $this->successResponse(Setting::getAll());
}
}
}