From 27d32d8b5b5a6bab278bebaafdb2c07d38778701 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 10 Jan 2020 22:10:07 +0100 Subject: Selection of API class depending on privided version --- http/api.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'http/api.php') diff --git a/http/api.php b/http/api.php index b0140b9..ea633e3 100644 --- a/http/api.php +++ b/http/api.php @@ -31,8 +31,15 @@ Parametry: require_once('api-inc.php'); function run($parameters) { + try { - $api = new ApiPkl($parameters); + $versionClasses = array( + '1' => 'ApiPklV1', // RegKlas 2018.11.01 + '_default' => 'ApiPklV1' + ); + $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 { -- cgit v1.2.3