Example #1
0
 /**
  * @inheritDoc
  */
 public function __invoke(array $input)
 {
     $serverParams = $this->server->getServerParams();
     if (!self::hasAuthorization($serverParams, $this->payload)) {
         return self::getErrorStatus($this->payload);
     }
     $weekDate = date(Constants::DEFAULT_DATEFORMAT);
     if (isset($input[Constants::WEEK_DATE])) {
         $weekDate = $input[Constants::WEEK_DATE];
     }
     $token = Utilities::getInstance()->parseToken($serverParams);
     $data = Utilities::getInstance()->extractData($token);
     $employeeId = $data->user_id;
     $hours = array();
     if (!empty($employeeId)) {
         $hours = Utilities::getInstance()->findWeekHours($employeeId, $weekDate);
         // dummy function: Results from DB implementation
     }
     return $this->payload->withStatus(PayloadInterface::OK)->withOutput($hours);
 }
Example #2
0
 /**
  * @inheritDoc
  */
 public function __invoke(array $input)
 {
     $status = PayloadInterface::INVALID;
     $serverParams = $this->server->getServerParams();
     $shiftId = 0;
     if (isset($input[Constants::SHIFT_ID])) {
         $shiftId = $input[Constants::SHIFT_ID];
     }
     if (!self::hasAuthorization($serverParams, $this->payload)) {
         return self::getErrorStatus($this->payload);
     }
     $data = Utilities::getInstance()->extractData($serverParams);
     $employeeId = $data->user_id;
     $buddies = array(self::setDefaultMessage(Constants::EMPLOYEE_ID . Constants::ERROR_REQUIRED));
     if (!empty($employeeId)) {
         $buddies = Utilities::getInstance()->findShiftBuddy($employeeId, $shiftId);
         // dummy function: Results from DB implementation
         $status = PayloadInterface::OK;
     }
     return $this->payload->withStatus($status)->withOutput($buddies);
 }
 /**
  * @inheritDoc
  */
 public function __invoke(array $input)
 {
     $status = PayloadInterface::INVALID;
     $serverParams = $this->server->getServerParams();
     if (!self::hasAuthorization($serverParams, $this->payload)) {
         return self::getErrorStatus($this->payload);
     }
     $data = Utilities::getInstance()->extractData($serverParams);
     $employeeId = $data->user_id;
     //defaults to own id
     if (isset($input[Constants::EMPLOYEE_ID]) && self::hasAuthorization($serverParams, $this->payload, Constants::MANAGER_ACCESS)) {
         $employeeId = $input[Constants::EMPLOYEE_ID];
         //only Managers can query employee IDs
     }
     $shifts = array(self::setDefaultMessage(Constants::EMPLOYEE_ID . Constants::ERROR_REQUIRED));
     if (!empty($employeeId)) {
         $shifts = Utilities::getInstance()->findShiftsByEmployeeId($employeeId);
         //Results from DB implementation, sample provided here with random generated data
         $status = PayloadInterface::OK;
     }
     return $this->payload->withStatus($status)->withOutput($shifts);
 }
 /**
  * @inheritDoc
  */
 public function __invoke(array $input)
 {
     $status = PayloadInterface::INVALID;
     $serverParams = $this->server->getServerParams();
     if (!self::hasAuthorization($serverParams, $this->payload)) {
         return self::getErrorStatus($this->payload);
     }
     $token = Utilities::getInstance()->parseToken($serverParams);
     $data = Utilities::getInstance()->extractData($token);
     $employeeId = $data->user_id;
     $shiftId = 0;
     if (isset($input[Constants::SHIFT_ID])) {
         $shiftId = $input[Constants::SHIFT_ID];
     }
     $shifts = array(self::setDefaultMessage(Constants::ERROR_SHIFTID_REQUIRED));
     if (!empty($shiftId)) {
         $shifts = Utilities::getInstance()->findEmployeeManager($shiftId);
         // Results from DB implementation, sample provided here with random generated data
         $status = PayloadInterface::OK;
     }
     return $this->payload->withStatus($status)->withOutput($shifts);
 }
Example #5
0
 /**
  * @inheritDoc
  */
 public function __invoke(array $input)
 {
     $status = PayloadInterface::INVALID;
     $serverParams = $this->server->getServerParams();
     if (!self::hasAuthorization($serverParams, $this->payload, Constants::MANAGER_ACCESS)) {
         return self::getErrorStatus($this->payload);
     }
     $data = Utilities::getInstance()->extractData($serverParams);
     $managerId = $data->user_id;
     $insertStatus = array(self::setDefaultMessage(Constants::EMPLOYEE_ID . Constants::ANDSTR . Constants::BREAKS . Constants::ANDSTR . Constants::FROM_DATE . Constants::ANDSTR . Constants::TO_DATE . Constants::ANDSTR));
     if (self::hasRequiredParams($input)) {
         $employeeId = $input[Constants::EMPLOYEE_ID];
         $breaks = $input[Constants::BREAKS];
         $startTime = $input[Constants::FROM_DATE];
         $endTime = $input[Constants::TO_DATE];
         $now = date(Constants::DEFAULT_DATEFORMAT);
         $newShift = new Shift([Constants::MANAGER_ID => $managerId, Constants::EMPLOYEE_ID => $employeeId, Constants::BREAKS => $breaks, Constants::START_TIME => $startTime, Constants::END_TIME => $endTime, Constants::CREATED_AT => $now, Constants::UPDATED_AT => $now]);
         $insertStatus = Utilities::getInstance()->addShift($newShift);
         // dummy function: Results from DB implementation
         $status = PayloadInterface::OK;
     }
     return $this->payload->withStatus($status)->withOutput($insertStatus);
 }