MCPcopy Create free account
hub / github.com/Rello/analytics / ApiController

Class ApiController

lib/Controller/ApiController.php:23–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21use OCP\IRequest;
22
23class ApiController extends OCSController {
24 private ReportService $reportService;
25 private $logger;
26
27 public function __construct(
28 string $appName,
29 IRequest $request,
30 LoggerInterface $logger,
31 ReportService $reportService,
32 private ShareService $shareService,
33 private OutputController $outputController,
34 private ApiDataController $apiDataController
35 ) {
36 parent::__construct($appName, $request);
37 $this->reportService = $reportService;
38 $this->logger = $logger;
39 }
40
41 /**
42 * Create an analytics report from an existing data file.
43 *
44 * @param int $fileId ID of the file to import
45 *
46 * @return DataResponse HTTP 200 with a link to the created report
47 *
48 */
49 #[NoAdminRequired]
50 #[NoCSRFRequired]
51 #[ApiRoute(verb: 'POST', url: '/createFromDataFile')]
52 public function createFromDataFile($fileId): DataResponse {
53 if ($fileId) {
54 $reportId = $this->reportService->createFromDataFile($fileId);
55 $url = '/apps/analytics/r/' . $reportId;
56 return new DataResponse([
57 'version' => '0.1',
58 'root' => [
59 'orientation' => 'vertical',
60 'rows' => [
61 [
62 'children' => [
63 [
64 'element' => 'URL',
65 'text' => 'Analytics report created',
66 'url' => $url,
67 ],
68 ],
69 ],
70 ],
71 ],
72 ]);
73 } else {
74 return new DataResponse(['error' => 'fileId missing'], HTTP::STATUS_BAD_REQUEST);
75 }
76 }
77
78 #[NoAdminRequired]
79 #[NoCSRFRequired]
80 #[ApiRoute(verb: 'GET', url: '/api/v1/reports')]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected