juggl/public/api/getStats.php

39 lines
973 B
PHP
Raw Normal View History

2021-05-23 00:43:12 +02:00
<?php
session_start();
require_once(__DIR__ . "/services/apiBranch.inc.php");
require_once(__DIR__ . "/services/jsonBuilder.inc.php");
require_once(__DIR__ . "/services/responses.inc.php");
require_once(__DIR__ . "/services/jugglDbApi.inc.php");
class GetStatsBranch extends ApiBranch
{
function get(ParamCleaner $params)
{
respondStatus(405);
}
function post(ParamCleaner $params)
{
$user_id = $params->get("user_id");
$from_date = date("Y-m-d");
if ($params->exists(["from_date"])) {
$from_date = $params->get("from_date");
}
$until_date = date("Y-m-d");
if ($params->exists(["until_date"])) {
$until_date = $params->get("until_date");
}
$stats = getStats($user_id, $from_date, $until_date);
$json = new JsonBuilder();
$json->addStats($stats);
respondJson($json);
}
}
$branch = new GetStatsBranch();
$branch->execute();