Update accounting api resource output class
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\ApiResource\Accounting;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\State\Options;
|
||||
use ApiPlatform\Metadata as API;
|
||||
use App\Entity\Accounting as Entity;
|
||||
use App\Entity\Interface\AccountingOwnerInterface;
|
||||
use App\Entity\Money;
|
||||
use App\State\Accounting\AccountingStateProcessor;
|
||||
use App\State\Accounting\AccountingStateProvider;
|
||||
|
||||
/**
|
||||
* Accountings represent payment services used to perform the necessary payments for Transactions between Accounts.\
|
||||
* \
|
||||
* For each Accounting there is an internal implementation that handles the creation and validation of Transactions between Accounts.
|
||||
* These implementations make use of external or internal services to gather the funds that are inside a Transaction,
|
||||
* perform corroboration of funds and store the Transactions into the system.
|
||||
*/
|
||||
#[API\ApiResource(
|
||||
stateOptions: new Options(entityClass: Entity\Accounting::class),
|
||||
provider: AccountingStateProvider::class,
|
||||
processor: AccountingStateProcessor::class,
|
||||
)]
|
||||
#[API\GetCollection()]
|
||||
#[API\Get()]
|
||||
#[API\Patch(security: 'is_granted("ACCOUNTING_EDIT", object)')]
|
||||
class Accounting
|
||||
{
|
||||
public ?int $id = null;
|
||||
|
||||
public ?string $currency = null;
|
||||
|
||||
public ?AccountingOwnerInterface $owner = null;
|
||||
|
||||
public ?Money $balance = null;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\ApiResource\Accounting;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\State\Options;
|
||||
use ApiPlatform\Metadata as API;
|
||||
use App\Entity\Accounting\Accounting;
|
||||
use App\Entity\Money;
|
||||
use App\State\Accounting\AccountingStateProcessor;
|
||||
use App\State\Accounting\AccountingStateProvider;
|
||||
|
||||
/**
|
||||
* v4 features an advanced economy model under the hood.
|
||||
* Accountings are implemented as a common interface for issuing and receiving Transactions,
|
||||
* which allows different resources to have money-capabalities.
|
||||
* \
|
||||
* \
|
||||
* Many different actions can trigger changes in Accountings, such as GatewayCheckouts being successfully charged.
|
||||
*/
|
||||
#[API\ApiResource(
|
||||
shortName: 'Accounting',
|
||||
stateOptions: new Options(entityClass: Accounting::class),
|
||||
provider: AccountingStateProvider::class,
|
||||
processor: AccountingStateProcessor::class,
|
||||
)]
|
||||
#[API\GetCollection()]
|
||||
#[API\Get()]
|
||||
#[API\Patch(security: 'is_granted("ACCOUNTING_EDIT", object)')]
|
||||
class AccountingApiResource
|
||||
{
|
||||
public int $id;
|
||||
|
||||
/**
|
||||
* The preferred currency for monetary operations.\
|
||||
* 3-letter ISO 4217 currency code.
|
||||
*/
|
||||
public string $currency;
|
||||
|
||||
/**
|
||||
* Accountings can be owned by different resources.\
|
||||
* Full-body owner data is not directly embedded,
|
||||
* instead a middle object with context about the owner is given.
|
||||
*/
|
||||
public AccountingOwner $owner;
|
||||
|
||||
/**
|
||||
* The money currently held by the Accounting.
|
||||
*/
|
||||
public Money $balance;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\ApiResource\Accounting;
|
||||
|
||||
use App\Entity\User\User;
|
||||
use App\Entity\Project\Project;
|
||||
use App\Entity\Tipjar;
|
||||
|
||||
class AccountingOwner
|
||||
{
|
||||
/**
|
||||
* Full-body of the owner data.
|
||||
* @var User|Project|Tipjar
|
||||
*/
|
||||
public object $data;
|
||||
|
||||
/**
|
||||
* The schema type of the owner.
|
||||
*/
|
||||
public string $schema;
|
||||
}
|
||||
Reference in New Issue
Block a user