summaryrefslogtreecommitdiff
path: root/http/api.php
diff options
context:
space:
mode:
authorMichał Klichowicz <emkael@tlen.pl>2020-05-16 19:26:44 +0200
committerGitHub <noreply@github.com>2020-05-16 19:26:44 +0200
commite34beab42e1c64965e7567e9e37fc3390fe79710 (patch)
tree6f3418eaac05ca451eb2c522fb2b4ac21729571d /http/api.php
parentb70009db358e73b374b48a9bad3d981da37040ef (diff)
parent00d867eb3e83a23157f593593063c6dfffb49aa6 (diff)
Merge pull request #5 from PZBS/local-b-net
BridgeNET Lokalny
Diffstat (limited to 'http/api.php')
-rw-r--r--http/api.php44
1 files changed, 14 insertions, 30 deletions
diff --git a/http/api.php b/http/api.php
index acf2752..6241aca 100644
--- a/http/api.php
+++ b/http/api.php
@@ -5,8 +5,9 @@ Parametry:
- rodzaj turnieju (4 => teamy, 2 => pary, 1 => ind)
- l. uczestników
- suma WK
- - ranga turnieju (0 => K, 1 => Ok, 2 => R, 3 => O, 4 => O*, 5 => O**, 6 => O***, 7 => O****) (opcjonalny, jeśli podano ręczne minPKL i wagę)
+ - ranga turnieju (0 => K, 1 => Ok, 2 => R, 3 => O, 4 => O*, 5 => O**, 6 => O***, 7 => O****, 101 => KMP, 102 => B-NET Lokalny) (opcjonalny, jeśli podano ręczne minPKL i wagę)
- l. rozdań => 40? (opcjonalny, jeśli podano ręczne minPKL i wagę)
+ - l. rozdań (jeśli obecny, przesłania l. rozdań => 40?, obowiązkowy dla turniejów BridgeNET)
- ręczne minPKL za pierwsze (opcjonalny)
- ręczna waga (opcjonalny)
- ręczny współczynnik zawodniczy (opcjonalny)
@@ -18,6 +19,7 @@ Parametry:
"title_sum": 230,
"tournament_rank": 3,
"over39_boards": 0,
+ "boards": 30,
"manual": {
"min_points": 50,
"tournament_weight": 50,
@@ -30,35 +32,17 @@ Parametry:
require_once('api-inc.php');
-function run($parameters) {
-
- try {
- $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;
- }
- catch (ParametersException $e) {
- http_response_code(400);
- die(json_encode($e->getMessage()));
- }
- catch (Exception $e) {
- http_response_code(500);
- die(json_encode($e->getMessage()));
- }
+try {
+ header('Content-Type: application/json');
+ print(json_encode(run($_REQUEST)));
+}
+catch (ParametersException $e) {
+ http_response_code(400);
+ die(json_encode($e->getMessage()));
+}
+catch (Exception $e) {
+ http_response_code(500);
+ die(json_encode($e->getMessage()));
}
-
-header('Content-Type: application/json');
-print(json_encode(run($_REQUEST)));
?>