2024-05-10 06:43:18 +02:00
|
|
|
<?php
|
|
|
|
|
2024-05-13 05:10:16 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2024-07-26 12:52:54 +02:00
|
|
|
namespace FireflyIII\JsonApi\V2;
|
2024-05-10 06:43:18 +02:00
|
|
|
|
2024-07-26 12:52:54 +02:00
|
|
|
use FireflyIII\JsonApi\V2\Accounts\AccountSchema;
|
|
|
|
use FireflyIII\JsonApi\V2\Users\UserSchema;
|
2024-07-27 15:42:43 +02:00
|
|
|
use FireflyIII\Support\JsonApi\Concerns\UsergroupAware;
|
|
|
|
use FireflyIII\Support\JsonApi\Concerns\UserGroupDetectable;
|
2024-07-28 12:23:45 +02:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2024-05-10 06:43:18 +02:00
|
|
|
use LaravelJsonApi\Core\Server\Server as BaseServer;
|
|
|
|
|
2024-07-26 18:50:41 +02:00
|
|
|
/**
|
|
|
|
* Class Server
|
|
|
|
*
|
|
|
|
* This class serves as a generic class for the v2 API "server".
|
|
|
|
*/
|
2024-05-10 06:43:18 +02:00
|
|
|
class Server extends BaseServer
|
|
|
|
{
|
2024-07-27 15:42:43 +02:00
|
|
|
use UsergroupAware;
|
|
|
|
use UserGroupDetectable;
|
|
|
|
|
2024-05-10 06:43:18 +02:00
|
|
|
/**
|
|
|
|
* The base URI namespace for this server.
|
|
|
|
*/
|
2024-07-27 15:42:43 +02:00
|
|
|
protected string $baseUri = '/api/v2';
|
2024-05-10 06:43:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Bootstrap the server when it is handling an HTTP request.
|
|
|
|
*/
|
|
|
|
public function serving(): void
|
|
|
|
{
|
2024-07-28 12:23:45 +02:00
|
|
|
Log::debug(__METHOD__);
|
2024-07-28 07:02:04 +02:00
|
|
|
// at this point the user may not actually have access to this user group.
|
2024-07-27 15:42:43 +02:00
|
|
|
$res = $this->detectUserGroup();
|
|
|
|
$this->setUserGroup($res);
|
2024-05-10 06:43:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the server's list of schemas.
|
|
|
|
*/
|
|
|
|
protected function allSchemas(): array
|
|
|
|
{
|
2024-07-28 12:23:45 +02:00
|
|
|
Log::debug(__METHOD__);
|
2024-07-29 05:06:54 +02:00
|
|
|
|
2024-05-10 06:43:18 +02:00
|
|
|
return [
|
|
|
|
AccountSchema::class,
|
|
|
|
UserSchema::class,
|
2024-07-29 05:06:54 +02:00
|
|
|
// AccountBalanceSchema::class,
|
2024-05-10 06:43:18 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|