2016-07-09 22:53:28 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
|
|
|
*
|
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
|
|
|
* @copyright Copyright (c) 2013 - 2016, Alex Tselegidis
|
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
* @link http://easyappointments.org
|
|
|
|
* @since v1.2.0
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
namespace EA\Engine\Api\V1\Parsers;
|
|
|
|
|
|
|
|
class Appointments implements ParsersInterface {
|
|
|
|
public function encode(array &$response) {
|
|
|
|
$encodedResponse = [
|
2016-07-10 11:37:30 +03:00
|
|
|
'id' => $response['id'] !== null ? (int)$response['id'] : null,
|
2016-07-09 22:53:28 +03:00
|
|
|
'book' => $response['book_datetime'],
|
|
|
|
'start' => $response['start_datetime'],
|
|
|
|
'end' => $response['end_datetime'],
|
|
|
|
'hash' => $response['hash'],
|
|
|
|
'notes' => $response['notes'],
|
2016-07-10 11:37:30 +03:00
|
|
|
'customerId' => $response['id_users_customer'] !== null ? (int)$response['id_users_customer'] : null,
|
|
|
|
'providerId' => $response['id_users_provider'] !== null ? (int)$response['id_users_provider'] : null,
|
|
|
|
'serviceId' => $response['id_services'] !== null ? (int)$response['id_services'] : null,
|
|
|
|
'googleCalendarId' => $response['id_google_calendar'] !== null ? (int)$response['id_google_calendar'] : null
|
2016-07-09 22:53:28 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
$response = $encodedResponse;
|
|
|
|
}
|
|
|
|
|
2016-07-09 23:01:03 +03:00
|
|
|
public function decode(array &$request, array $base = null) {
|
|
|
|
$decodedRequest = $base ?: [];
|
2016-07-09 22:53:28 +03:00
|
|
|
|
|
|
|
if (!empty($request['id'])) {
|
|
|
|
$decodedRequest['id'] = $request['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($request['book'])) {
|
|
|
|
$decodedRequest['book_datetime'] = $request['book'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($request['start'])) {
|
|
|
|
$decodedRequest['start_datetime'] = $request['start'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($request['end'])) {
|
|
|
|
$decodedRequest['end_datetime'] = $request['end'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($request['hash'])) {
|
|
|
|
$decodedRequest['hash'] = $request['hash'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($request['notes'])) {
|
|
|
|
$decodedRequest['notes'] = $request['notes'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($request['customerId'])) {
|
|
|
|
$decodedRequest['id_users_customer'] = $request['customerId'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($request['providerId'])) {
|
|
|
|
$decodedRequest['id_users_provider'] = $request['providerId'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($request['serviceId'])) {
|
|
|
|
$decodedRequest['id_services'] = $request['serviceId'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($request['googleCalendarId'])) {
|
|
|
|
$decodedRequest['id_google_calendar'] = $request['googleCalendarId'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$decodedRequest['is_unavailable'] = false;
|
|
|
|
|
|
|
|
$request = $decodedRequest;
|
|
|
|
}
|
|
|
|
}
|