[ADDED] getusertransactions API call

* Fetch last `n` transactions, default `5` max `30`
* Fetch transaction summary if enabled in admin panel

Fixes #1079 once merged.
This commit is contained in:
Sebastian Grewe 2013-12-23 21:20:39 +01:00
parent e2681fe5bf
commit 5cf9ed0b3a

View File

@ -0,0 +1,32 @@
<?php
// Make sure we are called from index.php
if (!defined('SECURITY')) die('Hacking attempt');
// Check if the API is activated
$api->isActive();
// Check user token
$user_id = $api->checkAccess($user->checkApiKey($_REQUEST['api_key']), @$_REQUEST['id']);
// Fetch transactions
if (isset($_REQUEST['limit']) && $_REQUEST['limit'] < 30) {
$limit = $_REQUEST['limit'];
} else {
// Force limit
$limit = 5;
}
$data['transactions'] = $transaction->getTransactions($user_id, NULL, $limit);
// Fetch summary if enabled
if (!$setting->getValue('disable_transactionsummary')) {
$aTransactionSummary = $transaction->getTransactionSummary($_SESSION['USERDATA']['id']);
$data['transactionsummary'] = $aTransactionSummary;
}
// Output JSON format
echo $api->get_json($data);
// Supress master template
$supress_master = 1;
?>