-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeInfoService.php
56 lines (40 loc) · 1.2 KB
/
timeInfoService.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* Created by PhpStorm.
* User: r.troulakis
* Date: 04/02/2019
* Time: 4:33 PM
*/
require_once("SimpleRest.php");
include "timeInfo.php";
class timeInfoRestHandler extends SimpleRest
{
function getInfo(){
$customer_info = new timeInfo();
$customer_info->setTimeInfo();
$rawData = $customer_info->getTimeInfo();
if(empty($rawData)) {
$statusCode = 404;
$rawData = array('error' => 'File with Logs Not Found!');
} else {
$statusCode = 200;
}
$requestContentType = "application/json";
$this ->setHttpHeaders($requestContentType, $statusCode);
$response1 = $this->encodeJson($rawData);
$response = "[".$response1."]";
echo $response;
}
function getErrorMsg(){
$statusCode = 404;
$rawData = array('error' => 'Invalid Token!');
$requestContentType = "text/json";
$this ->setHttpHeaders($requestContentType, $statusCode);
$response = $this->encodeJson($rawData);
echo $response;
}
public function encodeJson($responseData) {
$jsonResponse = json_encode($responseData);
return $jsonResponse;
}
}