From e65c178e8f4009ea2a9a3f56553131ecdf911890 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 6 Nov 2021 16:15:12 +0100 Subject: [PATCH] Removed the deprecated engine directory from the project (including tests and the composer autoloading configuration) --- composer.json | 8 - engine/Api/V1/Authorization.php | 62 ---- engine/Api/V1/Exception.php | 58 --- engine/Api/V1/Parsers/Admins.php | 155 -------- engine/Api/V1/Parsers/Appointments.php | 138 -------- engine/Api/V1/Parsers/Categories.php | 67 ---- engine/Api/V1/Parsers/Customers.php | 103 ------ engine/Api/V1/Parsers/ParsersInterface.php | 38 -- engine/Api/V1/Parsers/Providers.php | 226 ------------ engine/Api/V1/Parsers/Secretaries.php | 161 --------- engine/Api/V1/Parsers/Services.php | 109 ------ engine/Api/V1/Parsers/Settings.php | 61 ---- engine/Api/V1/Parsers/Unavailabilities.php | 97 ----- engine/Api/V1/Processors/Filter.php | 36 -- engine/Api/V1/Processors/Minimize.php | 67 ---- engine/Api/V1/Processors/Paginate.php | 51 --- .../Api/V1/Processors/ProcessorsInterface.php | 25 -- engine/Api/V1/Processors/Search.php | 79 ----- engine/Api/V1/Processors/Sort.php | 99 ------ engine/Api/V1/Request.php | 34 -- engine/Api/V1/Response.php | 154 -------- engine/Notifications/Email.php | 334 ------------------ engine/Types/Boolean.php | 32 -- engine/Types/Decimal.php | 33 -- engine/Types/Email.php | 32 -- engine/Types/Integer.php | 32 -- engine/Types/NonEmptyText.php | 32 -- engine/Types/Text.php | 32 -- engine/Types/Type.php | 57 --- engine/Types/UnsignedInteger.php | 32 -- engine/Types/Url.php | 32 -- engine/index.html | 10 - tests/engine/Api/V1/AuthorizationTest.php | 29 -- tests/engine/Api/V1/FilterTest.php | 23 -- tests/engine/Api/V1/MinimizeTest.php | 23 -- tests/engine/Api/V1/PaginationTest.php | 23 -- tests/engine/Api/V1/ResponseTest.php | 23 -- tests/engine/Api/V1/SearchTest.php | 23 -- tests/engine/Api/V1/SortTest.php | 23 -- tests/engine/Api/V1/fixtures/admin.json | 17 - tests/engine/Api/V1/fixtures/appointment.json | 12 - tests/engine/Api/V1/fixtures/category.json | 5 - tests/engine/Api/V1/fixtures/customer.json | 11 - tests/engine/Api/V1/fixtures/provider.json | 72 ---- tests/engine/Api/V1/fixtures/secretary.json | 20 -- tests/engine/Api/V1/fixtures/service.json | 9 - tests/engine/Api/V1/fixtures/setting.json | 4 - .../Api/V1/fixtures/unavailability.json | 9 - tests/engine/Types/BooleanTest.php | 30 -- tests/engine/Types/DecimalTest.php | 30 -- tests/engine/Types/EmailTest.php | 36 -- tests/engine/Types/IntegerTest.php | 36 -- tests/engine/Types/NonEmptyTextTest.php | 36 -- tests/engine/Types/TextTest.php | 30 -- tests/engine/Types/UnsignedIntegerTest.php | 36 -- tests/engine/Types/UrlTest.php | 36 -- 56 files changed, 3082 deletions(-) delete mode 100644 engine/Api/V1/Authorization.php delete mode 100644 engine/Api/V1/Exception.php delete mode 100644 engine/Api/V1/Parsers/Admins.php delete mode 100644 engine/Api/V1/Parsers/Appointments.php delete mode 100644 engine/Api/V1/Parsers/Categories.php delete mode 100644 engine/Api/V1/Parsers/Customers.php delete mode 100644 engine/Api/V1/Parsers/ParsersInterface.php delete mode 100644 engine/Api/V1/Parsers/Providers.php delete mode 100644 engine/Api/V1/Parsers/Secretaries.php delete mode 100644 engine/Api/V1/Parsers/Services.php delete mode 100644 engine/Api/V1/Parsers/Settings.php delete mode 100644 engine/Api/V1/Parsers/Unavailabilities.php delete mode 100644 engine/Api/V1/Processors/Filter.php delete mode 100644 engine/Api/V1/Processors/Minimize.php delete mode 100644 engine/Api/V1/Processors/Paginate.php delete mode 100644 engine/Api/V1/Processors/ProcessorsInterface.php delete mode 100644 engine/Api/V1/Processors/Search.php delete mode 100644 engine/Api/V1/Processors/Sort.php delete mode 100644 engine/Api/V1/Request.php delete mode 100644 engine/Api/V1/Response.php delete mode 100755 engine/Notifications/Email.php delete mode 100644 engine/Types/Boolean.php delete mode 100644 engine/Types/Decimal.php delete mode 100644 engine/Types/Email.php delete mode 100644 engine/Types/Integer.php delete mode 100644 engine/Types/NonEmptyText.php delete mode 100644 engine/Types/Text.php delete mode 100644 engine/Types/Type.php delete mode 100644 engine/Types/UnsignedInteger.php delete mode 100644 engine/Types/Url.php delete mode 100644 engine/index.html delete mode 100644 tests/engine/Api/V1/AuthorizationTest.php delete mode 100644 tests/engine/Api/V1/FilterTest.php delete mode 100644 tests/engine/Api/V1/MinimizeTest.php delete mode 100644 tests/engine/Api/V1/PaginationTest.php delete mode 100644 tests/engine/Api/V1/ResponseTest.php delete mode 100644 tests/engine/Api/V1/SearchTest.php delete mode 100644 tests/engine/Api/V1/SortTest.php delete mode 100644 tests/engine/Api/V1/fixtures/admin.json delete mode 100644 tests/engine/Api/V1/fixtures/appointment.json delete mode 100644 tests/engine/Api/V1/fixtures/category.json delete mode 100644 tests/engine/Api/V1/fixtures/customer.json delete mode 100644 tests/engine/Api/V1/fixtures/provider.json delete mode 100644 tests/engine/Api/V1/fixtures/secretary.json delete mode 100644 tests/engine/Api/V1/fixtures/service.json delete mode 100644 tests/engine/Api/V1/fixtures/setting.json delete mode 100644 tests/engine/Api/V1/fixtures/unavailability.json delete mode 100644 tests/engine/Types/BooleanTest.php delete mode 100644 tests/engine/Types/DecimalTest.php delete mode 100644 tests/engine/Types/EmailTest.php delete mode 100644 tests/engine/Types/IntegerTest.php delete mode 100644 tests/engine/Types/NonEmptyTextTest.php delete mode 100644 tests/engine/Types/TextTest.php delete mode 100644 tests/engine/Types/UnsignedIntegerTest.php delete mode 100644 tests/engine/Types/UrlTest.php diff --git a/composer.json b/composer.json index 7a226909..9e52809c 100644 --- a/composer.json +++ b/composer.json @@ -26,14 +26,6 @@ "services" ], "minimum-stability": "stable", - "autoload": { - "psr-4": { - "EA\\Engine\\": [ - "engine/", - "tests/engine/" - ] - } - }, "require": { "php": ">=7.3", "ext-curl": "*", diff --git a/engine/Api/V1/Authorization.php b/engine/Api/V1/Authorization.php deleted file mode 100644 index c8095570..00000000 --- a/engine/Api/V1/Authorization.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1; - -use CI_Controller; -use EA\Engine\Types\NonEmptyText; -use EA_Controller; - -/** - * API v1 Authorization Class - * - * This class will handle the authorization procedure of the API. - * - * @deprecated - */ -class Authorization { - /** - * Framework Instance - * - * @var EA_Controller - */ - protected $CI; - - /** - * Class Constructor - * - * @param CI_Controller $CI - */ - public function __construct(EA_Controller $CI) - { - $this->CI = $CI; - } - - /** - * Perform Basic Authentication - * - * @param NonEmptyText $username Admin Username - * @param NonEmptyText $password Admin Password - * - * @throws \RuntimeException - */ - public function basic(NonEmptyText $username, NonEmptyText $password) - { - $this->CI->load->library('accounts'); - - if ( ! $this->CI->accounts->check_login($username->get(), $password->get())) - { - throw new \RuntimeException('The provided credentials do not match any admin user!', 401, 'Unauthorized'); - } - } -} diff --git a/engine/Api/V1/Exception.php b/engine/Api/V1/Exception.php deleted file mode 100644 index 750031ca..00000000 --- a/engine/Api/V1/Exception.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1; - -/** - * API v1 Exception Class - * - * This exception variation will hold the information needed for exception handling in the API. - * - * @deprecated - */ -class Exception extends \Exception { - /** - * Header Description - * - * e.g. 'Unauthorized' - * - * @var string - */ - protected $header; - - /** - * Class Constructor - * - * @link http://php.net/manual/en/class.exception.php - * - * @param string $message - * @param int $code - * @param string $header - * @param \Exception|null $previous - */ - public function __construct($message = NULL, $code = 500, $header = '', \Exception $previous = NULL) - { - parent::__construct($message, $code, $previous); - $this->header = $header; - } - - /** - * Get the header string. - * - * @return string - */ - public function get_header() - { - return $this->header; - } -} diff --git a/engine/Api/V1/Parsers/Admins.php b/engine/Api/V1/Parsers/Admins.php deleted file mode 100644 index fac31fb0..00000000 --- a/engine/Api/V1/Parsers/Admins.php +++ /dev/null @@ -1,155 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Parsers; - -/** - * Admins Parser - * - * This class will handle the encoding and decoding from the API requests. - * - * @deprecated - */ -class Admins implements ParsersInterface { - /** - * Encode Response Array - * - * @param array &$response The response to be encoded. - */ - public function encode(array &$response) - { - $encoded_response = [ - 'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL, - 'firstName' => $response['first_name'], - 'lastName' => $response['last_name'], - 'email' => $response['email'], - 'mobile' => $response['mobile_number'], - 'phone' => $response['phone_number'], - 'address' => $response['address'], - 'city' => $response['city'], - 'state' => $response['state'], - 'zip' => $response['zip_code'], - 'notes' => $response['notes'], - 'timezone' => $response['timezone'], - 'settings' => [ - 'username' => $response['settings']['username'], - 'notifications' => filter_var($response['settings']['notifications'], FILTER_VALIDATE_BOOLEAN), - 'calendarView' => $response['settings']['calendar_view'] - ] - ]; - - $response = $encoded_response; - } - - /** - * Decode Request - * - * @param array &$request The request to be decoded. - * @param array $base Optional (null), if provided it will be used as a base array. - */ - public function decode(array &$request, array $base = NULL) - { - $decoded_request = $base ?: []; - - if (array_key_exists('id', $request)) - { - $decoded_request['id'] = $request['id']; - } - - if (array_key_exists('firstName', $request)) - { - $decoded_request['first_name'] = $request['firstName']; - } - - if (array_key_exists('lastName', $request)) - { - $decoded_request['last_name'] = $request['lastName']; - } - - if (array_key_exists('email', $request)) - { - $decoded_request['email'] = $request['email']; - } - - if (array_key_exists('mobile', $request)) - { - $decoded_request['mobile_number'] = $request['mobile']; - } - - if (array_key_exists('phone', $request)) - { - $decoded_request['phone_number'] = $request['phone']; - } - - if (array_key_exists('address', $request)) - { - $decoded_request['address'] = $request['address']; - } - - if (array_key_exists('city', $request)) - { - $decoded_request['city'] = $request['city']; - } - - if (array_key_exists('state', $request)) - { - $decoded_request['state'] = $request['state']; - } - - if (array_key_exists('zip', $request)) - { - $decoded_request['zip_code'] = $request['zip']; - } - - if (array_key_exists('notes', $request)) - { - $decoded_request['notes'] = $request['notes']; - } - - if (array_key_exists('timezone', $request)) - { - $decoded_request['timezone'] = $request['timezone']; - } - - if (array_key_exists('settings', $request)) - { - if (empty($decoded_request['settings'])) - { - $decoded_request['settings'] = []; - } - - if (array_key_exists('username', $request['settings'])) - { - $decoded_request['settings']['username'] = $request['settings']['username']; - } - - if (array_key_exists('password', $request['settings'])) - { - $decoded_request['settings']['password'] = $request['settings']['password']; - } - - if (array_key_exists('notifications', $request['settings'])) - { - $decoded_request['settings']['notifications'] = filter_var($request['settings']['notifications'], - FILTER_VALIDATE_BOOLEAN); - } - - if (array_key_exists('calendarView', $request['settings'])) - { - $decoded_request['settings']['calendar_view'] = $request['settings']['calendarView']; - } - } - - $request = $decoded_request; - } -} diff --git a/engine/Api/V1/Parsers/Appointments.php b/engine/Api/V1/Parsers/Appointments.php deleted file mode 100644 index 24974e4b..00000000 --- a/engine/Api/V1/Parsers/Appointments.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Parsers; - -/** - * Appointments Parser - * - * This class will handle the encoding and decoding from the API requests. - * - * @deprecated - */ -class Appointments implements ParsersInterface { - /** - * Encode Response Array - * - * @param array &$response The response to be encoded. - */ - public function encode(array &$response) - { - $encoded_response = [ - 'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL, - 'book' => $response['book_datetime'], - 'start' => $response['start_datetime'], - 'end' => $response['end_datetime'], - 'hash' => $response['hash'], - 'location' => $response['location'], - 'notes' => $response['notes'], - 'customerId' => $response['id_users_customer'] !== NULL ? (int)$response['id_users_customer'] : NULL, - 'providerId' => $response['id_users_provider'] !== NULL ? (int)$response['id_users_provider'] : NULL, - 'serviceId' => $response['id_services'] !== NULL ? (int)$response['id_services'] : NULL, - 'googleCalendarId' => $response['id_google_calendar'] !== NULL ? (int)$response['id_google_calendar'] : NULL - ]; - - if (isset($response['provider'])) - { - $provider_parser = new Providers(); - $provider_parser->encode($response['provider']); - $encoded_response['provider'] = $response['provider']; - } - - if (isset($response['customer'])) - { - $customer_parser = new Customers(); - $customer_parser->encode($response['customer']); - $encoded_response['customer'] = $response['customer']; - } - - if (isset($response['service'])) - { - $service_parser = new Services(); - $service_parser->encode($response['service']); - $encoded_response['service'] = $response['service']; - } - - $response = $encoded_response; - } - - /** - * Decode Request - * - * @param array &$request The request to be decoded. - * @param array $base Optional (null), if provided it will be used as a base array. - */ - public function decode(array &$request, array $base = NULL) - { - $decoded_request = $base ?: []; - - if (array_key_exists('id', $request)) - { - $decoded_request['id'] = $request['id']; - } - - if (array_key_exists('book', $request)) - { - $decoded_request['book_datetime'] = $request['book']; - } - - if (array_key_exists('start', $request)) - { - $decoded_request['start_datetime'] = $request['start']; - } - - if (array_key_exists('end', $request)) - { - $decoded_request['end_datetime'] = $request['end']; - } - - if (array_key_exists('hash', $request)) - { - $decoded_request['hash'] = $request['hash']; - } - - if (array_key_exists('location', $request)) - { - $decoded_request['location'] = $request['location']; - } - - if (array_key_exists('notes', $request)) - { - $decoded_request['notes'] = $request['notes']; - } - - if (array_key_exists('customerId', $request)) - { - $decoded_request['id_users_customer'] = $request['customerId']; - } - - if (array_key_exists('providerId', $request)) - { - $decoded_request['id_users_provider'] = $request['providerId']; - } - - if (array_key_exists('serviceId', $request)) - { - $decoded_request['id_services'] = $request['serviceId']; - } - - if (array_key_exists('googleCalendarId', $request)) - { - $decoded_request['id_google_calendar'] = $request['googleCalendarId']; - } - - $decoded_request['is_unavailable'] = FALSE; - - $request = $decoded_request; - } -} diff --git a/engine/Api/V1/Parsers/Categories.php b/engine/Api/V1/Parsers/Categories.php deleted file mode 100644 index 6b2ea7a2..00000000 --- a/engine/Api/V1/Parsers/Categories.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Parsers; - -/** - * Categories Parser - * - * This class will handle the encoding and decoding from the API requests. - * - * @deprecated - */ -class Categories implements ParsersInterface { - /** - * Encode Response Array - * - * @param array &$response The response to be encoded. - */ - public function encode(array &$response) - { - $encoded_response = [ - 'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL, - 'name' => $response['name'], - 'description' => array_key_exists('description', $response) ? $response['description'] : NULL - ]; - - $response = $encoded_response; - } - - /** - * Decode Request - * - * @param array &$request The request to be decoded. - * @param array $base Optional (null), if provided it will be used as a base array. - */ - public function decode(array &$request, array $base = NULL) - { - $decoded_request = $base ?: []; - - if (array_key_exists('id', $request)) - { - $decoded_request['id'] = $request['id']; - } - - if (array_key_exists('name', $request)) - { - $decoded_request['name'] = $request['name']; - } - - if (array_key_exists('description', $request)) - { - $decoded_request['description'] = $request['description']; - } - - $request = $decoded_request; - } -} diff --git a/engine/Api/V1/Parsers/Customers.php b/engine/Api/V1/Parsers/Customers.php deleted file mode 100644 index c6610774..00000000 --- a/engine/Api/V1/Parsers/Customers.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Parsers; - -/** - * Customers Parser - * - * This class will handle the encoding and decoding from the API requests. - * - * @deprecated - */ -class Customers implements ParsersInterface { - /** - * Encode Response Array - * - * @param array &$response The response to be encoded. - */ - public function encode(array &$response) - { - $encoded_response = [ - 'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL, - 'firstName' => $response['first_name'], - 'lastName' => $response['last_name'], - 'email' => $response['email'], - 'phone' => $response['phone_number'], - 'address' => $response['address'], - 'city' => $response['city'], - 'zip' => $response['zip_code'], - 'notes' => $response['notes'] - ]; - - $response = $encoded_response; - } - - /** - * Decode Request - * - * @param array &$request The request to be decoded. - * @param array $base Optional (null), if provided it will be used as a base array. - */ - public function decode(array &$request, array $base = NULL) - { - $decoded_request = $base ?: []; - - if ( array_key_exists('id', $request)) - { - $decoded_request['id'] = $request['id']; - } - - if ( array_key_exists('firstName', $request)) - { - $decoded_request['first_name'] = $request['firstName']; - } - - if ( array_key_exists('lastName', $request)) - { - $decoded_request['last_name'] = $request['lastName']; - } - - if ( array_key_exists('email', $request)) - { - $decoded_request['email'] = $request['email']; - } - - if ( array_key_exists('phone', $request)) - { - $decoded_request['phone_number'] = $request['phone']; - } - - if ( array_key_exists('address', $request)) - { - $decoded_request['address'] = $request['address']; - } - - if ( array_key_exists('city', $request)) - { - $decoded_request['city'] = $request['city']; - } - - if ( array_key_exists('zip', $request)) - { - $decoded_request['zip_code'] = $request['zip']; - } - - if ( array_key_exists('notes', $request)) - { - $decoded_request['notes'] = $request['notes']; - } - - $request = $decoded_request; - } -} diff --git a/engine/Api/V1/Parsers/ParsersInterface.php b/engine/Api/V1/Parsers/ParsersInterface.php deleted file mode 100644 index 8b103297..00000000 --- a/engine/Api/V1/Parsers/ParsersInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Parsers; - -/** - * Parsers Interface - * - * Every parser needs the "encode" and "decode" methods. - * - * @deprecated - */ -interface ParsersInterface { - /** - * Encode Response Array - * - * @param array &$response The response to be encoded. - */ - public function encode(array &$response); - - /** - * Decode Request - * - * @param array &$request The request to be decoded. - * @param array $base Optional (null), if provided it will be used as a base array. - */ - public function decode(array &$request, array $base = NULL); -} diff --git a/engine/Api/V1/Parsers/Providers.php b/engine/Api/V1/Parsers/Providers.php deleted file mode 100644 index 79fee1f1..00000000 --- a/engine/Api/V1/Parsers/Providers.php +++ /dev/null @@ -1,226 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Parsers; - -/** - * Providers Parser - * - * This class will handle the encoding and decoding from the API requests. - * - * @deprecated - */ -class Providers implements ParsersInterface { - /** - * Encode Response Array - * - * @param array &$response The response to be encoded. - */ - public function encode(array &$response) - { - $encoded_response = [ - 'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL, - 'firstName' => $response['first_name'], - 'lastName' => $response['last_name'], - 'email' => $response['email'], - 'mobile' => $response['mobile_number'], - 'phone' => $response['phone_number'], - 'address' => $response['address'], - 'city' => $response['city'], - 'state' => $response['state'], - 'zip' => $response['zip_code'], - 'notes' => $response['notes'], - 'timezone' => $response['timezone'], - ]; - - if (array_key_exists('services', $response)) - { - $encoded_response['services'] = $response['services']; - } - - if (array_key_exists('settings', $response)) - { - $encoded_response['settings'] = [ - 'username' => $response['settings']['username'], - 'notifications' => filter_var($response['settings']['notifications'], FILTER_VALIDATE_BOOLEAN), - 'calendarView' => $response['settings']['calendar_view'], - '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, - ]; - } - - $response = $encoded_response; - } - - /** - * Decode Request - * - * @param array &$request The request to be decoded. - * @param array $base Optional (null), if provided it will be used as a base array. - */ - public function decode(array &$request, array $base = NULL) - { - $decoded_request = $base ?: []; - - if (array_key_exists('id', $request)) - { - $decoded_request['id'] = $request['id']; - } - - if (array_key_exists('firstName', $request)) - { - $decoded_request['first_name'] = $request['firstName']; - } - - if (array_key_exists('lastName', $request)) - { - $decoded_request['last_name'] = $request['lastName']; - } - - if (array_key_exists('email', $request)) - { - $decoded_request['email'] = $request['email']; - } - - if (array_key_exists('mobile', $request)) - { - $decoded_request['mobile_number'] = $request['mobile']; - } - - if (array_key_exists('phone', $request)) - { - $decoded_request['phone_number'] = $request['phone']; - } - - if (array_key_exists('address', $request)) - { - $decoded_request['address'] = $request['address']; - } - - if (array_key_exists('city', $request)) - { - $decoded_request['city'] = $request['city']; - } - - if (array_key_exists('state', $request)) - { - $decoded_request['state'] = $request['state']; - } - - if (array_key_exists('zip', $request)) - { - $decoded_request['zip_code'] = $request['zip']; - } - - if (array_key_exists('notes', $request)) - { - $decoded_request['notes'] = $request['notes']; - } - - if (array_key_exists('timezone', $request)) - { - $decoded_request['timezone'] = $request['timezone']; - } - - if (array_key_exists('services', $request)) - { - $decoded_request['services'] = $request['services']; - } - - if (array_key_exists('settings', $request)) - { - if (empty($decoded_request['settings'])) - { - $decoded_request['settings'] = []; - } - - if (array_key_exists('username', $request['settings'])) - { - $decoded_request['settings']['username'] = $request['settings']['username']; - } - - if (array_key_exists('password', $request['settings'])) - { - $decoded_request['settings']['password'] = $request['settings']['password']; - } - - if (array_key_exists('calendarView', $request['settings'])) - { - $decoded_request['settings']['calendar_view'] = $request['settings']['calendarView']; - } - - if (array_key_exists('notifications', $request['settings'])) - { - $decoded_request['settings']['notifications'] = filter_var($request['settings']['notifications'], - FILTER_VALIDATE_BOOLEAN); - } - - if (array_key_exists('googleSync', $request['settings'])) - { - $decoded_request['settings']['google_sync'] = filter_var($request['settings']['googleSync'], - FILTER_VALIDATE_BOOLEAN); - } - - if (array_key_exists('googleCalendar', $request['settings'])) - { - $decoded_request['settings']['google_calendar'] = $request['settings']['googleCalendar']; - } - - if (array_key_exists('googleToken', $request['settings'])) - { - $decoded_request['settings']['google_token'] = $request['settings']['googleToken']; - } - - if (array_key_exists('syncFutureDays', $request['settings'])) - { - $decoded_request['settings']['sync_future_days'] = $request['settings']['syncFutureDays']; - } - - if (array_key_exists('syncPastDays', $request['settings'])) - { - $decoded_request['settings']['sync_past_days'] = $request['settings']['syncPastDays']; - } - - if (array_key_exists('workingPlan', $request['settings'])) - { - $decoded_request['settings']['working_plan'] = json_encode($request['settings']['workingPlan']); - } - - if (array_key_exists('workingPlanExceptions', $request['settings'])) - { - $decoded_request['settings']['working_plan_exceptions'] = json_encode($request['settings']['workingPlanExceptions']); - } - } - - $request = $decoded_request; - } -} diff --git a/engine/Api/V1/Parsers/Secretaries.php b/engine/Api/V1/Parsers/Secretaries.php deleted file mode 100644 index 162fe559..00000000 --- a/engine/Api/V1/Parsers/Secretaries.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Parsers; - -/** - * Secretaries Parser - * - * This class will handle the encoding and decoding from the API requests. - * - * @deprecated - */ -class Secretaries implements ParsersInterface { - /** - * Encode Response Array - * - * @param array &$response The response to be encoded. - */ - public function encode(array &$response) - { - $encoded_response = [ - 'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL, - 'firstName' => $response['first_name'], - 'lastName' => $response['last_name'], - 'email' => $response['email'], - 'mobile' => $response['mobile_number'], - 'phone' => $response['phone_number'], - 'address' => $response['address'], - 'city' => $response['city'], - 'state' => $response['state'], - 'zip' => $response['zip_code'], - 'notes' => $response['notes'], - 'providers' => $response['providers'], - 'timezone' => $response['timezone'], - 'settings' => [ - 'username' => $response['settings']['username'], - 'notifications' => filter_var($response['settings']['notifications'], FILTER_VALIDATE_BOOLEAN), - 'calendarView' => $response['settings']['calendar_view'] - ] - ]; - - $response = $encoded_response; - } - - /** - * Decode Request - * - * @param array &$request The request to be decoded. - * @param array $base Optional (null), if provided it will be used as a base array. - */ - public function decode(array &$request, array $base = NULL) - { - $decoded_request = $base ?: []; - - if (array_key_exists('id', $request)) - { - $decoded_request['id'] = $request['id']; - } - - if (array_key_exists('firstName', $request)) - { - $decoded_request['first_name'] = $request['firstName']; - } - - if (array_key_exists('lastName', $request)) - { - $decoded_request['last_name'] = $request['lastName']; - } - - if (array_key_exists('email', $request)) - { - $decoded_request['email'] = $request['email']; - } - - if (array_key_exists('mobile', $request)) - { - $decoded_request['mobile_number'] = $request['mobile']; - } - - if (array_key_exists('phone', $request)) - { - $decoded_request['phone_number'] = $request['phone']; - } - - if (array_key_exists('address', $request)) - { - $decoded_request['address'] = $request['address']; - } - - if (array_key_exists('city', $request)) - { - $decoded_request['city'] = $request['city']; - } - - if (array_key_exists('state', $request)) - { - $decoded_request['state'] = $request['state']; - } - - if (array_key_exists('zip', $request)) - { - $decoded_request['zip_code'] = $request['zip']; - } - - if (array_key_exists('notes', $request)) - { - $decoded_request['notes'] = $request['notes']; - } - - if (array_key_exists('timezone', $request)) - { - $decoded_request['timezone'] = $request['timezone']; - } - - if (array_key_exists('providers', $request)) - { - $decoded_request['providers'] = $request['providers']; - } - - if (array_key_exists('settings', $request)) - { - if (empty($decoded_request['settings'])) - { - $decoded_request['settings'] = []; - } - - if (array_key_exists('username', $request['settings'])) - { - $decoded_request['settings']['username'] = $request['settings']['username']; - } - - if (array_key_exists('password', $request['settings'])) - { - $decoded_request['settings']['password'] = $request['settings']['password']; - } - - if (array_key_exists('notifications', $request['settings'])) - { - $decoded_request['settings']['notifications'] = filter_var($request['settings']['notifications'], - FILTER_VALIDATE_BOOLEAN); - } - - if (array_key_exists('calendarView', $request['settings'])) - { - $decoded_request['settings']['calendar_view'] = $request['settings']['calendarView']; - } - } - - $request = $decoded_request; - } -} diff --git a/engine/Api/V1/Parsers/Services.php b/engine/Api/V1/Parsers/Services.php deleted file mode 100644 index c1de3581..00000000 --- a/engine/Api/V1/Parsers/Services.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Parsers; - -/** - * Services Parser - * - * This class will handle the encoding and decoding from the API requests. - * - * @deprecated - */ -class Services implements ParsersInterface { - /** - * Encode Response Array - * - * @param array &$response The response to be encoded. - */ - public function encode(array &$response) - { - $encoded_response = [ - 'id' => array_key_exists('id', $response) ? (int)$response['id'] : NULL, - 'name' => $response['name'], - 'duration' => (int)$response['duration'], - 'price' => (float)$response['price'], - 'currency' => $response['currency'], - 'description' => $response['description'], - 'location' => $response['location'], - 'availabilitiesType' => $response['availabilities_type'], - 'attendantsNumber' => (int)$response['attendants_number'], - 'categoryId' => $response['id_service_categories'] !== NULL ? (int)$response['id_service_categories'] : NULL - ]; - - $response = $encoded_response; - } - - /** - * Decode Request - * - * @param array &$request The request to be decoded. - * @param array $base Optional (null), if provided it will be used as a base array. - */ - public function decode(array &$request, array $base = NULL) - { - $decoded_request = $base ?: []; - - if (array_key_exists('id', $request)) - { - $decoded_request['id'] = $request['id']; - } - - if (array_key_exists('name', $request)) - { - $decoded_request['name'] = $request['name']; - } - - if (array_key_exists('duration', $request)) - { - $decoded_request['duration'] = $request['duration']; - } - - if (array_key_exists('price', $request)) - { - $decoded_request['price'] = $request['price']; - } - - if (array_key_exists('currency', $request)) - { - $decoded_request['currency'] = $request['currency']; - } - - if (array_key_exists('description', $request)) - { - $decoded_request['description'] = $request['description']; - } - - if (array_key_exists('location', $request)) - { - $decoded_request['location'] = $request['location']; - } - - if (array_key_exists('availabilitiesType', $request)) - { - $decoded_request['availabilities_type'] = $request['availabilitiesType']; - } - - if (array_key_exists('attendantsNumber', $request)) - { - $decoded_request['attendants_number'] = $request['attendantsNumber']; - } - - if (array_key_exists('categoryId', $request)) - { - $decoded_request['id_service_categories'] = $request['categoryId']; - } - - $request = $decoded_request; - } -} diff --git a/engine/Api/V1/Parsers/Settings.php b/engine/Api/V1/Parsers/Settings.php deleted file mode 100644 index 591c5842..00000000 --- a/engine/Api/V1/Parsers/Settings.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Parsers; - -/** - * Settings Parser - * - * This class will handle the encoding and decoding from the API requests. - * - * @deprecated - */ -class Settings implements ParsersInterface { - /** - * Encode Response Array - * - * @param array &$response The response to be encoded. - */ - public function encode(array &$response) - { - $encoded_response = [ - 'name' => $response['name'], - 'value' => $response['value'] - ]; - - $response = $encoded_response; - } - - /** - * Decode Request - * - * @param array &$request The request to be decoded. - * @param array $base Optional (null), if provided it will be used as a base array. - */ - public function decode(array &$request, array $base = NULL) - { - $decoded_request = $base ?: []; - - if (array_key_exists('name', $request)) - { - $decoded_request['name'] = $request['name']; - } - - if (array_key_exists('value', $request)) - { - $decoded_request['value'] = $request['value']; - } - - $request = $decoded_request; - } -} diff --git a/engine/Api/V1/Parsers/Unavailabilities.php b/engine/Api/V1/Parsers/Unavailabilities.php deleted file mode 100644 index 40b8b898..00000000 --- a/engine/Api/V1/Parsers/Unavailabilities.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Parsers; - -/** - * Unavailabilities Parser - * - * This class will handle the encoding and decoding from the API requests. - * - * @deprecated - */ -class Unavailabilities implements ParsersInterface { - /** - * Encode Response Array - * - * @param array &$response The response to be encoded. - */ - public function encode(array &$response) - { - $encoded_response = [ - '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' => 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; - } - - /** - * Decode Request - * - * @param array &$request The request to be decoded. - * @param array $base Optional (null), if provided it will be used as a base array. - */ - public function decode(array &$request, array $base = NULL) - { - $decodedRequest = $base ?: []; - - if (array_key_exists('id', $request)) - { - $decodedRequest['id'] = $request['id']; - } - - if (array_key_exists('book', $request)) - { - $decodedRequest['book_datetime'] = $request['book']; - } - - if (array_key_exists('start', $request)) - { - $decodedRequest['start_datetime'] = $request['start']; - } - - if (array_key_exists('end', $request)) - { - $decodedRequest['end_datetime'] = $request['end']; - } - - if (array_key_exists('notes', $request)) - { - $decodedRequest['notes'] = $request['notes']; - } - - if (array_key_exists('providerId', $request)) - { - $decodedRequest['id_users_provider'] = $request['providerId']; - } - - if (array_key_exists('googleCalendarId', $request)) - { - $decodedRequest['id_google_calendar'] = $request['googleCalendarId']; - } - - $decodedRequest['is_unavailable'] = TRUE; - - $request = $decodedRequest; - } -} diff --git a/engine/Api/V1/Processors/Filter.php b/engine/Api/V1/Processors/Filter.php deleted file mode 100644 index 4580d92b..00000000 --- a/engine/Api/V1/Processors/Filter.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Processors; - -/** - * Filter Processor - * - * This class will handle custom filters upon the response array. In some specific cases it might be - * easier to apply some custom filtering in order to get the required results. - * - * @todo Implement this processor class. - * - * @deprecated - */ -class Filter implements ProcessorsInterface { - /** - * Process Response Array - * - * @param array &$response The response array to be processed. - */ - public static function process(array &$response) - { - // Not implemented yet. - } -} diff --git a/engine/Api/V1/Processors/Minimize.php b/engine/Api/V1/Processors/Minimize.php deleted file mode 100644 index 3292ea36..00000000 --- a/engine/Api/V1/Processors/Minimize.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Processors; - -/** - * Minimize Processor - * - * This processor will check for the "fields" GET parameters and provide only the required fields in - * every response entry. This might come in handy when the client needs specific information and not - * the whole objects. - * - * Make sure that the response parameter is a sequential array and not a single entry by the time this - * processor is executed. - * - * @deprecated - */ -class Minimize implements ProcessorsInterface { - /** - * Process Response Array - * - * Example: - * http://ea-installation.com/api/v1/appointments?fields=id,book,start,end - * - * - * @param array &$response The response array to be processed. - */ - public static function process(array &$response) - { - if ( ! isset($_GET['fields']) || empty($response)) - { - return; - } - - $fields = explode(',', $_GET['fields']); - - $temporary_response = []; - - foreach ($response as &$entry) - { - $temporary_entry = []; - - foreach ($fields as $field) - { - $field = trim($field); - if (isset($entry[$field])) - { - $temporary_entry[$field] = $entry[$field]; - } - } - - $temporary_response[] = $temporary_entry; - } - - $response = $temporary_response; - } -} diff --git a/engine/Api/V1/Processors/Paginate.php b/engine/Api/V1/Processors/Paginate.php deleted file mode 100644 index a1b02775..00000000 --- a/engine/Api/V1/Processors/Paginate.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Processors; - -/** - * Paginate Processor - * - * This class will handle the pagination GET parameters ("page", "length"). The "page" parameter - * is required in order for the pagination to work. The "length" is optional and the default value - * is 20 entries per page. - * - * Make sure that the response parameter is a sequential array and not a single entry by the time this - * processor is executed. - * - * @deprecated - */ -class Paginate implements ProcessorsInterface { - /** - * Process Response Array - * - * Example: - * http://example.org/api/v1/appointments?page=3&length=30 - * - * @param array &$response The response array to be processed. - */ - public static function process(array &$response) - { - if ( ! isset($_GET['page']) || empty($response)) - { - return; - } - - $page = (int)$_GET['page']; - $length = isset($_GET['length']) ? (int)$_GET['length'] : 20; - - $chunks = array_chunk($response, $length); - - $response = isset($chunks[$page - 1]) ? $chunks[$page - 1] : []; - } -} diff --git a/engine/Api/V1/Processors/ProcessorsInterface.php b/engine/Api/V1/Processors/ProcessorsInterface.php deleted file mode 100644 index 4cb34e8a..00000000 --- a/engine/Api/V1/Processors/ProcessorsInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Processors; - -/** - * Interface ProcessorsInterface - * - * @deprecated - * - * @package EA\Engine\Api\V1\Processors - */ -interface ProcessorsInterface { - public static function process(array &$response); -} diff --git a/engine/Api/V1/Processors/Search.php b/engine/Api/V1/Processors/Search.php deleted file mode 100644 index 2ec4cb89..00000000 --- a/engine/Api/V1/Processors/Search.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Processors; - -/** - * Search Processor - * - * This class will search the response with the "q" GET parameter and only provide the entries - * that match the keyword. Make sure that the response parameter is a sequential array and not - * a single entry by the time this processor is executed. - * - * @deprecated - */ -class Search implements ProcessorsInterface { - /** - * Process Response Array - * - * @param array &$response The response array to be processed. - */ - public static function process(array &$response) - { - if ( ! isset($_GET['q']) || empty($response)) - { - return; - } - - $searched_response = []; - $keyword = (string)$_GET['q']; - - foreach ($response as $entry) - { - if (self::recursive_array_search($entry, $keyword) !== FALSE) - { - $searched_response[] = $entry; - } - } - - $response = $searched_response; - } - - /** - * Recursive Array Search - * - * @param array $haystack Array to search in. - * @param string $needle Keyword to be searched. - * - * @return int|bool Returns the index of the search occurrence or false it nothing was found. - */ - protected static function recursive_array_search(array $haystack, $needle) - { - foreach ($haystack as $key => $value) - { - $currentKey = $key; - - if (is_array($value) && self::recursive_array_search($value, $needle) !== FALSE) - { - return $currentKey; - } - - if (is_string($value) && stripos($value, $needle) !== FALSE) - { - return $currentKey; - } - } - - return FALSE; - } -} diff --git a/engine/Api/V1/Processors/Sort.php b/engine/Api/V1/Processors/Sort.php deleted file mode 100644 index 96605d60..00000000 --- a/engine/Api/V1/Processors/Sort.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1\Processors; - -/** - * Sort Processor - * - * This class will sort the response array with the provided GET parameters. Make sure that the - * response parameter is a sequential array and not a single entry by the time this processor is - * executed. - * - * @deprecated - */ -class Sort implements ProcessorsInterface { - /** - * Supports up to 3 columns for sorting. - * - * Example: - * http://ea-installation.com/api/v1/appointments?sort=-start,+notes,-hash - * - * @param array &$response The response array to be processed. - */ - public static function process(array &$response) - { - if ( ! isset($_GET['sort']) || empty($response)) - { - return; - } - - $sort = explode(',', (string)$_GET['sort']); - - $sort_direction1 = substr($sort[0], 0, 1) === '-' ? SORT_DESC : SORT_ASC; - - if (isset($sort[1])) - { - $sort_direction2 = substr($sort[1], 0, 1) === '-' ? SORT_DESC : SORT_ASC; - } - else - { - $sort_direction2 = NULL; - } - - if (isset($sort[2])) - { - $sort_direction3 = substr($sort[2], 0, 1) === '-' ? SORT_DESC : SORT_ASC; - } - else - { - $sort_direction3 = NULL; - } - - foreach ($response as $index => $entry) - { - $sort_order1[$index] = $entry[substr($sort[0], 1)]; - - if ($sort_direction2) - { - $sort_order2[$index] = $entry[substr($sort[1], 1)]; - } - - if ($sort_direction3) - { - $sort_order3[$index] = $entry[substr($sort[2], 1)]; - } - } - - $arguments = [ - &$sort_order1, - &$sort_direction1 - ]; - - if ($sort_direction2) - { - $arguments[] = $sort_order2; - $arguments[] = $sort_direction2; - } - - if ($sort_direction3) - { - $arguments[] = $sort_order3; - $arguments[] = $sort_direction3; - } - - $arguments[] = &$response; - - call_user_func_array('array_multisort', $arguments); - } -} diff --git a/engine/Api/V1/Request.php b/engine/Api/V1/Request.php deleted file mode 100644 index 47c766f2..00000000 --- a/engine/Api/V1/Request.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1; - -/** - * Request Class - * - * This class handles the common request handling before the data are manipulated and - * returned back with the Response class. - * - * @deprecated - */ -class Request { - /** - * Get request body as an associative array. - * - * @return array - */ - public function get_body() - { - return json_decode(file_get_contents('php://input'), TRUE); - } -} diff --git a/engine/Api/V1/Response.php b/engine/Api/V1/Response.php deleted file mode 100644 index 49f1cb4d..00000000 --- a/engine/Api/V1/Response.php +++ /dev/null @@ -1,154 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1; - -use EA\Engine\Types\NonEmptyText; - -/** - * API v1 Response - * - * Use chain-calls of the class methods to easily manipulate the provided response array. This class will - * use directly the provided GET parameters for easier manipulation. - * - * Example: - * $parser = new \EA\Engine\Api\V1\Parsers\Appointments; - * $response = new \EA\Engine\Api\V1\Response($data); - * $response->format($parser)->search()->sort()->paginate()->minimize()->output(); - * - * @deprecated - */ -class Response { - /** - * Contains the response information. - * - * @var array - */ - protected $response; - - /** - * Class Constructor - * - * @param array $response Provide unfiltered data to be processed as an array. - */ - public function __construct(array $response) - { - $this->response = $response; - } - - /** - * Encode the response entries to the API compatible structure. - * - * @param Parsers\ParsersInterface $parser Provide the corresponding parser class. - * - * @return \EA\Engine\Api\V1\Response - */ - public function encode(Parsers\ParsersInterface $parser) - { - foreach ($this->response as &$entry) - { - $parser->encode($entry); - } - - return $this; - } - - /** - * Perform a response search. - * - * @return \EA\Engine\Api\V1\Response - */ - public function search() - { - Processors\Search::process($this->response); - - return $this; - } - - /** - * Perform a response sort. - * - * @return \EA\Engine\Api\V1\Response - */ - public function sort() - { - Processors\Sort::process($this->response); - - return $this; - } - - /** - * Perform a response paginate. - * - * @return \EA\Engine\Api\V1\Response - */ - public function paginate() - { - Processors\Paginate::process($this->response); - - return $this; - } - - /** - * Perform a response minimize. - * - * @return \EA\Engine\Api\V1\Response - */ - public function minimize() - { - Processors\Minimize::process($this->response); - - return $this; - } - - /** - * Return a single entry instead of an array of entries. - * - * This is useful whenever the client requests only a single entry. Make sure that you call this method - * right before the output() in order to avoid side-effects with the other processor methods of this class. - * - * @param int $id Provide the ID value of the request UI and if is not null the response will be - * converted into an associative array. - * - * @return \EA\Engine\Api\V1\Response - */ - public function singleEntry($id) - { - if ($id !== NULL) - { - $this->response = array_shift($this->response); - } - - return $this; - } - - /** - * Output the response as a JSON with the provided status header. - * - * @param \EA\Engine\Types\NonEmptyText $status Optional (null), if provided it must contain the status - * header value. Default string: '200 OK'. - * - * @return \EA\Engine\Api\V1\Response - */ - public function output(NonEmptyText $status = NULL) - { - $header = $status ? $status->get() : '200 OK'; - - header('HTTP/1.0 ' . $header); - header('Content-Type: application/json'); - - echo json_encode($this->response, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); - - return $this; - } -} diff --git a/engine/Notifications/Email.php b/engine/Notifications/Email.php deleted file mode 100755 index 0612f46c..00000000 --- a/engine/Notifications/Email.php +++ /dev/null @@ -1,334 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Notifications; - -use DateTime; -use DateTimeZone; -use EA\Engine\Types\Email as EmailAddress; -use EA\Engine\Types\NonEmptyText; -use EA\Engine\Types\Text; -use EA\Engine\Types\Url; -use EA_Controller; -use Exception; -use PHPMailer\PHPMailer\PHPMailer; -use RuntimeException; - -/** - * Email Notifications Class - * - * This library handles all the notification email deliveries on the system. - * - * Important: The email configuration settings are located at: /application/config/email.php - * - * @deprecated - */ -class Email { - /** - * Framework Instance - * - * @var EA_Controller - */ - protected $CI; - - /** - * Contains email configuration. - * - * @var array - */ - protected $config; - - /** - * Class Constructor - * - * @param \CI_Controller $CI - * @param array $config Contains the email configuration to be used. - */ - public function __construct(\CI_Controller $CI, array $config) - { - $this->CI = $CI; - $this->config = $config; - } - - /** - * Send an email with the appointment details. - * - * This email template also needs an email title and an email text in order to complete - * the appointment details. - * - * @param array $appointment Contains the appointment data. - * @param array $provider Contains the provider data. - * @param array $service Contains the service data. - * @param array $customer Contains the customer data. - * @param array $settings Contains settings of the company. At the time the "company_name", "company_link" and - * "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 $message The email message may vary depending the receiver. - * @param \EA\Engine\Types\Url $appointment_link_address This link is going to enable the receiver to make changes - * to the appointment record. - * @param \EA\Engine\Types\Email $recipient_email The recipient email address. - * @param \EA\Engine\Types\Text $ics_stream Stream contents of the ICS file. - * @param string|null $timezone Custom timezone for the notification. - * - * @throws \PHPMailer\PHPMailer\Exception - */ - public function send_appointment_details( - array $appointment, - array $provider, - array $service, - array $customer, - array $settings, - Text $title, - Text $message, - Url $appointment_link_address, - EmailAddress $recipient_email, - Text $ics_stream, - $timezone = NULL - ) - { - $timezones = $this->CI->timezones->to_array(); - - switch ($settings['date_format']) - { - case 'DMY': - $date_format = 'd/m/Y'; - break; - case 'MDY': - $date_format = 'm/d/Y'; - break; - case 'YMD': - $date_format = 'Y/m/d'; - break; - default: - throw new Exception('Invalid date_format value: ' . $settings['date_format']); - } - - switch ($settings['time_format']) - { - case 'military': - $time_format = 'H:i'; - break; - case 'regular': - $time_format = 'g:i a'; - break; - default: - throw new Exception('Invalid time_format value: ' . $settings['time_format']); - } - - $appointment_timezone = new DateTimeZone($provider['timezone']); - $appointment_start = new DateTime($appointment['start_datetime'], $appointment_timezone); - $appointment_end = new DateTime($appointment['end_datetime'], $appointment_timezone); - - if ($timezone && $timezone !== $provider['timezone']) - { - $appointment_timezone = new DateTimeZone($timezone); - $appointment_start->setTimezone($appointment_timezone); - $appointment_end->setTimezone($appointment_timezone); - } - - $html = $this->CI->load->view('emails/appointment_details', [ - 'email_title' => $title->get(), - 'email_message' => $message->get(), - 'appointment_service' => $service['name'], - 'appointment_provider' => $provider['first_name'] . ' ' . $provider['last_name'], - 'appointment_start_date' => $appointment_start->format($date_format . ' ' . $time_format), - 'appointment_end_date' => $appointment_end->format($date_format . ' ' . $time_format), - 'appointment_timezone' => $timezones[empty($timezone) ? $provider['timezone'] : $timezone], - 'appointment_link' => $appointment_link_address->get(), - 'company_link' => $settings['company_link'], - 'company_name' => $settings['company_name'], - 'customer_name' => $customer['first_name'] . ' ' . $customer['last_name'], - 'customer_email' => $customer['email'], - 'customer_phone' => $customer['phone_number'], - 'customer_address' => $customer['address'], - ], TRUE); - - $mailer = $this->create_mailer(); - $mailer->From = $settings['company_email']; - $mailer->FromName = $settings['company_name']; - $mailer->AddAddress($recipient_email->get()); - $mailer->Subject = $title->get(); - $mailer->Body = $html; - $mailer->addStringAttachment($ics_stream->get(), 'invitation.ics'); - - if ( ! $mailer->Send()) - { - throw new RuntimeException('Email could not been sent. Mailer Error (Line ' . __LINE__ . '): ' - . $mailer->ErrorInfo); - } - } - - /** - * Send an email notification to both provider and customer on appointment removal. - * - * Whenever an appointment is cancelled or removed, both the provider and customer - * need to be informed. This method sends the same email twice. - * - * IMPORTANT! This method's arguments should be taken - * from database before the appointment record is deleted. - * - * @param array $appointment The record data of the removed appointment. - * @param array $provider The record data of the appointment provider. - * @param array $service The record data of the appointment service. - * @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 - * the following values: "company_link", "company_name", "company_email". - * @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 string|null $timezone Custom timezone. - * - * @throws \PHPMailer\PHPMailer\Exception - */ - public function send_delete_appointment( - array $appointment, - array $provider, - array $service, - array $customer, - array $settings, - EmailAddress $recipient_email, - Text $reason, - $timezone = NULL - ) - { - $timezones = $this->CI->timezones->to_array(); - - switch ($settings['date_format']) - { - case 'DMY': - $date_format = 'd/m/Y'; - break; - case 'MDY': - $date_format = 'm/d/Y'; - break; - case 'YMD': - $date_format = 'Y/m/d'; - break; - default: - throw new Exception('Invalid date_format value: ' . $settings['date_format']); - } - - switch ($settings['time_format']) - { - case 'military': - $time_format = 'H:i'; - break; - case 'regular': - $time_format = 'g:i a'; - break; - default: - throw new Exception('Invalid time_format value: ' . $settings['time_format']); - } - - $appointment_timezone = new DateTimeZone($provider['timezone']); - $appointment_start = new DateTime($appointment['start_datetime'], $appointment_timezone); - - if ($timezone && $timezone !== $provider['timezone']) - { - $appointment_timezone = new DateTimeZone($timezone); - $appointment_start->setTimezone($appointment_timezone); - } - - $html = $this->CI->load->view('emails/delete_appointment', [ - 'appointment_service' => $service['name'], - 'appointment_provider' => $provider['first_name'] . ' ' . $provider['last_name'], - 'appointment_date' => $appointment_start->format($date_format . ' ' . $time_format), - 'appointment_duration' => $service['duration'] . ' ' . lang('minutes'), - 'appointment_timezone' => $timezones[empty($timezone) ? $provider['timezone'] : $timezone], - 'company_link' => $settings['company_link'], - 'company_name' => $settings['company_name'], - 'customer_name' => $customer['first_name'] . ' ' . $customer['last_name'], - 'customer_email' => $customer['email'], - 'customer_phone' => $customer['phone_number'], - 'customer_address' => $customer['address'], - 'reason' => $reason->get(), - ], TRUE); - - $mailer = $this->create_mailer(); - - // Send email to recipient. - $mailer->From = $settings['company_email']; - $mailer->FromName = $settings['company_name']; - $mailer->AddAddress($recipient_email->get()); // "Name" argument crushes the phpmailer class. - $mailer->Subject = lang('appointment_cancelled_title'); - $mailer->Body = $html; - - if ( ! $mailer->Send()) - { - throw new RuntimeException('Email could not been sent. Mailer Error (Line ' . __LINE__ . '): ' - . $mailer->ErrorInfo); - } - } - - /** - * This method sends an email with the new password of a user. - * - * @param \EA\Engine\Types\NonEmptyText $password Contains the new password. - * @param \EA\Engine\Types\Email $recipientEmail The receiver's email address. - * @param array $settings The company settings to be included in the email. - * - * @throws \PHPMailer\PHPMailer\Exception - */ - public function send_password(NonEmptyText $password, EmailAddress $recipientEmail, array $settings) - { - $html = $this->CI->load->view('emails/new_password', [ - 'email_title' => lang('new_account_password'), - 'email_message' => str_replace('$password', '' . $password->get() . '', lang('new_password_is')), - 'company_name' => $settings['company_name'], - 'company_email' => $settings['company_email'], - 'company_link' => $settings['company_link'], - ], TRUE); - - $mailer = $this->create_mailer(); - - $mailer->From = $settings['company_email']; - $mailer->FromName = $settings['company_name']; - $mailer->AddAddress($recipientEmail->get()); // "Name" argument crushes the phpmailer class. - $mailer->Subject = lang('new_account_password'); - $mailer->Body = $html; - - if ( ! $mailer->Send()) - { - throw new RuntimeException('Email could not been sent. Mailer Error (Line ' . __LINE__ . '): ' - . $mailer->ErrorInfo); - } - } - - /** - * Create PHP Mailer Instance - * - * @return PHPMailer - */ - protected function create_mailer() - { - $mailer = new PHPMailer(); - - if ($this->config['protocol'] === 'smtp') - { - $mailer->isSMTP(); - $mailer->SMTPDebug = $this->config['smtp_debug']; - $mailer->Host = $this->config['smtp_host']; - $mailer->SMTPAuth = $this->config['smtp_auth']; - $mailer->Username = $this->config['smtp_user']; - $mailer->Password = $this->config['smtp_pass']; - $mailer->SMTPSecure = $this->config['smtp_crypto']; - $mailer->Port = $this->config['smtp_port']; - $mailer->Sender = $settings['company_email']; - $mailer->SetFrom($settings['company_email'], $settings['company_name'], FALSE); - } - - $mailer->IsHTML($this->config['mailtype'] === 'html'); - $mailer->CharSet = $this->config['charset']; - - return $mailer; - } -} diff --git a/engine/Types/Boolean.php b/engine/Types/Boolean.php deleted file mode 100644 index f8ecc672..00000000 --- a/engine/Types/Boolean.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -/** - * Class Boolean - * - * @deprecated - * - * @package EA\Engine\Types - */ -class Boolean extends Type { - /** - * @param mixed $value - * @return bool - */ - protected function validate($value) - { - return is_bool($value); - } -} diff --git a/engine/Types/Decimal.php b/engine/Types/Decimal.php deleted file mode 100644 index 1c7aa465..00000000 --- a/engine/Types/Decimal.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - - -/** - * Class Decimal - * - * @deprecated - * - * @package EA\Engine\Types - */ -class Decimal extends Type { - /** - * @param mixed $value - * @return bool - */ - protected function validate($value) - { - return is_float($value); - } -} diff --git a/engine/Types/Email.php b/engine/Types/Email.php deleted file mode 100644 index ed1b842d..00000000 --- a/engine/Types/Email.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -/** - * Class Email - * - * @deprecated - * - * @package EA\Engine\Types - */ -class Email extends NonEmptyText { - /** - * @param mixed $value - * @return bool - */ - protected function validate($value) - { - return parent::validate($value) && filter_var($value, FILTER_VALIDATE_EMAIL); - } -} diff --git a/engine/Types/Integer.php b/engine/Types/Integer.php deleted file mode 100644 index e1c1a4c7..00000000 --- a/engine/Types/Integer.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -/** - * Class Integer - * - * @deprecated - * - * @package EA\Engine\Types - */ -class Integer extends Type { - /** - * @param mixed $value - * @return bool - */ - protected function validate($value) - { - return is_numeric($value) && ! is_float($value); - } -} diff --git a/engine/Types/NonEmptyText.php b/engine/Types/NonEmptyText.php deleted file mode 100644 index bcbb117e..00000000 --- a/engine/Types/NonEmptyText.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -/** - * Class NonEmptyText - * - * @deprecated - * - * @package EA\Engine\Types - */ -class NonEmptyText extends Text { - /** - * @param mixed $value - * @return bool - */ - protected function validate($value) - { - return parent::validate($value) && $value !== ''; - } -} diff --git a/engine/Types/Text.php b/engine/Types/Text.php deleted file mode 100644 index 807e34a2..00000000 --- a/engine/Types/Text.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -/** - * Class Text - * - * @deprecated - * - * @package EA\Engine\Types - */ -class Text extends Type { - /** - * @param mixed $value - * @return bool - */ - protected function validate($value) - { - return is_string($value); - } -} diff --git a/engine/Types/Type.php b/engine/Types/Type.php deleted file mode 100644 index ca99d6e6..00000000 --- a/engine/Types/Type.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -/** - * Abstract Type Class - * - * @deprecated - * - * This class needs to be extended by the type classes which must implement the validation logic. - */ -abstract class Type { - /** - * Class Constructor - * - * @param mixed $value The type value to be validated. - */ - public function __construct($value) - { - if ( ! $this->validate($value)) - { - throw new \InvalidArgumentException(__CLASS__ . ': Invalid argument value provided (' . $value . ')'); - } - - $this->value = $value; - } - - /** - * Get the type value. - * - * @return mixed - */ - public function get() - { - return $this->value; - } - - /** - * Implement the validation logic in the children classes. - * - * @param mixed $value The value to be validated. - * - * @return bool Returns whether the value is valid or not. - */ - abstract protected function validate($value); -} diff --git a/engine/Types/UnsignedInteger.php b/engine/Types/UnsignedInteger.php deleted file mode 100644 index e103bbfe..00000000 --- a/engine/Types/UnsignedInteger.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -/** - * Class UnsignedInteger - * - * @deprecated - * - * @package EA\Engine\Types - */ -class UnsignedInteger extends Integer { - /** - * @param mixed $value - * @return bool - */ - protected function validate($value) - { - return parent::validate($value) && $value > -1; - } -} diff --git a/engine/Types/Url.php b/engine/Types/Url.php deleted file mode 100644 index 27ed35ba..00000000 --- a/engine/Types/Url.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -/** - * Class Url - * - * @deprecated - * - * @package EA\Engine\Types - */ -class Url extends NonEmptyText { - /** - * @param mixed $value - * @return bool - */ - protected function validate($value) - { - return parent::validate($value) && filter_var($value, FILTER_VALIDATE_URL); - } -} diff --git a/engine/index.html b/engine/index.html deleted file mode 100644 index 423d9d58..00000000 --- a/engine/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - 403 Forbidden - - - -

Directory access is forbidden.

- - - diff --git a/tests/engine/Api/V1/AuthorizationTest.php b/tests/engine/Api/V1/AuthorizationTest.php deleted file mode 100644 index 45e2f630..00000000 --- a/tests/engine/Api/V1/AuthorizationTest.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1; - -use EA\Engine\Types\NonEmptyText; -use PHPUnit\Framework\TestCase; - -class AuthorizationTest extends TestCase { - public function testBasicMethodPerformsBasicAuthentication() - { - $this->markTestIncomplete(); - } - - public function testBasicMethodReturnsForbiddenResponse() - { - $this->markTestIncomplete(); - } -} diff --git a/tests/engine/Api/V1/FilterTest.php b/tests/engine/Api/V1/FilterTest.php deleted file mode 100644 index d2e3d270..00000000 --- a/tests/engine/Api/V1/FilterTest.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1; - -use PHPUnit\Framework\TestCase; - -class FilterTest extends TestCase { - public function test() - { - $this->markTestIncomplete(); - } -} diff --git a/tests/engine/Api/V1/MinimizeTest.php b/tests/engine/Api/V1/MinimizeTest.php deleted file mode 100644 index ccf1bf45..00000000 --- a/tests/engine/Api/V1/MinimizeTest.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1; - -use PHPUnit\Framework\TestCase; - -class MinimizeTest extends TestCase { - public function test() - { - $this->markTestIncomplete(); - } -} diff --git a/tests/engine/Api/V1/PaginationTest.php b/tests/engine/Api/V1/PaginationTest.php deleted file mode 100644 index 311532d2..00000000 --- a/tests/engine/Api/V1/PaginationTest.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1; - -use PHPUnit\Framework\TestCase; - -class PaginationTest extends TestCase { - public function test() - { - $this->markTestIncomplete(); - } -} diff --git a/tests/engine/Api/V1/ResponseTest.php b/tests/engine/Api/V1/ResponseTest.php deleted file mode 100644 index 08f2868e..00000000 --- a/tests/engine/Api/V1/ResponseTest.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1; - -use PHPUnit\Framework\TestCase; - -class ResponseTest extends TestCase { - public function test() - { - $this->markTestIncomplete(); - } -} diff --git a/tests/engine/Api/V1/SearchTest.php b/tests/engine/Api/V1/SearchTest.php deleted file mode 100644 index ad07b9ef..00000000 --- a/tests/engine/Api/V1/SearchTest.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1; - -use PHPUnit\Framework\TestCase; - -class SearchTest extends TestCase { - public function test() - { - $this->markTestIncomplete(); - } -} diff --git a/tests/engine/Api/V1/SortTest.php b/tests/engine/Api/V1/SortTest.php deleted file mode 100644 index fddb7c24..00000000 --- a/tests/engine/Api/V1/SortTest.php +++ /dev/null @@ -1,23 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Api\V1; - -use PHPUnit\Framework\TestCase; - -class SortTest extends TestCase { - public function test() - { - $this->markTestIncomplete(); - } -} diff --git a/tests/engine/Api/V1/fixtures/admin.json b/tests/engine/Api/V1/fixtures/admin.json deleted file mode 100644 index 5366edea..00000000 --- a/tests/engine/Api/V1/fixtures/admin.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": 143, - "firstname": "Chris", - "lastname": "Doe", - "email": "chris@doe.com", - "mobile": "012345679-0", - "phone": "0123456789-1", - "address": "Some Str. 123", - "city": "Some City", - "state": "Some City", - "zip": "12345", - "notes": "Test admin notes.", - "settings": { - "username": "chrisdoe", - "notifications": true - } -} diff --git a/tests/engine/Api/V1/fixtures/appointment.json b/tests/engine/Api/V1/fixtures/appointment.json deleted file mode 100644 index d26fb9d6..00000000 --- a/tests/engine/Api/V1/fixtures/appointment.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": 1, - "book": "2016-07-08 12:57:00", - "start": "2016-07-08 18:00:00", - "end": "2016-07-08 18:30:00", - "hash": "asdf809a8sdf987a9d8f7", - "notes": "These are some test notes.", - "customerId": 56, - "providerId": 4, - "serviceId": 7, - "googleCalendarId": 134 -} diff --git a/tests/engine/Api/V1/fixtures/category.json b/tests/engine/Api/V1/fixtures/category.json deleted file mode 100644 index 1ba27417..00000000 --- a/tests/engine/Api/V1/fixtures/category.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "id": 5, - "name": "Test Category", - "description": "This category includes test services" -} diff --git a/tests/engine/Api/V1/fixtures/customer.json b/tests/engine/Api/V1/fixtures/customer.json deleted file mode 100644 index 7b8432d9..00000000 --- a/tests/engine/Api/V1/fixtures/customer.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "id": 97, - "firstname": "John", - "lastname": "Doe", - "email": "john@doe.com", - "phone": "0123456789", - "address": "Some Str. 123", - "city": "Some City", - "zip": "12345", - "notes": "Test customer notes." -} diff --git a/tests/engine/Api/V1/fixtures/provider.json b/tests/engine/Api/V1/fixtures/provider.json deleted file mode 100644 index 47f3e7c7..00000000 --- a/tests/engine/Api/V1/fixtures/provider.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "id": 143, - "firstname": "Chloe", - "lastname": "Doe", - "email": "chloe@doe.com", - "mobile": "012345679-0", - "phone": "0123456789-1", - "address": "Some Str. 123", - "city": "Some City", - "state": "Some State", - "zip": "12345", - "notes": "Test provider notes.", - "services": [ - 1, - 5, - 9 - ], - "settings": { - "username": "chloedoe", - "notifications": true, - "googleSync": true, - "googleCalendar": "calendar-id", - "googleToken": "23897dfasdf7a98gas98d9", - "syncFutureDays": 10, - "syncPastDays": 10, - "workingPlan": { - "monday": { - "start": "09:00", - "end": "18:00", - "breaks": [ - { - "start": "14:30", - "end": "15:00" - } - ] - }, - "tuesday": { - "start": "09:00", - "end": "18:00", - "breaks": [ - { - "start": "14:30", - "end": "15:00" - } - ] - }, - "wednesday": null, - "thursday": { - "start": "09:00", - "end": "18:00", - "breaks": [ - { - "start": "14:30", - "end": "15:00" - } - ] - }, - "friday": { - "start": "09:00", - "end": "18:00", - "breaks": [ - { - "start": "14:30", - "end": "15:00" - } - ] - }, - "saturday": null, - "sunday": null - } - } -} diff --git a/tests/engine/Api/V1/fixtures/secretary.json b/tests/engine/Api/V1/fixtures/secretary.json deleted file mode 100644 index 67f54b66..00000000 --- a/tests/engine/Api/V1/fixtures/secretary.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "id": 143, - "firstname": "Chris", - "lastname": "Doe", - "email": "chris@doe.com", - "mobile": "012345679-0", - "phone": "0123456789-1", - "address": "Some Str. 123", - "city": "Some City", - "zip": "12345", - "notes": "Test secretary notes.", - "providers": [ - 53, - 17 - ], - "settings": { - "username": "chrisdoe", - "notifications": true - } -} diff --git a/tests/engine/Api/V1/fixtures/service.json b/tests/engine/Api/V1/fixtures/service.json deleted file mode 100644 index 3d37b9dd..00000000 --- a/tests/engine/Api/V1/fixtures/service.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": 74, - "name": "Male Haircut", - "duration": 60, - "price": 10.00, - "currency": "Euro", - "description": "Male haircut trends.", - "categoryId": null -} diff --git a/tests/engine/Api/V1/fixtures/setting.json b/tests/engine/Api/V1/fixtures/setting.json deleted file mode 100644 index 8b2ea618..00000000 --- a/tests/engine/Api/V1/fixtures/setting.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "book_advance_timeout", - "value": "100" -} diff --git a/tests/engine/Api/V1/fixtures/unavailability.json b/tests/engine/Api/V1/fixtures/unavailability.json deleted file mode 100644 index 3bb5284f..00000000 --- a/tests/engine/Api/V1/fixtures/unavailability.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": 1, - "book": "2016-07-08 12:57:00", - "start": "2016-07-08 18:00:00", - "end": "2016-07-08 18:30:00", - "notes": "These are some test notes.", - "providerId": 4, - "googleCalendarId": 474 -} diff --git a/tests/engine/Types/BooleanTest.php b/tests/engine/Types/BooleanTest.php deleted file mode 100644 index ddad070e..00000000 --- a/tests/engine/Types/BooleanTest.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -use PHPUnit\Framework\TestCase; - -class BooleanTest extends TestCase { - public function testBoolType() - { - $type = new Boolean(TRUE); - $this->assertEquals(TRUE, $type->get()); - } - - public function testBoolTypeThrowsExceptionWithInvalidValue() - { - $this->expectException(\InvalidArgumentException::class); - new Boolean(NULL); - } -} diff --git a/tests/engine/Types/DecimalTest.php b/tests/engine/Types/DecimalTest.php deleted file mode 100644 index aedc4925..00000000 --- a/tests/engine/Types/DecimalTest.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -use PHPUnit\Framework\TestCase; - -class DecimalTest extends TestCase { - public function testFloatType() - { - $type = new Decimal(100.00); - $this->assertEquals(100.00, $type->get()); - } - - public function testFloatTypeThrowsExceptionWithInvalidValue() - { - $this->expectException(\InvalidArgumentException::class); - new Decimal(NULL); - } -} diff --git a/tests/engine/Types/EmailTest.php b/tests/engine/Types/EmailTest.php deleted file mode 100644 index 5672f078..00000000 --- a/tests/engine/Types/EmailTest.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -use PHPUnit\Framework\TestCase; - -class EmailTest extends TestCase { - public function testEmailType() - { - $type = new Email('john@doe.com'); - $this->assertEquals('john@doe.com', $type->get()); - } - - public function testEmailTypeThrowsExceptionWithInvalidEmail() - { - $this->expectException(\InvalidArgumentException::class); - new Email('abcdef'); - } - - public function testEmailTypeThrowsExceptionWithInvalidValue() - { - $this->expectException(\InvalidArgumentException::class); - new Email(NULL); - } -} diff --git a/tests/engine/Types/IntegerTest.php b/tests/engine/Types/IntegerTest.php deleted file mode 100644 index 0caadcfb..00000000 --- a/tests/engine/Types/IntegerTest.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -use PHPUnit\Framework\TestCase; - -class IntegerTest extends TestCase { - public function testIntType() - { - $type = new Integer(1); - $this->assertEquals(1, $type->get()); - } - - public function testIntTypeThrowsExceptionWithFloat() - { - $this->expectException(\InvalidArgumentException::class); - new Integer(100.00); - } - - public function testIntTypeThrowsExceptionWithWithString() - { - $this->expectException(\InvalidArgumentException::class); - new Integer('invalid'); - } -} diff --git a/tests/engine/Types/NonEmptyTextTest.php b/tests/engine/Types/NonEmptyTextTest.php deleted file mode 100644 index bdd85fab..00000000 --- a/tests/engine/Types/NonEmptyTextTest.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -use PHPUnit\Framework\TestCase; - -class NonEmptyTextTest extends TestCase { - public function testNonEmptyStringType() - { - $type = new NonEmptyText('Hello!'); - $this->assertEquals('Hello!', $type->get()); - } - - public function testNonEmptyStringTypeThrowsExceptionWithEmptyString() - { - $this->expectException(\InvalidArgumentException::class); - new NonEmptyText(''); - } - - public function testNonEmptyStringTypeThrowsExceptionWithInvalidValue() - { - $this->expectException(\InvalidArgumentException::class); - new NonEmptyText(NULL); - } -} diff --git a/tests/engine/Types/TextTest.php b/tests/engine/Types/TextTest.php deleted file mode 100644 index e7f9b408..00000000 --- a/tests/engine/Types/TextTest.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -use PHPUnit\Framework\TestCase; - -class TextTest extends TestCase { - public function testStringType() - { - $type = new Text('Hello!'); - $this->assertEquals('Hello!', $type->get()); - } - - public function testStringTypeThrowsExceptionWithInvalidValue() - { - $this->expectException(\InvalidArgumentException::class); - new Text(NULL); - } -} diff --git a/tests/engine/Types/UnsignedIntegerTest.php b/tests/engine/Types/UnsignedIntegerTest.php deleted file mode 100644 index c022c120..00000000 --- a/tests/engine/Types/UnsignedIntegerTest.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -use PHPUnit\Framework\TestCase; - -class UnsignedIntegerTest extends TestCase { - public function testUnsignedIntType() - { - $type = new UnsignedInteger(1); - $this->assertEquals(1, $type->get()); - } - - public function testUnsignedIntTypeThrowsExceptionWithNegative() - { - $this->expectException(\InvalidArgumentException::class); - new UnsignedInteger(-1); - } - - public function testUnsignedIntTypeThrowsExceptionWithWithString() - { - $this->expectException(\InvalidArgumentException::class); - new UnsignedInteger('invalid'); - } -} diff --git a/tests/engine/Types/UrlTest.php b/tests/engine/Types/UrlTest.php deleted file mode 100644 index cb9392de..00000000 --- a/tests/engine/Types/UrlTest.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.2.0 - * ---------------------------------------------------------------------------- */ - -namespace EA\Engine\Types; - -use PHPUnit\Framework\TestCase; - -class UrlTest extends TestCase { - public function testUrlType() - { - $type = new Url('http://localhost'); - $this->assertEquals('http://localhost', $type->get()); - } - - public function testUrlTypeThrowsExceptionWithInvalidUrl() - { - $this->expectException(\InvalidArgumentException::class); - new Url('abcdef'); - } - - public function testUrlTypeThrowsExceptionWithInvalidValue() - { - $this->expectException(\InvalidArgumentException::class); - new Url(NULL); - } -}