1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace OCA\AppAPI\Service {
- use OCP\IRequest;
- class AppAPIService {
-
- public function validateExAppRequestToNC(IRequest $request, bool $isDav = false): bool {}
- }
- }
- namespace OCA\AppAPI {
- use OCP\IRequest;
- use OCP\Http\Client\IPromise;
- use OCP\Http\Client\IResponse;
- class PublicFunctions {
- public function __construct(
- private readonly ExAppService $exAppService,
- private readonly AppAPIService $service,
- ) {
- }
-
- public function exAppRequest(
- string $appId,
- string $route,
- ?string $userId = null,
- string $method = 'POST',
- array $params = [],
- array $options = [],
- ?IRequest $request = null,
- ): array|IResponse {
- $exApp = $this->exAppService->getExApp($appId);
- if ($exApp === null) {
- return ['error' => sprintf('ExApp `%s` not found', $appId)];
- }
- return $this->service->requestToExApp($exApp, $route, $userId, $method, $params, $options, $request);
- }
-
- public function asyncExAppRequest(
- string $appId,
- string $route,
- ?string $userId = null,
- string $method = 'POST',
- array $params = [],
- array $options = [],
- ?IRequest $request = null,
- ): IPromise {
- $exApp = $this->exAppService->getExApp($appId);
- if ($exApp === null) {
- throw new \Exception(sprintf('ExApp `%s` not found', $appId));
- }
- return $this->service->requestToExAppAsync($exApp, $route, $userId, $method, $params, $options, $request);
- }
-
- public function getExApp(string $appId): ?array {
- $exApp = $this->exAppService->getExApp($appId);
- if ($exApp !== null) {
- $info = $exApp->jsonSerialize();
- return [
- 'appid' => $info['appid'],
- 'version' => $info['version'],
- 'name' => $info['name'],
- 'enabled' => $info['enabled'],
- ];
- }
- return null;
- }
- }
- }
|