2016-07-10 17:56:43 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
|
|
|
*
|
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2017-01-31 09:35:34 +03:00
|
|
|
* @copyright Copyright (c) 2013 - 2017, Alex Tselegidis
|
2016-07-10 17:56:43 +03:00
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
* @link http://easyappointments.org
|
|
|
|
* @since v1.2.0
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
namespace EA\Engine\Api\V1\Parsers;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Settings Parser
|
|
|
|
*
|
|
|
|
* This class will handle the encoding and decoding from the API requests.
|
|
|
|
*/
|
|
|
|
class Settings implements ParsersInterface {
|
|
|
|
/**
|
|
|
|
* Encode Response Array
|
|
|
|
*
|
|
|
|
* @param array &$response The response to be encoded.
|
|
|
|
*/
|
|
|
|
public function encode(array &$response) {
|
|
|
|
$encodedResponse = [
|
|
|
|
'name' => $response['name'],
|
|
|
|
'value' => $response['value']
|
|
|
|
];
|
|
|
|
|
|
|
|
$response = $encodedResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Decode Request
|
|
|
|
*
|
|
|
|
* @param array &$request The request to be decoded.
|
|
|
|
* @param array $base Optional (null), if provided it will be used as a base array.
|
|
|
|
*/
|
|
|
|
public function decode(array &$request, array $base = null) {
|
|
|
|
$decodedRequest = $base ?: [];
|
|
|
|
|
|
|
|
if (!empty($request['name'])) {
|
|
|
|
$decodedRequest['name'] = $request['name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($request['value'])) {
|
|
|
|
$decodedRequest['value'] = $request['value'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$request = $decodedRequest;
|
|
|
|
}
|
|
|
|
}
|