forked from mirrors/easyappointments
Corrections in the API endpoints (#950)
This commit is contained in:
parent
de9e0542ea
commit
36def8c52c
12 changed files with 151 additions and 132 deletions
|
@ -84,7 +84,7 @@ class Appointments extends API_V1_Controller {
|
|||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
exit($this->handle_exception($exception));
|
||||
$this->handle_exception($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,6 +120,7 @@ class Appointments extends API_V1_Controller {
|
|||
|
||||
$id = $this->appointments_model->add($appointment);
|
||||
|
||||
$appointment = $this->appointments_model->get_row($id);
|
||||
$service = $this->services_model->get_row($appointment['id_services']);
|
||||
$provider = $this->providers_model->get_row($appointment['id_users_provider']);
|
||||
$customer = $this->customers_model->get_row($appointment['id_users_customer']);
|
||||
|
@ -142,7 +143,7 @@ class Appointments extends API_V1_Controller {
|
|||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
exit($this->handle_exception($exception));
|
||||
$this->handle_exception($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,7 +193,7 @@ class Appointments extends API_V1_Controller {
|
|||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
exit($this->handle_exception($exception));
|
||||
$this->handle_exception($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,7 +232,7 @@ class Appointments extends API_V1_Controller {
|
|||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
exit($this->handle_exception($exception));
|
||||
$this->handle_exception($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ class Settings extends API_V1_Controller {
|
|||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
exit($this->handle_exception($exception));
|
||||
$this->handle_exception($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class Settings extends API_V1_Controller {
|
|||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
exit($this->handle_exception($exception));
|
||||
$this->handle_exception($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ class Settings extends API_V1_Controller {
|
|||
{
|
||||
try
|
||||
{
|
||||
$result = $this->settings_model->remove_setting($name);
|
||||
$this->settings_model->remove_setting($name);
|
||||
|
||||
$response = new Response([
|
||||
'code' => 200,
|
||||
|
@ -140,7 +140,7 @@ class Settings extends API_V1_Controller {
|
|||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
exit($this->handle_exception($exception));
|
||||
$this->handle_exception($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class Unavailabilities extends API_V1_Controller {
|
|||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
exit($this->handle_exception($exception));
|
||||
$this->handle_exception($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ class Unavailabilities extends API_V1_Controller {
|
|||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
exit($this->handle_exception($exception));
|
||||
$this->handle_exception($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ class Unavailabilities extends API_V1_Controller {
|
|||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
exit($this->handle_exception($exception));
|
||||
$this->handle_exception($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ class Unavailabilities extends API_V1_Controller {
|
|||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
exit($this->handle_exception($exception));
|
||||
$this->handle_exception($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class Admins implements ParsersInterface {
|
|||
public function encode(array &$response)
|
||||
{
|
||||
$encoded_response = [
|
||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||
'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL,
|
||||
'firstName' => $response['first_name'],
|
||||
'lastName' => $response['last_name'],
|
||||
'email' => $response['email'],
|
||||
|
@ -61,90 +61,90 @@ class Admins implements ParsersInterface {
|
|||
{
|
||||
$decoded_request = $base ?: [];
|
||||
|
||||
if ( ! empty($request['id']))
|
||||
if (array_key_exists('id', $request))
|
||||
{
|
||||
$decoded_request['id'] = $request['id'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['firstName']))
|
||||
if (array_key_exists('firstName', $request))
|
||||
{
|
||||
$decoded_request['first_name'] = $request['firstName'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['lastName']))
|
||||
if (array_key_exists('lastName', $request))
|
||||
{
|
||||
$decoded_request['last_name'] = $request['lastName'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['email']))
|
||||
if (array_key_exists('email', $request))
|
||||
{
|
||||
$decoded_request['email'] = $request['email'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['mobile']))
|
||||
if (array_key_exists('mobile', $request))
|
||||
{
|
||||
$decoded_request['mobile_number'] = $request['mobile'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['phone']))
|
||||
if (array_key_exists('phone', $request))
|
||||
{
|
||||
$decoded_request['phone_number'] = $request['phone'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['address']))
|
||||
if (array_key_exists('address', $request))
|
||||
{
|
||||
$decoded_request['address'] = $request['address'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['city']))
|
||||
if (array_key_exists('city', $request))
|
||||
{
|
||||
$decoded_request['city'] = $request['city'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['state']))
|
||||
if (array_key_exists('state', $request))
|
||||
{
|
||||
$decoded_request['state'] = $request['state'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['zip']))
|
||||
if (array_key_exists('zip', $request))
|
||||
{
|
||||
$decoded_request['zip_code'] = $request['zip'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['notes']))
|
||||
if (array_key_exists('notes', $request))
|
||||
{
|
||||
$decoded_request['notes'] = $request['notes'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['timezone']))
|
||||
if (array_key_exists('timezone', $request))
|
||||
{
|
||||
$decoded_request['timezone'] = $request['timezone'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']))
|
||||
if (array_key_exists('settings', $request))
|
||||
{
|
||||
if (empty($decoded_request['settings']))
|
||||
{
|
||||
$decoded_request['settings'] = [];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['username']))
|
||||
if (array_key_exists('username', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['username'] = $request['settings']['username'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['password']))
|
||||
if (array_key_exists('password', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['password'] = $request['settings']['password'];
|
||||
}
|
||||
|
||||
if ($request['settings']['notifications'] !== NULL)
|
||||
if (array_key_exists('notifications', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['notifications'] = filter_var($request['settings']['notifications'],
|
||||
FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['calendarView']))
|
||||
if (array_key_exists('calendarView', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['calendar_view'] = $request['settings']['calendarView'];
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class Appointments implements ParsersInterface {
|
|||
public function encode(array &$response)
|
||||
{
|
||||
$encoded_response = [
|
||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||
'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL,
|
||||
'book' => $response['book_datetime'],
|
||||
'start' => $response['start_datetime'],
|
||||
'end' => $response['end_datetime'],
|
||||
|
@ -76,57 +76,57 @@ class Appointments implements ParsersInterface {
|
|||
{
|
||||
$decoded_request = $base ?: [];
|
||||
|
||||
if ( ! empty($request['id']))
|
||||
if (array_key_exists('id', $request))
|
||||
{
|
||||
$decoded_request['id'] = $request['id'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['book']))
|
||||
if (array_key_exists('book', $request))
|
||||
{
|
||||
$decoded_request['book_datetime'] = $request['book'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['start']))
|
||||
if (array_key_exists('start', $request))
|
||||
{
|
||||
$decoded_request['start_datetime'] = $request['start'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['end']))
|
||||
if (array_key_exists('end', $request))
|
||||
{
|
||||
$decoded_request['end_datetime'] = $request['end'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['hash']))
|
||||
if (array_key_exists('hash', $request))
|
||||
{
|
||||
$decoded_request['hash'] = $request['hash'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['location']))
|
||||
if (array_key_exists('location', $request))
|
||||
{
|
||||
$decoded_request['location'] = $request['location'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['notes']))
|
||||
if (array_key_exists('notes', $request))
|
||||
{
|
||||
$decoded_request['notes'] = $request['notes'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['customerId']))
|
||||
if (array_key_exists('customerId', $request))
|
||||
{
|
||||
$decoded_request['id_users_customer'] = $request['customerId'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['providerId']))
|
||||
if (array_key_exists('providerId', $request))
|
||||
{
|
||||
$decoded_request['id_users_provider'] = $request['providerId'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['serviceId']))
|
||||
if (array_key_exists('serviceId', $request))
|
||||
{
|
||||
$decoded_request['id_services'] = $request['serviceId'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['googleCalendarId']))
|
||||
if (array_key_exists('googleCalendarId', $request))
|
||||
{
|
||||
$decoded_request['id_google_calendar'] = $request['googleCalendarId'];
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@ class Categories implements ParsersInterface {
|
|||
public function encode(array &$response)
|
||||
{
|
||||
$encoded_response = [
|
||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||
'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL,
|
||||
'name' => $response['name'],
|
||||
'description' => $response['description']
|
||||
'description' => array_key_exists('description', $response) ? $response['description'] : NULL
|
||||
];
|
||||
|
||||
$response = $encoded_response;
|
||||
|
@ -47,17 +47,17 @@ class Categories implements ParsersInterface {
|
|||
{
|
||||
$decoded_request = $base ?: [];
|
||||
|
||||
if ( ! empty($request['id']))
|
||||
if (array_key_exists('id', $request))
|
||||
{
|
||||
$decoded_request['id'] = $request['id'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['name']))
|
||||
if (array_key_exists('name', $request))
|
||||
{
|
||||
$decoded_request['name'] = $request['name'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['description']))
|
||||
if (array_key_exists('description', $request))
|
||||
{
|
||||
$decoded_request['description'] = $request['description'];
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class Customers implements ParsersInterface {
|
|||
public function encode(array &$response)
|
||||
{
|
||||
$encoded_response = [
|
||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||
'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL,
|
||||
'firstName' => $response['first_name'],
|
||||
'lastName' => $response['last_name'],
|
||||
'email' => $response['email'],
|
||||
|
@ -53,47 +53,47 @@ class Customers implements ParsersInterface {
|
|||
{
|
||||
$decoded_request = $base ?: [];
|
||||
|
||||
if ( ! empty($request['id']))
|
||||
if ( array_key_exists('id', $request))
|
||||
{
|
||||
$decoded_request['id'] = $request['id'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['firstName']))
|
||||
if ( array_key_exists('firstName', $request))
|
||||
{
|
||||
$decoded_request['first_name'] = $request['firstName'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['lastName']))
|
||||
if ( array_key_exists('lastName', $request))
|
||||
{
|
||||
$decoded_request['last_name'] = $request['lastName'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['email']))
|
||||
if ( array_key_exists('email', $request))
|
||||
{
|
||||
$decoded_request['email'] = $request['email'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['phone']))
|
||||
if ( array_key_exists('phone', $request))
|
||||
{
|
||||
$decoded_request['phone_number'] = $request['phone'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['address']))
|
||||
if ( array_key_exists('address', $request))
|
||||
{
|
||||
$decoded_request['address'] = $request['address'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['city']))
|
||||
if ( array_key_exists('city', $request))
|
||||
{
|
||||
$decoded_request['city'] = $request['city'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['zip']))
|
||||
if ( array_key_exists('zip', $request))
|
||||
{
|
||||
$decoded_request['zip_code'] = $request['zip'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['notes']))
|
||||
if ( array_key_exists('notes', $request))
|
||||
{
|
||||
$decoded_request['notes'] = $request['notes'];
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class Providers implements ParsersInterface {
|
|||
public function encode(array &$response)
|
||||
{
|
||||
$encoded_response = [
|
||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||
'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL,
|
||||
'firstName' => $response['first_name'],
|
||||
'lastName' => $response['last_name'],
|
||||
'email' => $response['email'],
|
||||
|
@ -54,13 +54,27 @@ class Providers implements ParsersInterface {
|
|||
'username' => $response['settings']['username'],
|
||||
'notifications' => filter_var($response['settings']['notifications'], FILTER_VALIDATE_BOOLEAN),
|
||||
'calendarView' => $response['settings']['calendar_view'],
|
||||
'googleSync' => filter_var($response['settings']['google_sync'], FILTER_VALIDATE_BOOLEAN),
|
||||
'googleCalendar' => $response['settings']['google_calendar'],
|
||||
'googleToken' => $response['settings']['google_token'],
|
||||
'syncFutureDays' => $response['settings']['sync_future_days'] !== NULL ? (int)$response['settings']['sync_future_days'] : NULL,
|
||||
'syncPastDays' => $response['settings']['sync_past_days'] !== NULL ? (int)$response['settings']['sync_past_days'] : NULL,
|
||||
'workingPlan' => json_decode($response['settings']['working_plan'], TRUE),
|
||||
'workingPlanExceptions' => json_decode($response['settings']['working_plan_exceptions'], TRUE),
|
||||
'googleSync' => array_key_exists('google_sync', $response['settings'])
|
||||
? filter_var($response['settings']['google_sync'], FILTER_VALIDATE_BOOLEAN)
|
||||
: NULL,
|
||||
'googleCalendar' => array_key_exists('google_calendar', $response['settings'])
|
||||
? $response['settings']['google_calendar']
|
||||
: NULL,
|
||||
'googleToken' => array_key_exists('google_token', $response['settings'])
|
||||
? $response['settings']['google_token']
|
||||
: NULL,
|
||||
'syncFutureDays' => array_key_exists('sync_future_days', $response['settings'])
|
||||
? (int)$response['settings']['sync_future_days']
|
||||
: NULL,
|
||||
'syncPastDays' => array_key_exists('sync_past_days', $response['settings'])
|
||||
? (int)$response['settings']['sync_past_days']
|
||||
: NULL,
|
||||
'workingPlan' => array_key_exists('working_plan', $response['settings'])
|
||||
? json_decode($response['settings']['working_plan'], TRUE)
|
||||
: NULL,
|
||||
'workingPlanExceptions' => array_key_exists('working_plan_exceptions', $response['settings'])
|
||||
? json_decode($response['settings']['working_plan_exceptions'], TRUE)
|
||||
: NULL,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -77,131 +91,131 @@ class Providers implements ParsersInterface {
|
|||
{
|
||||
$decoded_request = $base ?: [];
|
||||
|
||||
if ( ! empty($request['id']))
|
||||
if (array_key_exists('id', $request))
|
||||
{
|
||||
$decoded_request['id'] = $request['id'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['firstName']))
|
||||
if (array_key_exists('firstName', $request))
|
||||
{
|
||||
$decoded_request['first_name'] = $request['firstName'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['lastName']))
|
||||
if (array_key_exists('lastName', $request))
|
||||
{
|
||||
$decoded_request['last_name'] = $request['lastName'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['email']))
|
||||
if (array_key_exists('email', $request))
|
||||
{
|
||||
$decoded_request['email'] = $request['email'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['mobile']))
|
||||
if (array_key_exists('mobile', $request))
|
||||
{
|
||||
$decoded_request['mobile_number'] = $request['mobile'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['phone']))
|
||||
if (array_key_exists('phone', $request))
|
||||
{
|
||||
$decoded_request['phone_number'] = $request['phone'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['address']))
|
||||
if (array_key_exists('address', $request))
|
||||
{
|
||||
$decoded_request['address'] = $request['address'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['city']))
|
||||
if (array_key_exists('city', $request))
|
||||
{
|
||||
$decoded_request['city'] = $request['city'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['state']))
|
||||
if (array_key_exists('state', $request))
|
||||
{
|
||||
$decoded_request['state'] = $request['state'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['zip']))
|
||||
if (array_key_exists('zip', $request))
|
||||
{
|
||||
$decoded_request['zip_code'] = $request['zip'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['notes']))
|
||||
if (array_key_exists('notes', $request))
|
||||
{
|
||||
$decoded_request['notes'] = $request['notes'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['timezone']))
|
||||
if (array_key_exists('timezone', $request))
|
||||
{
|
||||
$decoded_request['timezone'] = $request['timezone'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['services']))
|
||||
if (array_key_exists('services', $request))
|
||||
{
|
||||
$decoded_request['services'] = $request['services'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']))
|
||||
if (array_key_exists('settings', $request))
|
||||
{
|
||||
if (empty($decoded_request['settings']))
|
||||
{
|
||||
$decoded_request['settings'] = [];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['username']))
|
||||
if (array_key_exists('username', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['username'] = $request['settings']['username'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['password']))
|
||||
if (array_key_exists('password', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['password'] = $request['settings']['password'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['calendarView']))
|
||||
if (array_key_exists('calendarView', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['calendar_view'] = $request['settings']['calendarView'];
|
||||
}
|
||||
|
||||
if ($request['settings']['notifications'] !== NULL)
|
||||
if (array_key_exists('notifications', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['notifications'] = filter_var($request['settings']['notifications'],
|
||||
FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
if ($request['settings']['googleSync'] !== NULL)
|
||||
if (array_key_exists('googleSync', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['google_sync'] = filter_var($request['settings']['googleSync'],
|
||||
FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['googleCalendar']))
|
||||
if (array_key_exists('googleCalendar', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['google_calendar'] = $request['settings']['googleCalendar'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['googleToken']))
|
||||
if (array_key_exists('googleToken', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['google_token'] = $request['settings']['googleToken'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['syncFutureDays']))
|
||||
if (array_key_exists('syncFutureDays', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['sync_future_days'] = $request['settings']['syncFutureDays'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['syncPastDays']))
|
||||
if (array_key_exists('syncPastDays', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['sync_past_days'] = $request['settings']['syncPastDays'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['workingPlan']))
|
||||
if (array_key_exists('workingPlan', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['working_plan'] = json_encode($request['settings']['workingPlan']);
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['workingPlanExceptions']))
|
||||
if (array_key_exists('workingPlanExceptions', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['working_plan_exceptions'] = json_encode($request['settings']['workingPlanExceptions']);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class Secretaries implements ParsersInterface {
|
|||
public function encode(array &$response)
|
||||
{
|
||||
$encoded_response = [
|
||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||
'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL,
|
||||
'firstName' => $response['first_name'],
|
||||
'lastName' => $response['last_name'],
|
||||
'email' => $response['email'],
|
||||
|
@ -62,95 +62,95 @@ class Secretaries implements ParsersInterface {
|
|||
{
|
||||
$decoded_request = $base ?: [];
|
||||
|
||||
if ( ! empty($request['id']))
|
||||
if (array_key_exists('id', $request))
|
||||
{
|
||||
$decoded_request['id'] = $request['id'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['firstName']))
|
||||
if (array_key_exists('firstName', $request))
|
||||
{
|
||||
$decoded_request['first_name'] = $request['firstName'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['lastName']))
|
||||
if (array_key_exists('lastName', $request))
|
||||
{
|
||||
$decoded_request['last_name'] = $request['lastName'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['email']))
|
||||
if (array_key_exists('email', $request))
|
||||
{
|
||||
$decoded_request['email'] = $request['email'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['mobile']))
|
||||
if (array_key_exists('mobile', $request))
|
||||
{
|
||||
$decoded_request['mobile_number'] = $request['mobile'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['phone']))
|
||||
if (array_key_exists('phone', $request))
|
||||
{
|
||||
$decoded_request['phone_number'] = $request['phone'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['address']))
|
||||
if (array_key_exists('address', $request))
|
||||
{
|
||||
$decoded_request['address'] = $request['address'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['city']))
|
||||
if (array_key_exists('city', $request))
|
||||
{
|
||||
$decoded_request['city'] = $request['city'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['state']))
|
||||
if (array_key_exists('state', $request))
|
||||
{
|
||||
$decoded_request['state'] = $request['state'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['zip']))
|
||||
if (array_key_exists('zip', $request))
|
||||
{
|
||||
$decoded_request['zip_code'] = $request['zip'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['notes']))
|
||||
if (array_key_exists('notes', $request))
|
||||
{
|
||||
$decoded_request['notes'] = $request['notes'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['timezone']))
|
||||
if (array_key_exists('timezone', $request))
|
||||
{
|
||||
$decoded_request['timezone'] = $request['timezone'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['providers']))
|
||||
if (array_key_exists('providers', $request))
|
||||
{
|
||||
$decoded_request['providers'] = $request['providers'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']))
|
||||
if (array_key_exists('settings', $request))
|
||||
{
|
||||
if (empty($decoded_request['settings']))
|
||||
{
|
||||
$decoded_request['settings'] = [];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['username']))
|
||||
if (array_key_exists('username', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['username'] = $request['settings']['username'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['password']))
|
||||
if (array_key_exists('password', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['password'] = $request['settings']['password'];
|
||||
}
|
||||
|
||||
if ($request['settings']['notifications'] !== NULL)
|
||||
if (array_key_exists('notifications', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['notifications'] = filter_var($request['settings']['notifications'],
|
||||
FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
|
||||
if ( ! empty($request['settings']['calendarView']))
|
||||
if (array_key_exists('calendarView', $request['settings']))
|
||||
{
|
||||
$decoded_request['settings']['calendar_view'] = $request['settings']['calendarView'];
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class Services implements ParsersInterface {
|
|||
public function encode(array &$response)
|
||||
{
|
||||
$encoded_response = [
|
||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||
'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL,
|
||||
'name' => $response['name'],
|
||||
'duration' => (int)$response['duration'],
|
||||
'price' => (float)$response['price'],
|
||||
|
@ -54,52 +54,52 @@ class Services implements ParsersInterface {
|
|||
{
|
||||
$decoded_request = $base ?: [];
|
||||
|
||||
if ( ! empty($request['id']))
|
||||
if (array_key_exists('id', $request))
|
||||
{
|
||||
$decoded_request['id'] = $request['id'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['name']))
|
||||
if (array_key_exists('name', $request))
|
||||
{
|
||||
$decoded_request['name'] = $request['name'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['duration']))
|
||||
if (array_key_exists('duration', $request))
|
||||
{
|
||||
$decoded_request['duration'] = $request['duration'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['price']))
|
||||
if (array_key_exists('price', $request))
|
||||
{
|
||||
$decoded_request['price'] = $request['price'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['currency']))
|
||||
if (array_key_exists('currency', $request))
|
||||
{
|
||||
$decoded_request['currency'] = $request['currency'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['description']))
|
||||
if (array_key_exists('description', $request))
|
||||
{
|
||||
$decoded_request['description'] = $request['description'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['location']))
|
||||
if (array_key_exists('location', $request))
|
||||
{
|
||||
$decoded_request['location'] = $request['location'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['availabilitiesType']))
|
||||
if (array_key_exists('availabilitiesType', $request))
|
||||
{
|
||||
$decoded_request['availabilities_type'] = $request['availabilitiesType'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['attendantsNumber']))
|
||||
if (array_key_exists('attendantsNumber', $request))
|
||||
{
|
||||
$decoded_request['attendants_number'] = $request['attendantsNumber'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['categoryId']))
|
||||
if (array_key_exists('categoryId', $request))
|
||||
{
|
||||
$decoded_request['id_service_categories'] = $request['categoryId'];
|
||||
}
|
||||
|
|
|
@ -46,12 +46,12 @@ class Settings implements ParsersInterface {
|
|||
{
|
||||
$decoded_request = $base ?: [];
|
||||
|
||||
if ( ! empty($request['name']))
|
||||
if (array_key_exists('name', $request))
|
||||
{
|
||||
$decoded_request['name'] = $request['name'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['value']))
|
||||
if (array_key_exists('value', $request))
|
||||
{
|
||||
$decoded_request['value'] = $request['value'];
|
||||
}
|
||||
|
|
|
@ -29,13 +29,17 @@ class Unavailabilities implements ParsersInterface {
|
|||
public function encode(array &$response)
|
||||
{
|
||||
$encoded_response = [
|
||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||
'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL,
|
||||
'book' => $response['book_datetime'],
|
||||
'start' => $response['start_datetime'],
|
||||
'end' => $response['end_datetime'],
|
||||
'notes' => $response['notes'],
|
||||
'providerId' => $response['id_users_provider'] !== NULL ? (int)$response['id_users_provider'] : NULL,
|
||||
'googleCalendarId' => $response['id_google_calendar'] !== NULL ? (int)$response['id_google_calendar'] : NULL
|
||||
'providerId' => array_key_exists('id_users_provider', $response)
|
||||
? (int)$response['id_users_provider']
|
||||
: NULL,
|
||||
'googleCalendarId' => array_key_exists('id_google_calendar', $response)
|
||||
? (int)$response['id_google_calendar']
|
||||
: NULL
|
||||
];
|
||||
|
||||
$response = $encoded_response;
|
||||
|
@ -51,37 +55,37 @@ class Unavailabilities implements ParsersInterface {
|
|||
{
|
||||
$decodedRequest = $base ?: [];
|
||||
|
||||
if ( ! empty($request['id']))
|
||||
if (array_key_exists('id', $request))
|
||||
{
|
||||
$decodedRequest['id'] = $request['id'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['book']))
|
||||
if (array_key_exists('book', $request))
|
||||
{
|
||||
$decodedRequest['book_datetime'] = $request['book'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['start']))
|
||||
if (array_key_exists('start', $request))
|
||||
{
|
||||
$decodedRequest['start_datetime'] = $request['start'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['end']))
|
||||
if (array_key_exists('end', $request))
|
||||
{
|
||||
$decodedRequest['end_datetime'] = $request['end'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['notes']))
|
||||
if (array_key_exists('notes', $request))
|
||||
{
|
||||
$decodedRequest['notes'] = $request['notes'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['providerId']))
|
||||
if (array_key_exists('providerId', $request))
|
||||
{
|
||||
$decodedRequest['id_users_provider'] = $request['providerId'];
|
||||
}
|
||||
|
||||
if ( ! empty($request['googleCalendarId']))
|
||||
if (array_key_exists('googleCalendarId', $request))
|
||||
{
|
||||
$decodedRequest['id_google_calendar'] = $request['googleCalendarId'];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue