Canviat mètode POST getClasses per GET getCurrentClasses
El mètode GET és més adequat per aquest tipus de peticions.
Change-Id: I6f4a233962f216c126a2327463f82e4fe55d2214
diff --git a/inc/API.php b/inc/API.php
index f1763ea..8ecfdd1 100644
--- a/inc/API.php
+++ b/inc/API.php
@@ -143,13 +143,15 @@
self::returnError();
break;
- case 'getClasses':
- $body = self::getJSONBody();
- $response = Classes::handleAPIGetClasses($body);
- if ($response === false)
+ case 'getCurrentClasses':
+ self::checkRequestMethod('GET');
+ $classes = Classes::getCurrentClasses();
+ if ($classes === false)
self::returnError();
else
- self::returnPayload($response);
+ self::returnPayload([
+ 'classes' => $classes
+ ]);
break;
case 'setClassState':
diff --git a/inc/Classes.php b/inc/Classes.php
index 9c21ac8..f0ebf90 100644
--- a/inc/Classes.php
+++ b/inc/Classes.php
@@ -37,26 +37,4 @@
return $classes;
}
-
- public static function handleAPIGetClasses($body) {
- if (!isset($body['type']))
- return false;
-
- $response = [];
-
- switch ($body['type']) {
- case 'current':
- $classes = self::getCurrentClasses();
- if ($classes === false)
- return false;
-
- $response['classes'] = $classes;
- break;
-
- default:
- return false;
- }
-
- return $response;
- }
}