Add business-hours API endpoint
This commit is contained in:
parent
09b371036a
commit
df780f4546
15
api/BusinessLogic/Calendar/BusinessHours.php
Normal file
15
api/BusinessLogic/Calendar/BusinessHours.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BusinessLogic\Calendar;
|
||||||
|
|
||||||
|
|
||||||
|
class BusinessHours {
|
||||||
|
/* @var $dayOfWeek int */
|
||||||
|
public $dayOfWeek;
|
||||||
|
|
||||||
|
/* @var $startTime string */
|
||||||
|
public $startTime;
|
||||||
|
|
||||||
|
/* @var $endTime string */
|
||||||
|
public $endTime;
|
||||||
|
}
|
@ -89,4 +89,8 @@ class CalendarHandler extends \BaseClass {
|
|||||||
public function deleteEvent($id, $userContext, $heskSettings) {
|
public function deleteEvent($id, $userContext, $heskSettings) {
|
||||||
$this->calendarGateway->deleteEvent($id, $userContext, $heskSettings);
|
$this->calendarGateway->deleteEvent($id, $userContext, $heskSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBusinessHours($heskSettings) {
|
||||||
|
return $this->calendarGateway->getBusinessHours($heskSettings);
|
||||||
|
}
|
||||||
}
|
}
|
@ -124,4 +124,12 @@ class CalendarController extends \BaseClass {
|
|||||||
|
|
||||||
return $event;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function getBusinessHours() {
|
||||||
|
global $applicationContext, $hesk_settings;
|
||||||
|
|
||||||
|
$calendarHandler = $applicationContext->get(CalendarHandler::clazz());
|
||||||
|
|
||||||
|
return output($calendarHandler->getBusinessHours($hesk_settings));
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ namespace DataAccess\Calendar;
|
|||||||
|
|
||||||
|
|
||||||
use BusinessLogic\Calendar\AbstractEvent;
|
use BusinessLogic\Calendar\AbstractEvent;
|
||||||
|
use BusinessLogic\Calendar\BusinessHours;
|
||||||
use BusinessLogic\Calendar\CalendarEvent;
|
use BusinessLogic\Calendar\CalendarEvent;
|
||||||
use BusinessLogic\Calendar\ReminderUnit;
|
use BusinessLogic\Calendar\ReminderUnit;
|
||||||
use BusinessLogic\Calendar\SearchEventsFilter;
|
use BusinessLogic\Calendar\SearchEventsFilter;
|
||||||
@ -243,4 +244,23 @@ class CalendarGateway extends CommonDao {
|
|||||||
|
|
||||||
$this->close();
|
$this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBusinessHours($heskSettings) {
|
||||||
|
$this->init();
|
||||||
|
|
||||||
|
$rs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_calendar_business_hours`");
|
||||||
|
$businessHours = array();
|
||||||
|
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||||
|
$businessHour = new BusinessHours();
|
||||||
|
$businessHour->dayOfWeek = intval($row['day_of_week']);
|
||||||
|
$businessHour->startTime = $row['start_time'];
|
||||||
|
$businessHour->endTime = $row['end_time'];
|
||||||
|
|
||||||
|
$businessHours[] = $businessHour;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->close();
|
||||||
|
|
||||||
|
return $businessHours;
|
||||||
|
}
|
||||||
}
|
}
|
@ -211,6 +211,7 @@ Link::all(array(
|
|||||||
// Settings
|
// Settings
|
||||||
'/v1/settings' => action(\Controllers\Settings\SettingsController::clazz(), RequestMethod::all()),
|
'/v1/settings' => action(\Controllers\Settings\SettingsController::clazz(), RequestMethod::all()),
|
||||||
// Calendar
|
// Calendar
|
||||||
|
'/v1/calendar/business-hours' => action(\Controllers\Calendar\CalendarController::clazz() . '::getBusinessHours', array(RequestMethod::GET), SecurityHandler::OPEN),
|
||||||
'/v1/calendar/events' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET), SecurityHandler::OPEN),
|
'/v1/calendar/events' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET), SecurityHandler::OPEN),
|
||||||
'/v1/calendar/events/staff' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET, RequestMethod::POST), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
'/v1/calendar/events/staff' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET, RequestMethod::POST), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
||||||
'/v1/calendar/events/staff/{i}' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::PUT, RequestMethod::DELETE), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
'/v1/calendar/events/staff/{i}' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::PUT, RequestMethod::DELETE), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user