2017-09-15 14:36:37 +03:00
|
|
|
<?php
|
2016-07-10 17:56:43 +03:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
|
|
|
*
|
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2020-03-11 12:10:59 +03:00
|
|
|
* @copyright Copyright (c) 2013 - 2020, 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
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
2017-09-15 14:36:37 +03:00
|
|
|
namespace EA\Engine\Api\V1\Parsers;
|
2016-07-10 17:56:43 +03:00
|
|
|
|
|
|
|
/**
|
2017-09-15 14:36:37 +03:00
|
|
|
* Settings Parser
|
2016-07-10 17:56:43 +03:00
|
|
|
*
|
2017-09-15 14:36:37 +03:00
|
|
|
* This class will handle the encoding and decoding from the API requests.
|
2020-05-12 21:49:15 +03:00
|
|
|
*
|
|
|
|
* @deprecated
|
2016-07-10 17:56:43 +03:00
|
|
|
*/
|
|
|
|
class Settings implements ParsersInterface {
|
|
|
|
/**
|
2017-09-15 14:36:37 +03:00
|
|
|
* Encode Response Array
|
|
|
|
*
|
2016-07-10 17:56:43 +03:00
|
|
|
* @param array &$response The response to be encoded.
|
|
|
|
*/
|
2017-09-15 14:36:37 +03:00
|
|
|
public function encode(array &$response)
|
|
|
|
{
|
2020-11-16 12:54:59 +03:00
|
|
|
$encoded_response = [
|
2016-07-10 17:56:43 +03:00
|
|
|
'name' => $response['name'],
|
|
|
|
'value' => $response['value']
|
|
|
|
];
|
|
|
|
|
2020-11-16 12:54:59 +03:00
|
|
|
$response = $encoded_response;
|
2016-07-10 17:56:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-15 14:36:37 +03:00
|
|
|
* 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.
|
2016-07-10 17:56:43 +03:00
|
|
|
*/
|
2017-09-15 14:36:37 +03:00
|
|
|
public function decode(array &$request, array $base = NULL)
|
|
|
|
{
|
2020-11-16 12:54:59 +03:00
|
|
|
$decoded_request = $base ?: [];
|
2016-07-10 17:56:43 +03:00
|
|
|
|
2020-12-11 22:16:49 +03:00
|
|
|
if (array_key_exists('name', $request))
|
2017-09-15 14:36:37 +03:00
|
|
|
{
|
2020-11-16 12:54:59 +03:00
|
|
|
$decoded_request['name'] = $request['name'];
|
2016-07-10 17:56:43 +03:00
|
|
|
}
|
|
|
|
|
2020-12-11 22:16:49 +03:00
|
|
|
if (array_key_exists('value', $request))
|
2017-09-15 14:36:37 +03:00
|
|
|
{
|
2020-11-16 12:54:59 +03:00
|
|
|
$decoded_request['value'] = $request['value'];
|
2016-07-10 17:56:43 +03:00
|
|
|
}
|
|
|
|
|
2020-11-16 12:54:59 +03:00
|
|
|
$request = $decoded_request;
|
2016-07-10 17:56:43 +03:00
|
|
|
}
|
|
|
|
}
|