mirror of
https://github.com/linuxserver/Heimdall-Apps.git
synced 2026-01-15 09:01:49 +08:00
* feat(Memos): add livestats and config support for Memos app Implement livestats functionality to display memo count and add config support for API access. Enable enhanced app features in app.json. * style(Memos): improve code formatting and readability * style: remove empty line in Memos constructor --------- Co-authored-by: Lucas Araujo <lucas.ribeiro.de.araujo@rabobank.nl>
59 lines
1.2 KiB
PHP
59 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\SupportedApps\Memos;
|
|
|
|
class Memos extends \App\SupportedApps implements \App\EnhancedApps
|
|
{
|
|
public $config;
|
|
|
|
public function __construct() {
|
|
}
|
|
|
|
public function test()
|
|
{
|
|
$test = parent::appTest(
|
|
$this->url('api/v1/auth/sessions/current'),
|
|
$this->attrs()
|
|
);
|
|
echo $test->status;
|
|
}
|
|
|
|
public function livestats()
|
|
{
|
|
$status = 'inactive';
|
|
$res = parent::execute(
|
|
$this->url('api/v1/memos'),
|
|
$this->attrs()
|
|
);
|
|
$details = json_decode($res->getBody());
|
|
|
|
$data = [];
|
|
|
|
if ($details) {
|
|
$status = 'active';
|
|
$data['memo_count'] = count($details->memos);
|
|
}
|
|
|
|
return parent::getLiveStats($status, $data);
|
|
}
|
|
|
|
public function url($endpoint)
|
|
{
|
|
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
|
|
return $api_url;
|
|
}
|
|
|
|
|
|
public function attrs()
|
|
{
|
|
$access_token = $this->config->access_token;
|
|
$attrs = [
|
|
"headers" => [
|
|
"content-type" => "application/json",
|
|
"Authorization" => "Bearer " . $access_token,
|
|
],
|
|
];
|
|
return $attrs;
|
|
}
|
|
}
|