コード例 #1
0
ファイル: Hello.php プロジェクト: elevenone/spark-rest-api
 public function __invoke(array $input)
 {
     $this->stories = new \stories($this->shiftModel, $this->userModel, $this->tokensModel, $this->token);
     if (!empty($input['name'])) {
         $name = $input['name'];
     }
     if (!empty($input['employeeID'])) {
         $employeeID = $input['employeeID'];
         $return = $this->stories->shiftsForEmployee($employeeID);
     }
     if (!empty($input['startTime']) && !empty($input['endTime'])) {
         $start = $input['startTime'];
         $end = $input['endTime'];
         $startTime = \DateTime::createFromFormat('m-d-Y', $start);
         $endTime = \DateTime::createFromFormat('m-d-Y', $end);
         $return = $this->stories->getEmployeesWorkingBetween($startTime, $endTime);
     }
     if (!empty($input['employeeID']) && !empty($input['startTime']) && !empty($input['endTime'])) {
         $start = $input['startTime'];
         $end = $input['endTime'];
         $employeeID = $input['employeeID'];
         $startTime = \DateTime::createFromFormat('m-d-Y', $start);
         $endTime = \DateTime::createFromFormat('m-d-Y', $end);
         $return = $this->stories->getHoursForEmployeeBetween($employeeID, $startTime, $endTime);
     }
     if (!empty($input['employeeI2D'])) {
         $employeeID = $input['employeeID2'];
         $return = $this->stories->shiftsForEmployee($employeeID);
     }
     return (new Payload())->withStatus(Payload::OK)->withOutput(['hello' => $return]);
 }
コード例 #2
0
ファイル: Story3.php プロジェクト: elevenone/spark-rest-api
 public function __invoke(array $input)
 {
     $this->stories = new \stories($this->shiftModel, $this->userModel, $this->tokensModel, $this->token);
     if (!empty($input['employeeID']) && !empty($input['startTime']) && !empty($input['endTime'])) {
         $start = $input['startTime'];
         $end = $input['endTime'];
         $employeeID = $input['employeeID'];
         $startTime = \DateTime::createFromFormat('m-d-Y', $start);
         $endTime = \DateTime::createFromFormat('m-d-Y', $end);
         $return = $this->stories->getHoursForEmployeeBetween($employeeID, $startTime, $endTime);
     } else {
         throw new \Exception('improper API usage');
     }
     return (new Payload())->withStatus(Payload::OK)->withOutput(['hello' => $return]);
 }