summaryrefslogtreecommitdiff
path: root/http/api-inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'http/api-inc.php')
-rw-r--r--http/api-inc.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/http/api-inc.php b/http/api-inc.php
index 565e66c..96c9ca7 100644
--- a/http/api-inc.php
+++ b/http/api-inc.php
@@ -28,6 +28,23 @@ function recursive_ksort(&$array, $flags = SORT_REGULAR) {
class ParametersException extends Exception {};
+function run($parameters) {
+ $versionClasses = array(
+ '1' => 'ApiPklV1', // RegKlas 2018.11.01
+ '2' => 'ApiPklV2', // RegKMP 2020.01.01
+ '_default' => 'ApiPklV2'
+ );
+ $version = isset($parameters['version']) ? $parameters['version'] : '_default';
+ $apiClass = isset($versionClasses[$version]) ? $versionClasses[$version] : $versionClasses['_default'];
+ $api = new $apiClass($parameters);
+ if ($parameters['tournament_rank'] == ApiPkl::RANK_KMP) {
+ $result = $api->calculate_kmp_points();
+ } else {
+ $result = $api->calculate_points();
+ }
+ return $result;
+}
+
class ApiPkl {
const RANK_KMP = 101;