forked from mirrors/easyappointments
Applied consistent code style to the engine class files.
This commit is contained in:
parent
084aed9e23
commit
46d604f5e6
40 changed files with 257 additions and 243 deletions
|
@ -431,7 +431,7 @@ class Backend_api extends EA_Controller {
|
||||||
|
|
||||||
if ((bool)$send_provider === TRUE)
|
if ((bool)$send_provider === TRUE)
|
||||||
{
|
{
|
||||||
$email->sendDeleteAppointment($appointment, $provider,
|
$email->send_delete_appointment($appointment, $provider,
|
||||||
$service, $customer, $settings, new Email($provider['email']),
|
$service, $customer, $settings, new Email($provider['email']),
|
||||||
new Text($this->input->post('delete_reason')));
|
new Text($this->input->post('delete_reason')));
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,7 @@ class Backend_api extends EA_Controller {
|
||||||
|
|
||||||
if ((bool)$send_customer === TRUE)
|
if ((bool)$send_customer === TRUE)
|
||||||
{
|
{
|
||||||
$email->sendDeleteAppointment($appointment, $provider,
|
$email->send_delete_appointment($appointment, $provider,
|
||||||
$service, $customer, $settings, new Email($customer['email']),
|
$service, $customer, $settings, new Email($customer['email']),
|
||||||
new Text($this->input->post('delete_reason')));
|
new Text($this->input->post('delete_reason')));
|
||||||
}
|
}
|
||||||
|
@ -455,7 +455,7 @@ class Backend_api extends EA_Controller {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$email->sendDeleteAppointment($appointment, $provider,
|
$email->send_delete_appointment($appointment, $provider,
|
||||||
$service, $customer, $settings, new Email($admin['email']),
|
$service, $customer, $settings, new Email($admin['email']),
|
||||||
new Text($this->input->post('cancel_reason')));
|
new Text($this->input->post('cancel_reason')));
|
||||||
}
|
}
|
||||||
|
@ -475,7 +475,7 @@ class Backend_api extends EA_Controller {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$email->sendDeleteAppointment($appointment, $provider,
|
$email->send_delete_appointment($appointment, $provider,
|
||||||
$service, $customer, $settings, new Email($secretary['email']),
|
$service, $customer, $settings, new Email($secretary['email']),
|
||||||
new Text($this->input->post('cancel_reason')));
|
new Text($this->input->post('cancel_reason')));
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,7 @@ class User extends EA_Controller {
|
||||||
'company_email' => $this->settings_model->get_setting('company_email')
|
'company_email' => $this->settings_model->get_setting('company_email')
|
||||||
];
|
];
|
||||||
|
|
||||||
$email->sendPassword(new NonEmptyText($new_password), new Email($this->input->post('email')),
|
$email->send_password(new NonEmptyText($new_password), new Email($this->input->post('email')),
|
||||||
$company_settings);
|
$company_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ class API_V1_Controller extends EA_Controller {
|
||||||
];
|
];
|
||||||
|
|
||||||
$header = $exception instanceof \EA\Engine\Api\V1\Exception
|
$header = $exception instanceof \EA\Engine\Api\V1\Exception
|
||||||
? $exception->getCode() . ' ' . $exception->getHeader()
|
? $exception->getCode() . ' ' . $exception->get_header()
|
||||||
: '500 Internal Server Error';
|
: '500 Internal Server Error';
|
||||||
|
|
||||||
header('HTTP/1.0 ' . $header);
|
header('HTTP/1.0 ' . $header);
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Admins extends API_V1_Controller {
|
||||||
{
|
{
|
||||||
// Insert the admin to the database.
|
// Insert the admin to the database.
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$admin = $request->getBody();
|
$admin = $request->get_body();
|
||||||
$this->parser->decode($admin);
|
$this->parser->decode($admin);
|
||||||
|
|
||||||
if (isset($admin['id']))
|
if (isset($admin['id']))
|
||||||
|
@ -123,7 +123,7 @@ class Admins extends API_V1_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$updatedAdmin = $request->getBody();
|
$updatedAdmin = $request->get_body();
|
||||||
$baseAdmin = $batch[0];
|
$baseAdmin = $batch[0];
|
||||||
$this->parser->decode($updatedAdmin, $baseAdmin);
|
$this->parser->decode($updatedAdmin, $baseAdmin);
|
||||||
$updatedAdmin['id'] = $id;
|
$updatedAdmin['id'] = $id;
|
||||||
|
|
|
@ -97,7 +97,7 @@ class Appointments extends API_V1_Controller {
|
||||||
{
|
{
|
||||||
// Insert the appointment to the database.
|
// Insert the appointment to the database.
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$appointment = $request->getBody();
|
$appointment = $request->get_body();
|
||||||
$this->parser->decode($appointment);
|
$this->parser->decode($appointment);
|
||||||
|
|
||||||
if (isset($appointment['id']))
|
if (isset($appointment['id']))
|
||||||
|
@ -164,7 +164,7 @@ class Appointments extends API_V1_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$updated_appointment = $request->getBody();
|
$updated_appointment = $request->get_body();
|
||||||
$base_appointment = $batch[0];
|
$base_appointment = $batch[0];
|
||||||
$this->parser->decode($updated_appointment, $base_appointment);
|
$this->parser->decode($updated_appointment, $base_appointment);
|
||||||
$updated_appointment['id'] = $id;
|
$updated_appointment['id'] = $id;
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Categories extends API_V1_Controller {
|
||||||
{
|
{
|
||||||
// Insert the category to the database.
|
// Insert the category to the database.
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$category = $request->getBody();
|
$category = $request->get_body();
|
||||||
$this->parser->decode($category);
|
$this->parser->decode($category);
|
||||||
|
|
||||||
if (isset($category['id']))
|
if (isset($category['id']))
|
||||||
|
@ -123,7 +123,7 @@ class Categories extends API_V1_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$updated_category = $request->getBody();
|
$updated_category = $request->get_body();
|
||||||
$base_category = $batch[0];
|
$base_category = $batch[0];
|
||||||
$this->parser->decode($updated_category, $base_category);
|
$this->parser->decode($updated_category, $base_category);
|
||||||
$updated_category['id'] = $id;
|
$updated_category['id'] = $id;
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Customers extends API_V1_Controller {
|
||||||
{
|
{
|
||||||
// Insert the customer to the database.
|
// Insert the customer to the database.
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$customer = $request->getBody();
|
$customer = $request->get_body();
|
||||||
$this->parser->decode($customer);
|
$this->parser->decode($customer);
|
||||||
|
|
||||||
if (isset($customer['id']))
|
if (isset($customer['id']))
|
||||||
|
@ -123,7 +123,7 @@ class Customers extends API_V1_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$updated_customer = $request->getBody();
|
$updated_customer = $request->get_body();
|
||||||
$base_customer = $batch[0];
|
$base_customer = $batch[0];
|
||||||
$this->parser->decode($updated_customer, $base_customer);
|
$this->parser->decode($updated_customer, $base_customer);
|
||||||
$updated_customer['id'] = $id;
|
$updated_customer['id'] = $id;
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Providers extends API_V1_Controller {
|
||||||
{
|
{
|
||||||
// Insert the provider to the database.
|
// Insert the provider to the database.
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$provider = $request->getBody();
|
$provider = $request->get_body();
|
||||||
$this->parser->decode($provider);
|
$this->parser->decode($provider);
|
||||||
|
|
||||||
if (isset($provider['id']))
|
if (isset($provider['id']))
|
||||||
|
@ -123,7 +123,7 @@ class Providers extends API_V1_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$updated_provider = $request->getBody();
|
$updated_provider = $request->get_body();
|
||||||
$base_provider = $batch[0];
|
$base_provider = $batch[0];
|
||||||
$this->parser->decode($updated_provider, $base_provider);
|
$this->parser->decode($updated_provider, $base_provider);
|
||||||
$updated_provider['id'] = $id;
|
$updated_provider['id'] = $id;
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Secretaries extends API_V1_Controller {
|
||||||
{
|
{
|
||||||
// Insert the secretary to the database.
|
// Insert the secretary to the database.
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$secretary = $request->getBody();
|
$secretary = $request->get_body();
|
||||||
$this->parser->decode($secretary);
|
$this->parser->decode($secretary);
|
||||||
|
|
||||||
if (isset($secretary['id']))
|
if (isset($secretary['id']))
|
||||||
|
@ -123,7 +123,7 @@ class Secretaries extends API_V1_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$updated_secretary = $request->getBody();
|
$updated_secretary = $request->get_body();
|
||||||
$base_secretary = $batch[0];
|
$base_secretary = $batch[0];
|
||||||
$this->parser->decode($updated_secretary, $base_secretary);
|
$this->parser->decode($updated_secretary, $base_secretary);
|
||||||
$updated_secretary['id'] = $id;
|
$updated_secretary['id'] = $id;
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Services extends API_V1_Controller {
|
||||||
{
|
{
|
||||||
// Insert the service to the database.
|
// Insert the service to the database.
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$service = $request->getBody();
|
$service = $request->get_body();
|
||||||
$this->parser->decode($service);
|
$this->parser->decode($service);
|
||||||
|
|
||||||
if (isset($service['id']))
|
if (isset($service['id']))
|
||||||
|
@ -123,7 +123,7 @@ class Services extends API_V1_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$updated_service = $request->getBody();
|
$updated_service = $request->get_body();
|
||||||
$base_service = $batch[0];
|
$base_service = $batch[0];
|
||||||
$this->parser->decode($updated_service, $base_service);
|
$this->parser->decode($updated_service, $base_service);
|
||||||
$updated_service['id'] = $id;
|
$updated_service['id'] = $id;
|
||||||
|
|
|
@ -102,7 +102,7 @@ class Settings extends API_V1_Controller {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$value = $request->getBody()['value'];
|
$value = $request->get_body()['value'];
|
||||||
$this->settings_model->set_setting($name, $value);
|
$this->settings_model->set_setting($name, $value);
|
||||||
|
|
||||||
// Fetch the updated object from the database and return it to the client.
|
// Fetch the updated object from the database and return it to the client.
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Unavailabilities extends API_V1_Controller {
|
||||||
{
|
{
|
||||||
// Insert the appointment to the database.
|
// Insert the appointment to the database.
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$unavailability = $request->getBody();
|
$unavailability = $request->get_body();
|
||||||
$this->parser->decode($unavailability);
|
$this->parser->decode($unavailability);
|
||||||
|
|
||||||
if (isset($unavailability['id']))
|
if (isset($unavailability['id']))
|
||||||
|
@ -123,7 +123,7 @@ class Unavailabilities extends API_V1_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$updatedUnavailability = $request->getBody();
|
$updatedUnavailability = $request->get_body();
|
||||||
$baseUnavailability = $batch[0];
|
$baseUnavailability = $batch[0];
|
||||||
$this->parser->decode($updatedUnavailability, $baseUnavailability);
|
$this->parser->decode($updatedUnavailability, $baseUnavailability);
|
||||||
$updatedUnavailability['id'] = $id;
|
$updatedUnavailability['id'] = $id;
|
||||||
|
|
|
@ -89,7 +89,7 @@ class Notifications {
|
||||||
|
|
||||||
if ($send_customer === TRUE)
|
if ($send_customer === TRUE)
|
||||||
{
|
{
|
||||||
$email->sendAppointmentDetails($appointment, $provider,
|
$email->send_appointment_details($appointment, $provider,
|
||||||
$service, $customer, $settings, $customer_title,
|
$service, $customer, $settings, $customer_title,
|
||||||
$customer_message, $customer_link, new Email($customer['email']), new Text($ics_stream), $customer['timezone']);
|
$customer_message, $customer_link, new Email($customer['email']), new Text($ics_stream), $customer['timezone']);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ class Notifications {
|
||||||
|
|
||||||
if ($send_provider === TRUE)
|
if ($send_provider === TRUE)
|
||||||
{
|
{
|
||||||
$email->sendAppointmentDetails($appointment, $provider,
|
$email->send_appointment_details($appointment, $provider,
|
||||||
$service, $customer, $settings, $provider_title,
|
$service, $customer, $settings, $provider_title,
|
||||||
$provider_message, $provider_link, new Email($provider['email']), new Text($ics_stream), $provider['timezone']);
|
$provider_message, $provider_link, new Email($provider['email']), new Text($ics_stream), $provider['timezone']);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ class Notifications {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$email->sendAppointmentDetails($appointment, $provider,
|
$email->send_appointment_details($appointment, $provider,
|
||||||
$service, $customer, $settings, $provider_title,
|
$service, $customer, $settings, $provider_title,
|
||||||
$provider_message, $provider_link, new Email($admin['email']), new Text($ics_stream), $admin['timezone']);
|
$provider_message, $provider_link, new Email($admin['email']), new Text($ics_stream), $admin['timezone']);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class Notifications {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$email->sendAppointmentDetails($appointment, $provider,
|
$email->send_appointment_details($appointment, $provider,
|
||||||
$service, $customer, $settings, $provider_title,
|
$service, $customer, $settings, $provider_title,
|
||||||
$provider_message, $provider_link, new Email($secretary['email']), new Text($ics_stream), $secretary['timezone']);
|
$provider_message, $provider_link, new Email($secretary['email']), new Text($ics_stream), $secretary['timezone']);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ class Notifications {
|
||||||
|
|
||||||
if ($send_provider === TRUE)
|
if ($send_provider === TRUE)
|
||||||
{
|
{
|
||||||
$email->sendDeleteAppointment($appointment, $provider,
|
$email->send_delete_appointment($appointment, $provider,
|
||||||
$service, $customer, $settings, new Email($provider['email']),
|
$service, $customer, $settings, new Email($provider['email']),
|
||||||
new Text($this->CI->input->post('cancel_reason')));
|
new Text($this->CI->input->post('cancel_reason')));
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ class Notifications {
|
||||||
|
|
||||||
if ($send_customer === TRUE)
|
if ($send_customer === TRUE)
|
||||||
{
|
{
|
||||||
$email->sendDeleteAppointment($appointment, $provider,
|
$email->send_delete_appointment($appointment, $provider,
|
||||||
$service, $customer, $settings, new Email($customer['email']),
|
$service, $customer, $settings, new Email($customer['email']),
|
||||||
new Text($this->CI->input->post('cancel_reason')));
|
new Text($this->CI->input->post('cancel_reason')));
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ class Notifications {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$email->sendDeleteAppointment($appointment, $provider,
|
$email->send_delete_appointment($appointment, $provider,
|
||||||
$service, $customer, $settings, new Email($admin['email']),
|
$service, $customer, $settings, new Email($admin['email']),
|
||||||
new Text($this->CI->input->post('cancel_reason')));
|
new Text($this->CI->input->post('cancel_reason')));
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ class Notifications {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$email->sendDeleteAppointment($appointment, $provider,
|
$email->send_delete_appointment($appointment, $provider,
|
||||||
$service, $customer, $settings, new Email($secretary['email']),
|
$service, $customer, $settings, new Email($secretary['email']),
|
||||||
new Text($this->CI->input->post('cancel_reason')));
|
new Text($this->CI->input->post('cancel_reason')));
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,9 @@ class Services_model extends EA_Model {
|
||||||
/**
|
/**
|
||||||
* Get all, or specific records from service's table.
|
* Get all, or specific records from service's table.
|
||||||
*
|
*
|
||||||
* @example $this->Model->getBatch('id = ' . $recordId);
|
* Example:
|
||||||
|
*
|
||||||
|
* $this->model->get_batch(['id' => $record_id]);
|
||||||
*
|
*
|
||||||
* @param mixed $where
|
* @param mixed $where
|
||||||
* @param mixed $order_by
|
* @param mixed $order_by
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
|
|
||||||
namespace EA\Engine\Api\V1;
|
namespace EA\Engine\Api\V1;
|
||||||
|
|
||||||
use \EA\Engine\Types\NonEmptyText;
|
use CI_Controller;
|
||||||
|
use EA\Engine\Types\NonEmptyText;
|
||||||
|
use EA_Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API v1 Authorization Class
|
* API v1 Authorization Class
|
||||||
|
@ -26,18 +28,18 @@ class Authorization {
|
||||||
/**
|
/**
|
||||||
* Framework Instance
|
* Framework Instance
|
||||||
*
|
*
|
||||||
* @var CI_Controller
|
* @var EA_Controller
|
||||||
*/
|
*/
|
||||||
protected $framework;
|
protected $CI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Constructor
|
* Class Constructor
|
||||||
*
|
*
|
||||||
* @param \CI_Controller $framework
|
* @param CI_Controller $CI
|
||||||
*/
|
*/
|
||||||
public function __construct(\CI_Controller $framework)
|
public function __construct(EA_Controller $CI)
|
||||||
{
|
{
|
||||||
$this->framework = $framework;
|
$this->CI = $CI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,9 +52,9 @@ class Authorization {
|
||||||
*/
|
*/
|
||||||
public function basic(NonEmptyText $username, NonEmptyText $password)
|
public function basic(NonEmptyText $username, NonEmptyText $password)
|
||||||
{
|
{
|
||||||
$this->framework->load->model('user_model');
|
$this->CI->load->model('user_model');
|
||||||
|
|
||||||
if ( ! $this->framework->user_model->check_login($username->get(), $password->get()))
|
if ( ! $this->CI->user_model->check_login($username->get(), $password->get()))
|
||||||
{
|
{
|
||||||
throw new Exception('The provided credentials do not match any admin user!', 401, 'Unauthorized');
|
throw new Exception('The provided credentials do not match any admin user!', 401, 'Unauthorized');
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Exception extends \Exception {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getHeader()
|
public function get_header()
|
||||||
{
|
{
|
||||||
return $this->header;
|
return $this->header;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Admins implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function encode(array &$response)
|
public function encode(array &$response)
|
||||||
{
|
{
|
||||||
$encodedResponse = [
|
$encoded_response = [
|
||||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||||
'firstName' => $response['first_name'],
|
'firstName' => $response['first_name'],
|
||||||
'lastName' => $response['last_name'],
|
'lastName' => $response['last_name'],
|
||||||
|
@ -47,7 +47,7 @@ class Admins implements ParsersInterface {
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $encodedResponse;
|
$response = $encoded_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,92 +58,92 @@ class Admins implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function decode(array &$request, array $base = NULL)
|
public function decode(array &$request, array $base = NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest = $base ?: [];
|
$decoded_request = $base ?: [];
|
||||||
|
|
||||||
if ( ! empty($request['id']))
|
if ( ! empty($request['id']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id'] = $request['id'];
|
$decoded_request['id'] = $request['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['firstName']))
|
if ( ! empty($request['firstName']))
|
||||||
{
|
{
|
||||||
$decodedRequest['first_name'] = $request['firstName'];
|
$decoded_request['first_name'] = $request['firstName'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['lastName']))
|
if ( ! empty($request['lastName']))
|
||||||
{
|
{
|
||||||
$decodedRequest['last_name'] = $request['lastName'];
|
$decoded_request['last_name'] = $request['lastName'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['email']))
|
if ( ! empty($request['email']))
|
||||||
{
|
{
|
||||||
$decodedRequest['email'] = $request['email'];
|
$decoded_request['email'] = $request['email'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['mobile']))
|
if ( ! empty($request['mobile']))
|
||||||
{
|
{
|
||||||
$decodedRequest['mobile_number'] = $request['mobile'];
|
$decoded_request['mobile_number'] = $request['mobile'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['phone']))
|
if ( ! empty($request['phone']))
|
||||||
{
|
{
|
||||||
$decodedRequest['phone_number'] = $request['phone'];
|
$decoded_request['phone_number'] = $request['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['address']))
|
if ( ! empty($request['address']))
|
||||||
{
|
{
|
||||||
$decodedRequest['address'] = $request['address'];
|
$decoded_request['address'] = $request['address'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['city']))
|
if ( ! empty($request['city']))
|
||||||
{
|
{
|
||||||
$decodedRequest['city'] = $request['city'];
|
$decoded_request['city'] = $request['city'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['state']))
|
if ( ! empty($request['state']))
|
||||||
{
|
{
|
||||||
$decodedRequest['state'] = $request['state'];
|
$decoded_request['state'] = $request['state'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['zip']))
|
if ( ! empty($request['zip']))
|
||||||
{
|
{
|
||||||
$decodedRequest['zip_code'] = $request['zip'];
|
$decoded_request['zip_code'] = $request['zip'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['notes']))
|
if ( ! empty($request['notes']))
|
||||||
{
|
{
|
||||||
$decodedRequest['notes'] = $request['notes'];
|
$decoded_request['notes'] = $request['notes'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']))
|
if ( ! empty($request['settings']))
|
||||||
{
|
{
|
||||||
if (empty($decodedRequest['settings']))
|
if (empty($decoded_request['settings']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings'] = [];
|
$decoded_request['settings'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['username']))
|
if ( ! empty($request['settings']['username']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['username'] = $request['settings']['username'];
|
$decoded_request['settings']['username'] = $request['settings']['username'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['password']))
|
if ( ! empty($request['settings']['password']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['password'] = $request['settings']['password'];
|
$decoded_request['settings']['password'] = $request['settings']['password'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request['settings']['notifications'] !== NULL)
|
if ($request['settings']['notifications'] !== NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['notifications'] = filter_var($request['settings']['notifications'],
|
$decoded_request['settings']['notifications'] = filter_var($request['settings']['notifications'],
|
||||||
FILTER_VALIDATE_BOOLEAN);
|
FILTER_VALIDATE_BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['calendarView']))
|
if ( ! empty($request['settings']['calendarView']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['calendar_view'] = $request['settings']['calendarView'];
|
$decoded_request['settings']['calendar_view'] = $request['settings']['calendarView'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $decodedRequest;
|
$request = $decoded_request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Appointments implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function encode(array &$response)
|
public function encode(array &$response)
|
||||||
{
|
{
|
||||||
$encodedResponse = [
|
$encoded_response = [
|
||||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||||
'book' => $response['book_datetime'],
|
'book' => $response['book_datetime'],
|
||||||
'start' => $response['start_datetime'],
|
'start' => $response['start_datetime'],
|
||||||
|
@ -44,26 +44,26 @@ class Appointments implements ParsersInterface {
|
||||||
|
|
||||||
if (isset($response['provider']))
|
if (isset($response['provider']))
|
||||||
{
|
{
|
||||||
$providerParser = new Providers();
|
$provider_parser = new Providers();
|
||||||
$providerParser->encode($response['provider']);
|
$provider_parser->encode($response['provider']);
|
||||||
$encodedResponse['provider'] = $response['provider'];
|
$encoded_response['provider'] = $response['provider'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($response['customer']))
|
if (isset($response['customer']))
|
||||||
{
|
{
|
||||||
$customerParser = new Customers();
|
$customer_parser = new Customers();
|
||||||
$customerParser->encode($response['customer']);
|
$customer_parser->encode($response['customer']);
|
||||||
$encodedResponse['customer'] = $response['customer'];
|
$encoded_response['customer'] = $response['customer'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($response['service']))
|
if (isset($response['service']))
|
||||||
{
|
{
|
||||||
$serviceParser = new Services();
|
$service_parser = new Services();
|
||||||
$serviceParser->encode($response['service']);
|
$service_parser->encode($response['service']);
|
||||||
$encodedResponse['service'] = $response['service'];
|
$encoded_response['service'] = $response['service'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $encodedResponse;
|
$response = $encoded_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,65 +74,65 @@ class Appointments implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function decode(array &$request, array $base = NULL)
|
public function decode(array &$request, array $base = NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest = $base ?: [];
|
$decoded_request = $base ?: [];
|
||||||
|
|
||||||
if ( ! empty($request['id']))
|
if ( ! empty($request['id']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id'] = $request['id'];
|
$decoded_request['id'] = $request['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['book']))
|
if ( ! empty($request['book']))
|
||||||
{
|
{
|
||||||
$decodedRequest['book_datetime'] = $request['book'];
|
$decoded_request['book_datetime'] = $request['book'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['start']))
|
if ( ! empty($request['start']))
|
||||||
{
|
{
|
||||||
$decodedRequest['start_datetime'] = $request['start'];
|
$decoded_request['start_datetime'] = $request['start'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['end']))
|
if ( ! empty($request['end']))
|
||||||
{
|
{
|
||||||
$decodedRequest['end_datetime'] = $request['end'];
|
$decoded_request['end_datetime'] = $request['end'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['hash']))
|
if ( ! empty($request['hash']))
|
||||||
{
|
{
|
||||||
$decodedRequest['hash'] = $request['hash'];
|
$decoded_request['hash'] = $request['hash'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['location']))
|
if ( ! empty($request['location']))
|
||||||
{
|
{
|
||||||
$decodedRequest['location'] = $request['location'];
|
$decoded_request['location'] = $request['location'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['notes']))
|
if ( ! empty($request['notes']))
|
||||||
{
|
{
|
||||||
$decodedRequest['notes'] = $request['notes'];
|
$decoded_request['notes'] = $request['notes'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['customerId']))
|
if ( ! empty($request['customerId']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id_users_customer'] = $request['customerId'];
|
$decoded_request['id_users_customer'] = $request['customerId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['providerId']))
|
if ( ! empty($request['providerId']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id_users_provider'] = $request['providerId'];
|
$decoded_request['id_users_provider'] = $request['providerId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['serviceId']))
|
if ( ! empty($request['serviceId']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id_services'] = $request['serviceId'];
|
$decoded_request['id_services'] = $request['serviceId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['googleCalendarId']))
|
if ( ! empty($request['googleCalendarId']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id_google_calendar'] = $request['googleCalendarId'];
|
$decoded_request['id_google_calendar'] = $request['googleCalendarId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$decodedRequest['is_unavailable'] = FALSE;
|
$decoded_request['is_unavailable'] = FALSE;
|
||||||
|
|
||||||
$request = $decodedRequest;
|
$request = $decoded_request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,13 @@ class Categories implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function encode(array &$response)
|
public function encode(array &$response)
|
||||||
{
|
{
|
||||||
$encodedResponse = [
|
$encoded_response = [
|
||||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||||
'name' => $response['name'],
|
'name' => $response['name'],
|
||||||
'description' => $response['description']
|
'description' => $response['description']
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $encodedResponse;
|
$response = $encoded_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,23 +45,23 @@ class Categories implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function decode(array &$request, array $base = NULL)
|
public function decode(array &$request, array $base = NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest = $base ?: [];
|
$decoded_request = $base ?: [];
|
||||||
|
|
||||||
if ( ! empty($request['id']))
|
if ( ! empty($request['id']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id'] = $request['id'];
|
$decoded_request['id'] = $request['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['name']))
|
if ( ! empty($request['name']))
|
||||||
{
|
{
|
||||||
$decodedRequest['name'] = $request['name'];
|
$decoded_request['name'] = $request['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['description']))
|
if ( ! empty($request['description']))
|
||||||
{
|
{
|
||||||
$decodedRequest['description'] = $request['description'];
|
$decoded_request['description'] = $request['description'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $decodedRequest;
|
$request = $decoded_request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Customers implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function encode(array &$response)
|
public function encode(array &$response)
|
||||||
{
|
{
|
||||||
$encodedResponse = [
|
$encoded_response = [
|
||||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||||
'firstName' => $response['first_name'],
|
'firstName' => $response['first_name'],
|
||||||
'lastName' => $response['last_name'],
|
'lastName' => $response['last_name'],
|
||||||
|
@ -40,7 +40,7 @@ class Customers implements ParsersInterface {
|
||||||
'notes' => $response['notes']
|
'notes' => $response['notes']
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $encodedResponse;
|
$response = $encoded_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,53 +51,53 @@ class Customers implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function decode(array &$request, array $base = NULL)
|
public function decode(array &$request, array $base = NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest = $base ?: [];
|
$decoded_request = $base ?: [];
|
||||||
|
|
||||||
if ( ! empty($request['id']))
|
if ( ! empty($request['id']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id'] = $request['id'];
|
$decoded_request['id'] = $request['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['firstName']))
|
if ( ! empty($request['firstName']))
|
||||||
{
|
{
|
||||||
$decodedRequest['first_name'] = $request['firstName'];
|
$decoded_request['first_name'] = $request['firstName'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['lastName']))
|
if ( ! empty($request['lastName']))
|
||||||
{
|
{
|
||||||
$decodedRequest['last_name'] = $request['lastName'];
|
$decoded_request['last_name'] = $request['lastName'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['email']))
|
if ( ! empty($request['email']))
|
||||||
{
|
{
|
||||||
$decodedRequest['email'] = $request['email'];
|
$decoded_request['email'] = $request['email'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['phone']))
|
if ( ! empty($request['phone']))
|
||||||
{
|
{
|
||||||
$decodedRequest['phone_number'] = $request['phone'];
|
$decoded_request['phone_number'] = $request['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['address']))
|
if ( ! empty($request['address']))
|
||||||
{
|
{
|
||||||
$decodedRequest['address'] = $request['address'];
|
$decoded_request['address'] = $request['address'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['city']))
|
if ( ! empty($request['city']))
|
||||||
{
|
{
|
||||||
$decodedRequest['city'] = $request['city'];
|
$decoded_request['city'] = $request['city'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['zip']))
|
if ( ! empty($request['zip']))
|
||||||
{
|
{
|
||||||
$decodedRequest['zip_code'] = $request['zip'];
|
$decoded_request['zip_code'] = $request['zip'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['notes']))
|
if ( ! empty($request['notes']))
|
||||||
{
|
{
|
||||||
$decodedRequest['notes'] = $request['notes'];
|
$decoded_request['notes'] = $request['notes'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $decodedRequest;
|
$request = $decoded_request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Providers implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function encode(array &$response)
|
public function encode(array &$response)
|
||||||
{
|
{
|
||||||
$encodedResponse = [
|
$encoded_response = [
|
||||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||||
'firstName' => $response['first_name'],
|
'firstName' => $response['first_name'],
|
||||||
'lastName' => $response['last_name'],
|
'lastName' => $response['last_name'],
|
||||||
|
@ -44,12 +44,12 @@ class Providers implements ParsersInterface {
|
||||||
|
|
||||||
if (array_key_exists('services', $response))
|
if (array_key_exists('services', $response))
|
||||||
{
|
{
|
||||||
$encodedResponse['services'] = $response['services'];
|
$encoded_response['services'] = $response['services'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('settings', $response))
|
if (array_key_exists('settings', $response))
|
||||||
{
|
{
|
||||||
$encodedResponse['settings'] = [
|
$encoded_response['settings'] = [
|
||||||
'username' => $response['settings']['username'],
|
'username' => $response['settings']['username'],
|
||||||
'notifications' => filter_var($response['settings']['notifications'], FILTER_VALIDATE_BOOLEAN),
|
'notifications' => filter_var($response['settings']['notifications'], FILTER_VALIDATE_BOOLEAN),
|
||||||
'calendarView' => $response['settings']['calendar_view'],
|
'calendarView' => $response['settings']['calendar_view'],
|
||||||
|
@ -63,7 +63,7 @@ class Providers implements ParsersInterface {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $encodedResponse;
|
$response = $encoded_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,133 +74,133 @@ class Providers implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function decode(array &$request, array $base = NULL)
|
public function decode(array &$request, array $base = NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest = $base ?: [];
|
$decoded_request = $base ?: [];
|
||||||
|
|
||||||
if ( ! empty($request['id']))
|
if ( ! empty($request['id']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id'] = $request['id'];
|
$decoded_request['id'] = $request['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['firstName']))
|
if ( ! empty($request['firstName']))
|
||||||
{
|
{
|
||||||
$decodedRequest['first_name'] = $request['firstName'];
|
$decoded_request['first_name'] = $request['firstName'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['lastName']))
|
if ( ! empty($request['lastName']))
|
||||||
{
|
{
|
||||||
$decodedRequest['last_name'] = $request['lastName'];
|
$decoded_request['last_name'] = $request['lastName'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['email']))
|
if ( ! empty($request['email']))
|
||||||
{
|
{
|
||||||
$decodedRequest['email'] = $request['email'];
|
$decoded_request['email'] = $request['email'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['mobile']))
|
if ( ! empty($request['mobile']))
|
||||||
{
|
{
|
||||||
$decodedRequest['mobile_number'] = $request['mobile'];
|
$decoded_request['mobile_number'] = $request['mobile'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['phone']))
|
if ( ! empty($request['phone']))
|
||||||
{
|
{
|
||||||
$decodedRequest['phone_number'] = $request['phone'];
|
$decoded_request['phone_number'] = $request['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['address']))
|
if ( ! empty($request['address']))
|
||||||
{
|
{
|
||||||
$decodedRequest['address'] = $request['address'];
|
$decoded_request['address'] = $request['address'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['city']))
|
if ( ! empty($request['city']))
|
||||||
{
|
{
|
||||||
$decodedRequest['city'] = $request['city'];
|
$decoded_request['city'] = $request['city'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['state']))
|
if ( ! empty($request['state']))
|
||||||
{
|
{
|
||||||
$decodedRequest['state'] = $request['state'];
|
$decoded_request['state'] = $request['state'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['zip']))
|
if ( ! empty($request['zip']))
|
||||||
{
|
{
|
||||||
$decodedRequest['zip_code'] = $request['zip'];
|
$decoded_request['zip_code'] = $request['zip'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['notes']))
|
if ( ! empty($request['notes']))
|
||||||
{
|
{
|
||||||
$decodedRequest['notes'] = $request['notes'];
|
$decoded_request['notes'] = $request['notes'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['services']))
|
if ( ! empty($request['services']))
|
||||||
{
|
{
|
||||||
$decodedRequest['services'] = $request['services'];
|
$decoded_request['services'] = $request['services'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']))
|
if ( ! empty($request['settings']))
|
||||||
{
|
{
|
||||||
if (empty($decodedRequest['settings']))
|
if (empty($decoded_request['settings']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings'] = [];
|
$decoded_request['settings'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['username']))
|
if ( ! empty($request['settings']['username']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['username'] = $request['settings']['username'];
|
$decoded_request['settings']['username'] = $request['settings']['username'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['password']))
|
if ( ! empty($request['settings']['password']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['password'] = $request['settings']['password'];
|
$decoded_request['settings']['password'] = $request['settings']['password'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['calendarView']))
|
if ( ! empty($request['settings']['calendarView']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['calendar_view'] = $request['settings']['calendarView'];
|
$decoded_request['settings']['calendar_view'] = $request['settings']['calendarView'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request['settings']['notifications'] !== NULL)
|
if ($request['settings']['notifications'] !== NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['notifications'] = filter_var($request['settings']['notifications'],
|
$decoded_request['settings']['notifications'] = filter_var($request['settings']['notifications'],
|
||||||
FILTER_VALIDATE_BOOLEAN);
|
FILTER_VALIDATE_BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request['settings']['googleSync'] !== NULL)
|
if ($request['settings']['googleSync'] !== NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['google_sync'] = filter_var($request['settings']['googleSync'],
|
$decoded_request['settings']['google_sync'] = filter_var($request['settings']['googleSync'],
|
||||||
FILTER_VALIDATE_BOOLEAN);
|
FILTER_VALIDATE_BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['googleCalendar']))
|
if ( ! empty($request['settings']['googleCalendar']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['google_calendar'] = $request['settings']['googleCalendar'];
|
$decoded_request['settings']['google_calendar'] = $request['settings']['googleCalendar'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['googleToken']))
|
if ( ! empty($request['settings']['googleToken']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['google_token'] = $request['settings']['googleToken'];
|
$decoded_request['settings']['google_token'] = $request['settings']['googleToken'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['syncFutureDays']))
|
if ( ! empty($request['settings']['syncFutureDays']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['sync_future_days'] = $request['settings']['syncFutureDays'];
|
$decoded_request['settings']['sync_future_days'] = $request['settings']['syncFutureDays'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['syncPastDays']))
|
if ( ! empty($request['settings']['syncPastDays']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['sync_past_days'] = $request['settings']['syncPastDays'];
|
$decoded_request['settings']['sync_past_days'] = $request['settings']['syncPastDays'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['workingPlan']))
|
if ( ! empty($request['settings']['workingPlan']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['working_plan'] = json_encode($request['settings']['workingPlan']);
|
$decoded_request['settings']['working_plan'] = json_encode($request['settings']['workingPlan']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['workingPlanExceptions']))
|
if ( ! empty($request['settings']['workingPlanExceptions']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['working_plan_exceptions'] = json_encode($request['settings']['workingPlanExceptions']);
|
$decoded_request['settings']['working_plan_exceptions'] = json_encode($request['settings']['workingPlanExceptions']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $decodedRequest;
|
$request = $decoded_request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Secretaries implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function encode(array &$response)
|
public function encode(array &$response)
|
||||||
{
|
{
|
||||||
$encodedResponse = [
|
$encoded_response = [
|
||||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||||
'firstName' => $response['first_name'],
|
'firstName' => $response['first_name'],
|
||||||
'lastName' => $response['last_name'],
|
'lastName' => $response['last_name'],
|
||||||
|
@ -48,7 +48,7 @@ class Secretaries implements ParsersInterface {
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $encodedResponse;
|
$response = $encoded_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,97 +59,97 @@ class Secretaries implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function decode(array &$request, array $base = NULL)
|
public function decode(array &$request, array $base = NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest = $base ?: [];
|
$decoded_request = $base ?: [];
|
||||||
|
|
||||||
if ( ! empty($request['id']))
|
if ( ! empty($request['id']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id'] = $request['id'];
|
$decoded_request['id'] = $request['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['firstName']))
|
if ( ! empty($request['firstName']))
|
||||||
{
|
{
|
||||||
$decodedRequest['first_name'] = $request['firstName'];
|
$decoded_request['first_name'] = $request['firstName'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['lastName']))
|
if ( ! empty($request['lastName']))
|
||||||
{
|
{
|
||||||
$decodedRequest['last_name'] = $request['lastName'];
|
$decoded_request['last_name'] = $request['lastName'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['email']))
|
if ( ! empty($request['email']))
|
||||||
{
|
{
|
||||||
$decodedRequest['email'] = $request['email'];
|
$decoded_request['email'] = $request['email'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['mobile']))
|
if ( ! empty($request['mobile']))
|
||||||
{
|
{
|
||||||
$decodedRequest['mobile_number'] = $request['mobile'];
|
$decoded_request['mobile_number'] = $request['mobile'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['phone']))
|
if ( ! empty($request['phone']))
|
||||||
{
|
{
|
||||||
$decodedRequest['phone_number'] = $request['phone'];
|
$decoded_request['phone_number'] = $request['phone'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['address']))
|
if ( ! empty($request['address']))
|
||||||
{
|
{
|
||||||
$decodedRequest['address'] = $request['address'];
|
$decoded_request['address'] = $request['address'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['city']))
|
if ( ! empty($request['city']))
|
||||||
{
|
{
|
||||||
$decodedRequest['city'] = $request['city'];
|
$decoded_request['city'] = $request['city'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['state']))
|
if ( ! empty($request['state']))
|
||||||
{
|
{
|
||||||
$decodedRequest['state'] = $request['state'];
|
$decoded_request['state'] = $request['state'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['zip']))
|
if ( ! empty($request['zip']))
|
||||||
{
|
{
|
||||||
$decodedRequest['zip_code'] = $request['zip'];
|
$decoded_request['zip_code'] = $request['zip'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['notes']))
|
if ( ! empty($request['notes']))
|
||||||
{
|
{
|
||||||
$decodedRequest['notes'] = $request['notes'];
|
$decoded_request['notes'] = $request['notes'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['providers']))
|
if ( ! empty($request['providers']))
|
||||||
{
|
{
|
||||||
$decodedRequest['providers'] = $request['providers'];
|
$decoded_request['providers'] = $request['providers'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']))
|
if ( ! empty($request['settings']))
|
||||||
{
|
{
|
||||||
if (empty($decodedRequest['settings']))
|
if (empty($decoded_request['settings']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings'] = [];
|
$decoded_request['settings'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['username']))
|
if ( ! empty($request['settings']['username']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['username'] = $request['settings']['username'];
|
$decoded_request['settings']['username'] = $request['settings']['username'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['password']))
|
if ( ! empty($request['settings']['password']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['password'] = $request['settings']['password'];
|
$decoded_request['settings']['password'] = $request['settings']['password'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request['settings']['notifications'] !== NULL)
|
if ($request['settings']['notifications'] !== NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['notifications'] = filter_var($request['settings']['notifications'],
|
$decoded_request['settings']['notifications'] = filter_var($request['settings']['notifications'],
|
||||||
FILTER_VALIDATE_BOOLEAN);
|
FILTER_VALIDATE_BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['settings']['calendarView']))
|
if ( ! empty($request['settings']['calendarView']))
|
||||||
{
|
{
|
||||||
$decodedRequest['settings']['calendar_view'] = $request['settings']['calendarView'];
|
$decoded_request['settings']['calendar_view'] = $request['settings']['calendarView'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $decodedRequest;
|
$request = $decoded_request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Services implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function encode(array &$response)
|
public function encode(array &$response)
|
||||||
{
|
{
|
||||||
$encodedResponse = [
|
$encoded_response = [
|
||||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||||
'name' => $response['name'],
|
'name' => $response['name'],
|
||||||
'duration' => (int)$response['duration'],
|
'duration' => (int)$response['duration'],
|
||||||
|
@ -41,7 +41,7 @@ class Services implements ParsersInterface {
|
||||||
'categoryId' => $response['id_service_categories'] !== NULL ? (int)$response['id_service_categories'] : NULL
|
'categoryId' => $response['id_service_categories'] !== NULL ? (int)$response['id_service_categories'] : NULL
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $encodedResponse;
|
$response = $encoded_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,58 +52,58 @@ class Services implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function decode(array &$request, array $base = NULL)
|
public function decode(array &$request, array $base = NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest = $base ?: [];
|
$decoded_request = $base ?: [];
|
||||||
|
|
||||||
if ( ! empty($request['id']))
|
if ( ! empty($request['id']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id'] = $request['id'];
|
$decoded_request['id'] = $request['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['name']))
|
if ( ! empty($request['name']))
|
||||||
{
|
{
|
||||||
$decodedRequest['name'] = $request['name'];
|
$decoded_request['name'] = $request['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['duration']))
|
if ( ! empty($request['duration']))
|
||||||
{
|
{
|
||||||
$decodedRequest['duration'] = $request['duration'];
|
$decoded_request['duration'] = $request['duration'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['price']))
|
if ( ! empty($request['price']))
|
||||||
{
|
{
|
||||||
$decodedRequest['price'] = $request['price'];
|
$decoded_request['price'] = $request['price'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['currency']))
|
if ( ! empty($request['currency']))
|
||||||
{
|
{
|
||||||
$decodedRequest['currency'] = $request['currency'];
|
$decoded_request['currency'] = $request['currency'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['description']))
|
if ( ! empty($request['description']))
|
||||||
{
|
{
|
||||||
$decodedRequest['description'] = $request['description'];
|
$decoded_request['description'] = $request['description'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['location']))
|
if ( ! empty($request['location']))
|
||||||
{
|
{
|
||||||
$decodedRequest['location'] = $request['location'];
|
$decoded_request['location'] = $request['location'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['availabilitiesType']))
|
if ( ! empty($request['availabilitiesType']))
|
||||||
{
|
{
|
||||||
$decodedRequest['availabilities_type'] = $request['availabilitiesType'];
|
$decoded_request['availabilities_type'] = $request['availabilitiesType'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['attendantsNumber']))
|
if ( ! empty($request['attendantsNumber']))
|
||||||
{
|
{
|
||||||
$decodedRequest['attendants_number'] = $request['attendantsNumber'];
|
$decoded_request['attendants_number'] = $request['attendantsNumber'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['categoryId']))
|
if ( ! empty($request['categoryId']))
|
||||||
{
|
{
|
||||||
$decodedRequest['id_service_categories'] = $request['categoryId'];
|
$decoded_request['id_service_categories'] = $request['categoryId'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $decodedRequest;
|
$request = $decoded_request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,12 @@ class Settings implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function encode(array &$response)
|
public function encode(array &$response)
|
||||||
{
|
{
|
||||||
$encodedResponse = [
|
$encoded_response = [
|
||||||
'name' => $response['name'],
|
'name' => $response['name'],
|
||||||
'value' => $response['value']
|
'value' => $response['value']
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $encodedResponse;
|
$response = $encoded_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,18 +44,18 @@ class Settings implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function decode(array &$request, array $base = NULL)
|
public function decode(array &$request, array $base = NULL)
|
||||||
{
|
{
|
||||||
$decodedRequest = $base ?: [];
|
$decoded_request = $base ?: [];
|
||||||
|
|
||||||
if ( ! empty($request['name']))
|
if ( ! empty($request['name']))
|
||||||
{
|
{
|
||||||
$decodedRequest['name'] = $request['name'];
|
$decoded_request['name'] = $request['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty($request['value']))
|
if ( ! empty($request['value']))
|
||||||
{
|
{
|
||||||
$decodedRequest['value'] = $request['value'];
|
$decoded_request['value'] = $request['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $decodedRequest;
|
$request = $decoded_request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Unavailabilities implements ParsersInterface {
|
||||||
*/
|
*/
|
||||||
public function encode(array &$response)
|
public function encode(array &$response)
|
||||||
{
|
{
|
||||||
$encodedResponse = [
|
$encoded_response = [
|
||||||
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
'id' => $response['id'] !== NULL ? (int)$response['id'] : NULL,
|
||||||
'book' => $response['book_datetime'],
|
'book' => $response['book_datetime'],
|
||||||
'start' => $response['start_datetime'],
|
'start' => $response['start_datetime'],
|
||||||
|
@ -38,7 +38,7 @@ class Unavailabilities implements ParsersInterface {
|
||||||
'googleCalendarId' => $response['id_google_calendar'] !== NULL ? (int)$response['id_google_calendar'] : NULL
|
'googleCalendarId' => $response['id_google_calendar'] !== NULL ? (int)$response['id_google_calendar'] : NULL
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $encodedResponse;
|
$response = $encoded_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,24 +44,24 @@ class Minimize implements ProcessorsInterface {
|
||||||
|
|
||||||
$fields = explode(',', $_GET['fields']);
|
$fields = explode(',', $_GET['fields']);
|
||||||
|
|
||||||
$temporaryResponse = [];
|
$temporary_response = [];
|
||||||
|
|
||||||
foreach ($response as &$entry)
|
foreach ($response as &$entry)
|
||||||
{
|
{
|
||||||
$temporaryEntry = [];
|
$temporary_entry = [];
|
||||||
|
|
||||||
foreach ($fields as $field)
|
foreach ($fields as $field)
|
||||||
{
|
{
|
||||||
$field = trim($field);
|
$field = trim($field);
|
||||||
if (isset($entry[$field]))
|
if (isset($entry[$field]))
|
||||||
{
|
{
|
||||||
$temporaryEntry[$field] = $entry[$field];
|
$temporary_entry[$field] = $entry[$field];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$temporaryResponse[] = $temporaryEntry;
|
$temporary_response[] = $temporary_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $temporaryResponse;
|
$response = $temporary_response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Paginate implements ProcessorsInterface {
|
||||||
* Process Response Array
|
* Process Response Array
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* http://ea-installation.com/api/v1/appointments?page=3&length=30
|
* http://example.org/api/v1/appointments?page=3&length=30
|
||||||
*
|
*
|
||||||
* @param array &$response The response array to be processed.
|
* @param array &$response The response array to be processed.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -35,18 +35,18 @@ class Search implements ProcessorsInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$searchedResponse = [];
|
$searched_response = [];
|
||||||
$keyword = (string)$_GET['q'];
|
$keyword = (string)$_GET['q'];
|
||||||
|
|
||||||
foreach ($response as $entry)
|
foreach ($response as $entry)
|
||||||
{
|
{
|
||||||
if (self::_recursiveArraySearch($entry, $keyword) !== FALSE)
|
if (self::recursive_array_search($entry, $keyword) !== FALSE)
|
||||||
{
|
{
|
||||||
$searchedResponse[] = $entry;
|
$searched_response[] = $entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $searchedResponse;
|
$response = $searched_response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,13 +57,13 @@ class Search implements ProcessorsInterface {
|
||||||
*
|
*
|
||||||
* @return int|bool Returns the index of the search occurrence or false it nothing was found.
|
* @return int|bool Returns the index of the search occurrence or false it nothing was found.
|
||||||
*/
|
*/
|
||||||
protected static function _recursiveArraySearch(array $haystack, $needle)
|
protected static function recursive_array_search(array $haystack, $needle)
|
||||||
{
|
{
|
||||||
foreach ($haystack as $key => $value)
|
foreach ($haystack as $key => $value)
|
||||||
{
|
{
|
||||||
$currentKey = $key;
|
$currentKey = $key;
|
||||||
|
|
||||||
if (is_array($value) && self::_recursiveArraySearch($value, $needle) !== FALSE)
|
if (is_array($value) && self::recursive_array_search($value, $needle) !== FALSE)
|
||||||
{
|
{
|
||||||
return $currentKey;
|
return $currentKey;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,56 +40,56 @@ class Sort implements ProcessorsInterface {
|
||||||
|
|
||||||
$sort = explode(',', (string)$_GET['sort']);
|
$sort = explode(',', (string)$_GET['sort']);
|
||||||
|
|
||||||
$sortDirection1 = substr($sort[0], 0, 1) === '-' ? SORT_DESC : SORT_ASC;
|
$sort_direction1 = substr($sort[0], 0, 1) === '-' ? SORT_DESC : SORT_ASC;
|
||||||
|
|
||||||
if (isset($sort[1]))
|
if (isset($sort[1]))
|
||||||
{
|
{
|
||||||
$sortDirection2 = substr($sort[1], 0, 1) === '-' ? SORT_DESC : SORT_ASC;
|
$sort_direction2 = substr($sort[1], 0, 1) === '-' ? SORT_DESC : SORT_ASC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sortDirection2 = NULL;
|
$sort_direction2 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($sort[2]))
|
if (isset($sort[2]))
|
||||||
{
|
{
|
||||||
$sortDirection3 = substr($sort[2], 0, 1) === '-' ? SORT_DESC : SORT_ASC;
|
$sort_direction3 = substr($sort[2], 0, 1) === '-' ? SORT_DESC : SORT_ASC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sortDirection3 = NULL;
|
$sort_direction3 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($response as $index => $entry)
|
foreach ($response as $index => $entry)
|
||||||
{
|
{
|
||||||
$sortOrder1[$index] = $entry[substr($sort[0], 1)];
|
$sort_order1[$index] = $entry[substr($sort[0], 1)];
|
||||||
|
|
||||||
if ($sortDirection2)
|
if ($sort_direction2)
|
||||||
{
|
{
|
||||||
$sortOrder2[$index] = $entry[substr($sort[1], 1)];
|
$sort_order2[$index] = $entry[substr($sort[1], 1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sortDirection3)
|
if ($sort_direction3)
|
||||||
{
|
{
|
||||||
$sortOrder3[$index] = $entry[substr($sort[2], 1)];
|
$sort_order3[$index] = $entry[substr($sort[2], 1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$arguments = [
|
$arguments = [
|
||||||
&$sortOrder1,
|
&$sort_order1,
|
||||||
&$sortDirection1
|
&$sort_direction1
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($sortDirection2)
|
if ($sort_direction2)
|
||||||
{
|
{
|
||||||
$arguments[] = $sortOrder2;
|
$arguments[] = $sort_order2;
|
||||||
$arguments[] = $sortDirection2;
|
$arguments[] = $sort_direction2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sortDirection3)
|
if ($sort_direction3)
|
||||||
{
|
{
|
||||||
$arguments[] = $sortOrder3;
|
$arguments[] = $sort_order3;
|
||||||
$arguments[] = $sortDirection3;
|
$arguments[] = $sort_direction3;
|
||||||
}
|
}
|
||||||
|
|
||||||
$arguments[] = &$response;
|
$arguments[] = &$response;
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Request {
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getBody()
|
public function get_body()
|
||||||
{
|
{
|
||||||
return json_decode(file_get_contents('php://input'), TRUE);
|
return json_decode(file_get_contents('php://input'), TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,15 +74,15 @@ class Email {
|
||||||
* "company_email" values are required in the array.
|
* "company_email" values are required in the array.
|
||||||
* @param \EA\Engine\Types\Text $title The email title may vary depending the receiver.
|
* @param \EA\Engine\Types\Text $title The email title may vary depending the receiver.
|
||||||
* @param \EA\Engine\Types\Text $message The email message may vary depending the receiver.
|
* @param \EA\Engine\Types\Text $message The email message may vary depending the receiver.
|
||||||
* @param \EA\Engine\Types\Url $appointmentLink This link is going to enable the receiver to make changes to the
|
* @param \EA\Engine\Types\Url $appointment_link_address This link is going to enable the receiver to make changes
|
||||||
* appointment record.
|
* to the appointment record.
|
||||||
* @param \EA\Engine\Types\Email $recipientEmail The recipient email address.
|
* @param \EA\Engine\Types\Email $recipient_email The recipient email address.
|
||||||
* @param \EA\Engine\Types\Text $icsStream Stream contents of the ICS file.
|
* @param \EA\Engine\Types\Text $ics_stream Stream contents of the ICS file.
|
||||||
* @param string|null $timezone Custom timezone for the notification.
|
* @param string|null $timezone Custom timezone for the notification.
|
||||||
*
|
*
|
||||||
* @throws \PHPMailer\PHPMailer\Exception
|
* @throws \PHPMailer\PHPMailer\Exception
|
||||||
*/
|
*/
|
||||||
public function sendAppointmentDetails(
|
public function send_appointment_details(
|
||||||
array $appointment,
|
array $appointment,
|
||||||
array $provider,
|
array $provider,
|
||||||
array $service,
|
array $service,
|
||||||
|
@ -90,9 +90,9 @@ class Email {
|
||||||
array $settings,
|
array $settings,
|
||||||
Text $title,
|
Text $title,
|
||||||
Text $message,
|
Text $message,
|
||||||
Url $appointmentLink,
|
Url $appointment_link_address,
|
||||||
EmailAddress $recipientEmail,
|
EmailAddress $recipient_email,
|
||||||
Text $icsStream,
|
Text $ics_stream,
|
||||||
$timezone = NULL
|
$timezone = NULL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,7 @@ class Email {
|
||||||
$appointment_start_date = $appointment_start->format($date_format . ' ' . $time_format);
|
$appointment_start_date = $appointment_start->format($date_format . ' ' . $time_format);
|
||||||
$appointment_end_date = $appointment_end->format($date_format . ' ' . $time_format);
|
$appointment_end_date = $appointment_end->format($date_format . ' ' . $time_format);
|
||||||
$appointment_timezone = $timezones[empty($timezone) ? $provider['timezone'] : $timezone];
|
$appointment_timezone = $timezones[empty($timezone) ? $provider['timezone'] : $timezone];
|
||||||
$appointment_link = $appointmentLink->get();
|
$appointment_link = $appointment_link_address->get();
|
||||||
$company_link = $settings['company_link'];
|
$company_link = $settings['company_link'];
|
||||||
$company_name = $settings['company_name'];
|
$company_name = $settings['company_name'];
|
||||||
$customer_name = $customer['first_name'] . ' ' . $customer['last_name'];
|
$customer_name = $customer['first_name'] . ' ' . $customer['last_name'];
|
||||||
|
@ -161,10 +161,10 @@ class Email {
|
||||||
$mailer = $this->create_mailer();
|
$mailer = $this->create_mailer();
|
||||||
$mailer->From = $settings['company_email'];
|
$mailer->From = $settings['company_email'];
|
||||||
$mailer->FromName = $settings['company_name'];
|
$mailer->FromName = $settings['company_name'];
|
||||||
$mailer->AddAddress($recipientEmail->get());
|
$mailer->AddAddress($recipient_email->get());
|
||||||
$mailer->Subject = $title->get();
|
$mailer->Subject = $title->get();
|
||||||
$mailer->Body = $html;
|
$mailer->Body = $html;
|
||||||
$mailer->addStringAttachment($icsStream->get(), 'invitation.ics');
|
$mailer->addStringAttachment($ics_stream->get(), 'invitation.ics');
|
||||||
|
|
||||||
if ( ! $mailer->Send())
|
if ( ! $mailer->Send())
|
||||||
{
|
{
|
||||||
|
@ -188,19 +188,19 @@ class Email {
|
||||||
* @param array $customer The record data of the appointment customer.
|
* @param array $customer The record data of the appointment customer.
|
||||||
* @param array $settings Some settings that are required for this function. As of now this array must contain
|
* @param array $settings Some settings that are required for this function. As of now this array must contain
|
||||||
* the following values: "company_link", "company_name", "company_email".
|
* the following values: "company_link", "company_name", "company_email".
|
||||||
* @param \EA\Engine\Types\Email $recipientEmail The email address of the email recipient.
|
* @param \EA\Engine\Types\Email $recipient_email The email address of the email recipient.
|
||||||
* @param \EA\Engine\Types\Text $reason The reason why the appointment is deleted.
|
* @param \EA\Engine\Types\Text $reason The reason why the appointment is deleted.
|
||||||
* @param string|null $timezone Custom timezone.
|
* @param string|null $timezone Custom timezone.
|
||||||
*
|
*
|
||||||
* @throws \PHPMailer\PHPMailer\Exception
|
* @throws \PHPMailer\PHPMailer\Exception
|
||||||
*/
|
*/
|
||||||
public function sendDeleteAppointment(
|
public function send_delete_appointment(
|
||||||
array $appointment,
|
array $appointment,
|
||||||
array $provider,
|
array $provider,
|
||||||
array $service,
|
array $service,
|
||||||
array $customer,
|
array $customer,
|
||||||
array $settings,
|
array $settings,
|
||||||
EmailAddress $recipientEmail,
|
EmailAddress $recipient_email,
|
||||||
Text $reason,
|
Text $reason,
|
||||||
$timezone = NULL
|
$timezone = NULL
|
||||||
)
|
)
|
||||||
|
@ -269,7 +269,7 @@ class Email {
|
||||||
// Send email to recipient.
|
// Send email to recipient.
|
||||||
$mailer->From = $settings['company_email'];
|
$mailer->From = $settings['company_email'];
|
||||||
$mailer->FromName = $settings['company_name'];
|
$mailer->FromName = $settings['company_name'];
|
||||||
$mailer->AddAddress($recipientEmail->get()); // "Name" argument crushes the phpmailer class.
|
$mailer->AddAddress($recipient_email->get()); // "Name" argument crushes the phpmailer class.
|
||||||
$mailer->Subject = $this->framework->lang->line('appointment_cancelled_title');
|
$mailer->Subject = $this->framework->lang->line('appointment_cancelled_title');
|
||||||
$mailer->Body = $html;
|
$mailer->Body = $html;
|
||||||
|
|
||||||
|
@ -286,8 +286,10 @@ class Email {
|
||||||
* @param \EA\Engine\Types\NonEmptyText $password Contains the new password.
|
* @param \EA\Engine\Types\NonEmptyText $password Contains the new password.
|
||||||
* @param \EA\Engine\Types\Email $recipientEmail The receiver's email address.
|
* @param \EA\Engine\Types\Email $recipientEmail The receiver's email address.
|
||||||
* @param array $company The company settings to be included in the email.
|
* @param array $company The company settings to be included in the email.
|
||||||
|
*
|
||||||
|
* @throws \PHPMailer\PHPMailer\Exception
|
||||||
*/
|
*/
|
||||||
public function sendPassword(NonEmptyText $password, EmailAddress $recipientEmail, array $company)
|
public function send_password(NonEmptyText $password, EmailAddress $recipientEmail, array $company)
|
||||||
{
|
{
|
||||||
$email_title = $this->framework->lang->line('new_account_password');
|
$email_title = $this->framework->lang->line('new_account_password');
|
||||||
$password = '<strong>' . $password->get() . '</strong>';
|
$password = '<strong>' . $password->get() . '</strong>';
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Boolean extends Type {
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function _validate($value)
|
protected function validate($value)
|
||||||
{
|
{
|
||||||
return is_bool($value);
|
return is_bool($value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Decimal extends Type {
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function _validate($value)
|
protected function validate($value)
|
||||||
{
|
{
|
||||||
return is_float($value);
|
return is_float($value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,12 @@ namespace EA\Engine\Types;
|
||||||
* @package EA\Engine\Types
|
* @package EA\Engine\Types
|
||||||
*/
|
*/
|
||||||
class Email extends NonEmptyText {
|
class Email extends NonEmptyText {
|
||||||
protected function _validate($value)
|
/**
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function validate($value)
|
||||||
{
|
{
|
||||||
return parent::_validate($value) && filter_var($value, FILTER_VALIDATE_EMAIL);
|
return parent::validate($value) && filter_var($value, FILTER_VALIDATE_EMAIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Integer extends Type {
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function _validate($value)
|
protected function validate($value)
|
||||||
{
|
{
|
||||||
return is_numeric($value) && ! is_float($value);
|
return is_numeric($value) && ! is_float($value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ class NonEmptyText extends Text {
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function _validate($value)
|
protected function validate($value)
|
||||||
{
|
{
|
||||||
return parent::_validate($value) && $value !== '';
|
return parent::validate($value) && $value !== '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,11 @@ namespace EA\Engine\Types;
|
||||||
* @package EA\Engine\Types
|
* @package EA\Engine\Types
|
||||||
*/
|
*/
|
||||||
class Text extends Type {
|
class Text extends Type {
|
||||||
protected function _validate($value)
|
/**
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function validate($value)
|
||||||
{
|
{
|
||||||
return is_string($value);
|
return is_string($value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ abstract class Type {
|
||||||
*/
|
*/
|
||||||
public function __construct($value)
|
public function __construct($value)
|
||||||
{
|
{
|
||||||
if ( ! $this->_validate($value))
|
if ( ! $this->validate($value))
|
||||||
{
|
{
|
||||||
throw new \InvalidArgumentException(__CLASS__ . ': Invalid argument value provided (' . $value . ')');
|
throw new \InvalidArgumentException(__CLASS__ . ': Invalid argument value provided (' . $value . ')');
|
||||||
}
|
}
|
||||||
|
@ -53,5 +53,5 @@ abstract class Type {
|
||||||
*
|
*
|
||||||
* @return bool Returns whether the value is valid or not.
|
* @return bool Returns whether the value is valid or not.
|
||||||
*/
|
*/
|
||||||
abstract protected function _validate($value);
|
abstract protected function validate($value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ class UnsignedInteger extends Integer {
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function _validate($value)
|
protected function validate($value)
|
||||||
{
|
{
|
||||||
return parent::_validate($value) && $value > -1;
|
return parent::validate($value) && $value > -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ class Url extends NonEmptyText {
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function _validate($value)
|
protected function validate($value)
|
||||||
{
|
{
|
||||||
return parent::_validate($value) && filter_var($value, FILTER_VALIDATE_URL);
|
return parent::validate($value) && filter_var($value, FILTER_VALIDATE_URL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue