|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Soheilrt\AdobeConnectClient\Client; |
|
4
|
|
|
|
|
5
|
|
|
use BadMethodCallException; |
|
6
|
|
|
use DomainException; |
|
7
|
|
|
use ReflectionClass; |
|
8
|
|
|
use ReflectionException; |
|
9
|
|
|
use Soheilrt\AdobeConnectClient\Client\Abstracts\Command; |
|
10
|
|
|
use Soheilrt\AdobeConnectClient\Client\Connection\ConnectionInterface; |
|
11
|
|
|
use Soheilrt\AdobeConnectClient\Client\Connection\ResponseInterface; |
|
12
|
|
|
use Soheilrt\AdobeConnectClient\Client\Contracts\ArrayableInterface as Arrayable; |
|
13
|
|
|
use Soheilrt\AdobeConnectClient\Client\Entities\CommonInfo; |
|
14
|
|
|
use Soheilrt\AdobeConnectClient\Client\Entities\Permission; |
|
15
|
|
|
use Soheilrt\AdobeConnectClient\Client\Entities\Principal; |
|
16
|
|
|
use Soheilrt\AdobeConnectClient\Client\Entities\SCO; |
|
17
|
|
|
use Soheilrt\AdobeConnectClient\Client\Entities\SCORecord; |
|
18
|
|
|
use Soheilrt\AdobeConnectClient\Client\Exceptions\CommandClassNotFoundException; |
|
19
|
|
|
use Soheilrt\AdobeConnectClient\Client\Helpers\StringCaseTransform as SCT; |
|
20
|
|
|
use SplFileInfo; |
|
21
|
|
|
use UnexpectedValueException; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* The Client to Adobe Connect API. |
|
25
|
|
|
* |
|
26
|
|
|
* @method bool login(string $login, string $password) Login in the Service. |
|
27
|
|
|
* @method bool logout() Ends the service session |
|
28
|
|
|
* @method CommonInfo commonInfo(string $domain = '') Gets the Common Info |
|
29
|
|
|
* @method SCO scoInfo(int $scoId) Gets the info about a SCO |
|
30
|
|
|
* @method SCO scoCreate(Arrayable $sco) Create a SCO |
|
31
|
|
|
* @method bool scoUpdate(Arrayable $sco) Update a SCO |
|
32
|
|
|
* @method bool scoDelete(int $scoId) Delete a SCO or a Folder |
|
33
|
|
|
* @method SCO[] scoShortcuts(Arrayable $filter = null, Arrayable $sorter = null) Get SCO Shurcuts to SCO diffrent types. |
|
34
|
|
|
* @method bool scoMove(int $scoId, int $folderId) Move the SCO to other Folder |
|
35
|
|
|
* @method SCO[] scoContents(int $scoId, Arrayable $filter = null, Arrayable $sorter = null) Get the SCO Contents from a folder or from other SCO |
|
36
|
|
|
* @method SCORecord[] listRecordings(int $folderId) Provides a list of recordings for a specified folder or SCO |
|
37
|
|
|
* @method Principal principalInfo(int $principalId) Gets the info about an user or group |
|
38
|
|
|
* @method Principal principalCreate(Arrayable $principal) Create a Principal. |
|
39
|
|
|
* @method bool principalUpdate(Arrayable $principal) Update a Principal. |
|
40
|
|
|
* @method bool principalDelete(int $principalId) Remove one principal, either user or group |
|
41
|
|
|
* @method Principal[] principalList(int $groupId = 0, Arrayable $filter = null, Arrayable $sorter = null) Provides a complete list of users and groups, including primary groups. |
|
42
|
|
|
* @method bool userUpdatePassword(int $userId, string $newPassword, string $oldPassword = '') Changes user’s password |
|
43
|
|
|
* @method bool groupMembershipUpdate(int $groupId, int $principalId, bool $isMember) Add or remove a principal from a group |
|
44
|
|
|
* @method bool permissionUpdate(Arrayable $permission) Updates the principal's permissions to access a SCO or the access mode if the acl-id is a Meeting |
|
45
|
|
|
* @method Principal[] permissionsInfo(int $aclId, Arrayable $filter = null, Arrayable $sorter = null) Get a list of principals who have permissions to act on a SCO, Principal or Account |
|
46
|
|
|
* @method Permission permissionInfoFromPrincipal(int $aclId, int $principalId) Get the Principal's permission in a SCO, Principal or Account |
|
47
|
|
|
* @method bool meetingFeatureUpdate(int $accountId, string $featureId, bool $enable) Set a feature |
|
48
|
|
|
* @method bool aclFieldUpdate(int $aclId, string $fieldId, mixed $value, Arrayable $extraParams = null) Updates the passed in Field for the specified ACL |
|
49
|
|
|
* @method bool recordingPasscode(int $scoId, string $passcode) Set the passcode on a Recording and turned into public |
|
50
|
|
|
* @method int|null scoUpload(int $folderId, string $resourceName, resource|SplFileInfo $file) Uploads a file and then builds the file |
|
51
|
|
|
*/ |
|
52
|
|
|
class Client |
|
53
|
|
|
{ |
|
54
|
|
|
/** |
|
55
|
|
|
* @var ConnectionInterface |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $connection; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var string The Session Cookie |
|
61
|
|
|
*/ |
|
62
|
|
|
protected $sessionCookie = ''; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param ConnectionInterface $connection The Connection handler |
|
66
|
|
|
* @param string $session The Session Cookie |
|
67
|
|
|
*/ |
|
68
|
|
|
public function __construct(ConnectionInterface $connection, string $session = '') |
|
69
|
|
|
{ |
|
70
|
|
|
$this->connection = $connection; |
|
71
|
|
|
$this->sessionCookie = $session; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return string |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getSession() |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->sessionCookie; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param string $session |
|
84
|
|
|
*/ |
|
85
|
|
|
public function setSession($session = '') |
|
86
|
|
|
{ |
|
87
|
|
|
$this->sessionCookie = $session; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Instantiates the Command and execute it. |
|
92
|
|
|
* |
|
93
|
|
|
* @param string $commandName |
|
94
|
|
|
* @param array $arguments |
|
95
|
|
|
* |
|
96
|
|
|
* @throws ReflectionException |
|
97
|
|
|
* |
|
98
|
|
|
* @throws CommandClassNotFoundException |
|
99
|
|
|
* @return mixed |
|
100
|
|
|
*/ |
|
101
|
|
|
public function __call($commandName, array $arguments = []) |
|
102
|
|
|
{ |
|
103
|
|
|
$commandClassName = $this->getCommandClassName($commandName); |
|
104
|
|
|
|
|
105
|
|
|
if (!class_exists($commandClassName)) { |
|
106
|
|
|
throw new CommandClassNotFoundException("{$commandClassName} Not Found!"); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
$reflection = new ReflectionClass($commandClassName); |
|
110
|
|
|
|
|
111
|
|
|
if (!$reflection->isSubclassOf(Command::class)) { |
|
112
|
|
|
throw new DomainException(sprintf('"%s" is not a valid command', $commandName)); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
return $reflection->newInstanceArgs($arguments) |
|
116
|
|
|
->setClient($this) |
|
117
|
|
|
->execute(); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* get command class name |
|
122
|
|
|
* |
|
123
|
|
|
* @param string $commandName |
|
124
|
|
|
* |
|
125
|
|
|
* @throws BadMethodCallException |
|
126
|
|
|
* |
|
127
|
|
|
* @return string |
|
128
|
|
|
*/ |
|
129
|
|
|
protected final function getCommandClassName($commandName) |
|
130
|
|
|
{ |
|
131
|
|
|
$qualifiedCommandName = SCT::toUpperCamelCase($commandName); |
|
132
|
|
|
$command = "Soheilrt\\AdobeConnectClient\\Client\\Commands\\{$qualifiedCommandName}"; |
|
133
|
|
|
|
|
134
|
|
|
if (!class_exists($command)) { |
|
135
|
|
|
throw new BadMethodCallException("Command {$commandName} Does Not Exists!"); |
|
136
|
|
|
} |
|
137
|
|
|
return $command; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @param array $parameters |
|
143
|
|
|
* |
|
144
|
|
|
* @throws UnexpectedValueException |
|
145
|
|
|
* |
|
146
|
|
|
* @return ResponseInterface |
|
147
|
|
|
*/ |
|
148
|
|
|
public function doGet(array $parameters) |
|
149
|
|
|
{ |
|
150
|
|
|
return $this->connection->get($parameters); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* @param array $postParams |
|
155
|
|
|
* @param array $queryParams |
|
156
|
|
|
* |
|
157
|
|
|
* @throws UnexpectedValueException |
|
158
|
|
|
* |
|
159
|
|
|
* @return ResponseInterface |
|
160
|
|
|
*/ |
|
161
|
|
|
public function doPost(array $postParams, array $queryParams = []) |
|
162
|
|
|
{ |
|
163
|
|
|
return $this->connection->post($postParams, $queryParams); |
|
164
|
|
|
} |
|
165
|
|
|
} |
|
166
|
|
|
|