api.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. $app->get('/plugins/shuck-stop/settings', function ($request, $response, $args) {
  3. /**
  4. * @OA\Get(
  5. * tags={"plugins-shuck-stop"},
  6. * path="/api/v2/plugins/shuck-stop/settings",
  7. * summary="Get settings",
  8. * @OA\Response(
  9. * response="200",
  10. * description="Success",
  11. * @OA\JsonContent(ref="#/components/schemas/pluginSettingsPage"),
  12. * ),
  13. * @OA\Response(response="401",description="Unauthorized"),
  14. * security={{ "api_key":{} }}
  15. * )
  16. */
  17. $shuckStop = new ShuckStop();
  18. if ($shuckStop->checkRoute($request)) {
  19. if ($shuckStop->qualifyRequest(1, true)) {
  20. $GLOBALS['api']['response']['data'] = $shuckStop->_shuckStopPluginGetSettings();
  21. }
  22. }
  23. $response->getBody()->write(jsonE($GLOBALS['api']));
  24. return $response
  25. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  26. ->withStatus($GLOBALS['responseCode']);
  27. });
  28. $app->get('/plugins/shuck-stop/run', function ($request, $response, $args) {
  29. /**
  30. * @OA\Get(
  31. * tags={"plugins-shuck-stop"},
  32. * path="/api/v2/plugins/shuck-stop/run",
  33. * summary="Run ShuckStop plugin",
  34. * @OA\Response(
  35. * response="200",
  36. * description="Success",
  37. * @OA\JsonContent(ref="#/components/schemas/shuckStopRun"),
  38. * ),
  39. * @OA\Response(response="401",description="Unauthorized"),
  40. * security={{ "api_key":{} }}
  41. * )
  42. */
  43. $shuckStop = new ShuckStop();
  44. if ($shuckStop->checkRoute($request)) {
  45. if ($shuckStop->qualifyRequest(1, true)) {
  46. $shuckStop->_shuckStopPluginRun();
  47. }
  48. }
  49. $response->getBody()->write(jsonE($GLOBALS['api']));
  50. return $response
  51. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  52. ->withStatus($GLOBALS['responseCode']);
  53. });