|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (c) 2016-2023 BigBlueButton Inc. and by respective authors (see below). |
|
7
|
|
|
* |
|
8
|
|
|
* This program is free software; you can redistribute it and/or modify it under the |
|
9
|
|
|
* terms of the GNU Lesser General Public License as published by the Free Software |
|
10
|
|
|
* Foundation; either version 3.0 of the License, or (at your option) any later |
|
11
|
|
|
* version. |
|
12
|
|
|
* |
|
13
|
|
|
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY |
|
14
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
15
|
|
|
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU Lesser General Public License along |
|
18
|
|
|
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace BigBlueButton\Responses; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Class BaseJsonResponse. |
|
25
|
|
|
*/ |
|
26
|
|
|
abstract class BaseJsonResponse |
|
27
|
|
|
{ |
|
28
|
|
|
public const SUCCESS = 'SUCCESS'; |
|
29
|
|
|
public const FAILED = 'FAILED'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var mixed |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $data; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* BaseJsonResponse constructor. |
|
38
|
|
|
* |
|
39
|
|
|
* @param string $json |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct($json) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->data = json_decode($json); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function getRawJson() |
|
47
|
|
|
{ |
|
48
|
|
|
return json_encode($this->data); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function getMessage() |
|
52
|
|
|
{ |
|
53
|
|
|
if ($this->failed()) { |
|
54
|
|
|
return $this->data->response->message; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
return null; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function getMessageKey() |
|
61
|
|
|
{ |
|
62
|
|
|
if ($this->failed()) { |
|
63
|
|
|
return $this->data->response->messageKey; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
return null; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function getReturnCode() |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->data->response->returncode; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function success() |
|
75
|
|
|
{ |
|
76
|
|
|
return self::SUCCESS === $this->getReturnCode(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function failed() |
|
80
|
|
|
{ |
|
81
|
|
|
return self::FAILED === $this->getReturnCode(); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|